@@ -20,33 +20,35 @@ import DMQ.Protocol.SigSubmission.Type (Sig (..))
2020
2121import Network.TypedProtocol.Codec.CBOR
2222import Ouroboros.Network.Protocol.LocalTxSubmission.Codec qualified as LTX
23+ import Ouroboros.Network.TxSubmission.Mempool.Simple
2324
2425codecLocalMsgSubmission
2526 :: forall crypto m .
2627 ( MonadST m
2728 , Crypto crypto
2829 )
29- => (SigMempoolFail -> CBOR. Encoding )
30- -> (forall s . CBOR. Decoder s SigMempoolFail )
30+ => (MempoolAddFail ( Sig crypto ) -> CBOR. Encoding )
31+ -> (forall s . CBOR. Decoder s ( MempoolAddFail ( Sig crypto )) )
3132 -> AnnotatedCodec (LocalMsgSubmission (Sig crypto )) CBOR. DeserialiseFailure m ByteString
3233codecLocalMsgSubmission =
3334 LTX. anncodecLocalTxSubmission' SigWithBytes SigSubmission. encodeSig SigSubmission. decodeSig
3435
35- encodeReject :: SigMempoolFail -> CBOR. Encoding
36- encodeReject = \ case
37- SigInvalid reason -> CBOR. encodeListLen 2 <> CBOR. encodeWord 0 <> CBOR. encodeString reason
38- SigDuplicate -> CBOR. encodeListLen 1 <> CBOR. encodeWord 1
39- SigExpired -> CBOR. encodeListLen 1 <> CBOR. encodeWord 2
40- SigResultOther reason
41- -> CBOR. encodeListLen 2 <> CBOR. encodeWord 3 <> CBOR. encodeString reason
42-
43- decodeReject :: CBOR. Decoder s SigMempoolFail
44- decodeReject = do
45- len <- CBOR. decodeListLen
46- tag <- CBOR. decodeWord
47- case (tag, len) of
48- (0 , 2 ) -> SigInvalid <$> CBOR. decodeString
49- (1 , 1 ) -> pure SigDuplicate
50- (2 , 1 ) -> pure SigExpired
51- (3 , 2 ) -> SigResultOther <$> CBOR. decodeString
52- _otherwise -> fail $ printf " unrecognized (tag,len) = (%d, %d)" tag len
36+ encodeReject :: MempoolAddFail (Sig crypto ) -> CBOR. Encoding
37+ encodeReject = undefined
38+ -- encodeReject = \case
39+ -- SigInvalid reason -> CBOR.encodeListLen 2 <> CBOR.encodeWord 0 <> CBOR.encodeString reason
40+ -- SigDuplicate -> CBOR.encodeListLen 1 <> CBOR.encodeWord 1
41+ -- SigExpired -> CBOR.encodeListLen 1 <> CBOR.encodeWord 2
42+ -- SigResultOther reason
43+ -- -> CBOR.encodeListLen 2 <> CBOR.encodeWord 3 <> CBOR.encodeString reason
44+
45+ decodeReject :: CBOR. Decoder s (MempoolAddFail (Sig crypto ))
46+ decodeReject = return undefined -- do
47+ -- len <- CBOR.decodeListLen
48+ -- tag <- CBOR.decodeWord
49+ -- case (tag, len) of
50+ -- (0, 2) -> SigInvalid <$> CBOR.decodeString
51+ -- (1, 1) -> pure SigDuplicate
52+ -- (2, 1) -> pure SigExpired
53+ -- (3, 2) -> SigResultOther <$> CBOR.decodeString
54+ -- _otherwise -> fail $ printf "unrecognized (tag,len) = (%d, %d)" tag len
0 commit comments