@@ -28,7 +28,7 @@ import Data.Void (Void)
2828import System.Random (StdGen )
2929import System.Random qualified as Random
3030
31- import Ouroboros.Network.BlockFetch ( newFetchClientRegistry )
31+ import Ouroboros.Network.KeepAlive ( newKeepAliveRegistry )
3232import Ouroboros.Network.Magic (NetworkMagic (.. ))
3333import Ouroboros.Network.PeerSelection.Governor.Types
3434 (makePublicPeerSelectionStateVar )
@@ -42,6 +42,7 @@ import Ouroboros.Network.TxSubmission.Mempool.Simple qualified as Mempool
4242import DMQ.Configuration
4343import DMQ.Diffusion.NodeKernel.Types
4444import DMQ.Diffusion.PeerSelection.PeerMetric (mkPeerMetric )
45+ import DMQ.Genesis
4546import DMQ.Policy qualified as Policy
4647import DMQ.Protocol.SigSubmission.Type (Sig (sigExpiresAt , sigId ), SigId )
4748import DMQ.Tracer
@@ -52,31 +53,34 @@ newNodeKernel :: forall crypto ntnAddr m.
5253 , Ord ntnAddr
5354 )
5455 => StdGen
56+ -> ShelleyGenesis
5557 -> m (NodeKernel crypto ntnAddr m )
56- newNodeKernel rng = do
58+ newNodeKernel rng ShelleyGenesis {sgMaxKESEvolutions} = do
5759 publicPeerSelectionStateVar <- makePublicPeerSelectionStateVar
5860
59- fetchClientRegistry <- newFetchClientRegistry
61+ keepAliveRegistry <- newKeepAliveRegistry
6062 peerSharingRegistry <- newPeerSharingRegistry
6163
6264 mempool <- Mempool. empty
6365 sigChannelVar <- newTxChannelsVar
6466 sigMempoolSem <- newTxMempoolSem
6567 let (rng', rng'') = Random. splitGen rng
6668 sigSharedTxStateVar <- newSharedTxStateVar rng'
67- (nextEpochVar , ocertCountersVar, stakePoolsVar, ledgerBigPeersVar, ledgerPeersVar) <- atomically $
68- (,,,,) <$> newTVar Nothing
69+ (readinessVar , ocertCountersVar, stakePoolsVar, ledgerBigPeersVar, ledgerPeersVar) <- atomically $
70+ (,,,,) <$> newTVar NotReady
6971 <*> newTVar Map. empty
7072 <*> newTVar Map. empty
7173 <*> newTVar Nothing
7274 <*> newEmptyTMVar
7375
7476 let withPoolValidationCtx
75- :: forall a . (PoolValidationCtx -> (a , PoolValidationCtx )) -> STM m a
76- withPoolValidationCtx f = do
77- ctx <- PoolValidationCtx <$> readTVar nextEpochVar
78- <*> readTVar stakePoolsVar
79- <*> readTVar ocertCountersVar
77+ :: forall a . UTCTime -> (PoolValidationCtx -> (a , PoolValidationCtx )) -> STM m a
78+ withPoolValidationCtx now f = do
79+ ctx <- PoolValidationCtx now
80+ <$> readTVar readinessVar
81+ <*> readTVar stakePoolsVar
82+ <*> readTVar ocertCountersVar
83+ <*> pure sgMaxKESEvolutions
8084 let (a, PoolValidationCtx {vctxOcertMap}) = f ctx
8185 writeTVar ocertCountersVar vctxOcertMap
8286 return a
@@ -97,14 +101,14 @@ newNodeKernel rng = do
97101
98102 peerMetric <- mkPeerMetric
99103
100- pure NodeKernel { fetchClientRegistry
104+ pure NodeKernel { keepAliveRegistry
101105 , peerSharingRegistry
102106 , peerSharingAPI
103107 , mempool
104108 , sigChannelVar
105109 , sigMempoolSem
106110 , sigSharedTxStateVar
107- , nextEpochVar
111+ , readinessVar
108112 , stakePools
109113 , peerMetric
110114 }
@@ -123,6 +127,7 @@ withNodeKernel :: forall crypto ntnAddr ntcAddr m a.
123127 )
124128 => DMQTracers crypto ntnAddr ntcAddr m
125129 -> Configuration
130+ -> ShelleyGenesis
126131 -> StdGen
127132 -> (NetworkMagic -> NodeKernel crypto ntnAddr m -> m (Either SomeException Void ))
128133 -> (NodeKernel crypto ntnAddr m -> m a )
@@ -133,13 +138,14 @@ withNodeKernel DMQTracers { sigSubmissionLogicTracer }
133138 Configuration {
134139 dmqcCardanoNetworkMagic = I networkMagic
135140 }
141+ shelleyGenesis
136142 rng
137143 mkStakePoolMonitor k = do
138144 nodeKernel@ NodeKernel { mempool,
139145 sigChannelVar,
140146 sigSharedTxStateVar
141147 }
142- <- newNodeKernel rng
148+ <- newNodeKernel rng shelleyGenesis
143149 withAsync (mempoolWorker mempool)
144150 $ \ mempoolThread ->
145151 withAsync (decisionLogicThreads
0 commit comments