-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
64428c6
commit 4f94175
Showing
23 changed files
with
4,053 additions
and
3,383 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
823 changes: 405 additions & 418 deletions
823
hydra-node/golden/ReasonablySized (ClientInput (Tx ConwayEra)).json
Large diffs are not rendered by default.
Oops, something went wrong.
811 changes: 167 additions & 644 deletions
811
hydra-node/golden/ReasonablySized (DraftCommitTxRequest (Tx ConwayEra)).json
Large diffs are not rendered by default.
Oops, something went wrong.
5,537 changes: 3,346 additions & 2,191 deletions
5,537
hydra-node/golden/StateEvent (Tx ConwayEra).json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module Hydra.Network.Ouroboros.Codec where | ||
|
||
import Hydra.Prelude | ||
|
||
import Cardano.Binary qualified as CBOR | ||
import Codec.CBOR.Read qualified as CBOR | ||
import Hydra.Network.Ouroboros.Type (FireForget (..), Message (..), SFireForget (..)) | ||
import Network.TypedProtocol.Codec | ||
import Network.TypedProtocol.Codec.CBOR (mkCodecCborLazyBS) | ||
import Network.TypedProtocol.Core | ||
|
||
codecFireForget :: | ||
forall m msg. | ||
(MonadST m, FromCBOR msg, ToCBOR msg) => | ||
Codec (FireForget msg) CBOR.DeserialiseFailure m LByteString | ||
codecFireForget = | ||
mkCodecCborLazyBS encode decode | ||
where | ||
encode :: | ||
forall msg' (st :: FireForget msg') (st' :: FireForget msg'). | ||
ToCBOR msg' => | ||
Message (FireForget msg') st st' -> | ||
CBOR.Encoding | ||
encode MsgDone = CBOR.encodeWord 0 | ||
encode (MsgSend msg) = CBOR.encodeWord 1 <> toCBOR msg | ||
|
||
decode :: | ||
forall msg' s (st :: FireForget msg'). | ||
(FromCBOR msg', ActiveState st) => | ||
StateToken st -> | ||
CBOR.Decoder s (SomeMessage st) | ||
decode stok = do | ||
key <- CBOR.decodeWord | ||
case (stok, key) of | ||
(SingIdle, 0) -> pure $ SomeMessage MsgDone | ||
(SingIdle, 1) -> SomeMessage . MsgSend <$> fromCBOR | ||
(_, _) -> fail "codedFireForget.StIdle: unexpected" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.