Skip to content

Commit 7f17b74

Browse files
committed
Abstract over vote in LeiosNotify and add json encoder
This will avoid us needing to change the cardano-node code when we change message formats of the notify protocol. The abstraction over 'vote' is needed to avoid a cyclic dependency. Moving the toObject function would have been the alternative, but I followed the existing pattern.
1 parent 51cc1f2 commit 7f17b74

3 files changed

Lines changed: 149 additions & 93 deletions

File tree

ouroboros-consensus-diffusion/src/ouroboros-consensus-diffusion/Ouroboros/Consensus/Network/NodeToNode.hs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ import LeiosDemoTypes
7979
( LeiosEb
8080
, LeiosPoint (..)
8181
, LeiosTx
82+
, LeiosVote
8283
, TraceLeiosKernel (..)
8384
, TraceLeiosPeer (..)
8485
)
@@ -251,11 +252,11 @@ data Handlers m addr blk = Handlers
251252
NodeToNodeVersion ->
252253
ControlMessageSTM m ->
253254
ConnectionId addr ->
254-
LeiosNotifyClientPeerPipelined LeiosPoint () m ()
255+
LeiosNotifyClientPeerPipelined LeiosPoint () LeiosVote m ()
255256
, hLeiosNotifyServer ::
256257
NodeToNodeVersion ->
257258
ConnectionId addr ->
258-
LeiosNotifyServerPeer LeiosPoint () m ()
259+
LeiosNotifyServerPeer LeiosPoint () LeiosVote m ()
259260
, hLeiosFetchClient ::
260261
NodeToNodeVersion ->
261262
ControlMessageSTM m ->
@@ -475,7 +476,7 @@ data Codecs blk addr e m bCS bSCS bBF bSBF bTX bKA bPS bLN bLF = Codecs
475476
, cTxSubmission2Codec :: Codec (TxSubmission2 (GenTxId blk) (GenTx blk)) e m bTX
476477
, cKeepAliveCodec :: Codec KeepAlive e m bKA
477478
, cPeerSharingCodec :: Codec (PeerSharing addr) e m bPS
478-
, cLeiosNotifyCodec :: Codec (LeiosNotify LeiosPoint ()) e m bLN
479+
, cLeiosNotifyCodec :: Codec (LeiosNotify LeiosPoint () LeiosVote) e m bLN
479480
, cLeiosFetchCodec :: Codec (LeiosFetch LeiosPoint LeiosEb LeiosTx) e m bLF
480481
}
481482

@@ -548,6 +549,8 @@ defaultCodecs ccfg version encAddr decAddr nodeToNodeVersion =
548549
Leios.decodeLeiosPoint
549550
(\() -> CBOR.encodeNull)
550551
CBOR.decodeNull
552+
Leios.encodeLeiosVote
553+
Leios.decodeLeiosVote
551554
, cLeiosFetchCodec =
552555
codecLeiosFetch
553556
Leios.encodeLeiosPoint
@@ -582,7 +585,7 @@ identityCodecs ::
582585
(AnyMessage (TxSubmission2 (GenTxId blk) (GenTx blk)))
583586
(AnyMessage KeepAlive)
584587
(AnyMessage (PeerSharing addr))
585-
(AnyMessage (LeiosNotify LeiosPoint ()))
588+
(AnyMessage (LeiosNotify LeiosPoint () LeiosVote))
586589
(AnyMessage (LeiosFetch LeiosPoint LeiosEb LeiosTx))
587590
identityCodecs =
588591
Codecs
@@ -617,7 +620,7 @@ data Tracers' peer ntnAddr blk e f = Tracers
617620
f (TraceLabelPeer peer (TraceSendRecv (TxSubmission2 (GenTxId blk) (GenTx blk))))
618621
, tKeepAliveTracer :: f (TraceLabelPeer peer (TraceSendRecv KeepAlive))
619622
, tPeerSharingTracer :: f (TraceLabelPeer peer (TraceSendRecv (PeerSharing ntnAddr)))
620-
, tLeiosNotifyTracer :: f (TraceLabelPeer peer (TraceSendRecv (LeiosNotify LeiosPoint ())))
623+
, tLeiosNotifyTracer :: f (TraceLabelPeer peer (TraceSendRecv (LeiosNotify LeiosPoint () LeiosVote)))
621624
, tLeiosFetchTracer ::
622625
f (TraceLabelPeer peer (TraceSendRecv (LeiosFetch LeiosPoint LeiosEb LeiosTx)))
623626
}
@@ -761,9 +764,9 @@ data ByteLimits bCS bBF bTX bKA bLN bLF = ByteLimits
761764
KeepAlive
762765
bKA
763766
, blLeiosNotify ::
764-
forall point announcement.
767+
forall point announcement vote.
765768
ProtocolSizeLimits
766-
(LeiosNotify point announcement)
769+
(LeiosNotify point announcement vote)
767770
bLN
768771
, blLeiosFetch ::
769772
forall point eb tx.

0 commit comments

Comments
 (0)