@@ -66,7 +66,7 @@ fetchBlockMethod request = do
6666 <> tshow maxFetchBlockRefs
6767 <> " ; batch your requests"
6868
69- nodeKernelAccess@ NodeKernelAccess {systemStart, readEraHistory} <- grabNodeKernelAccess
69+ nodeKernelAccess <- grabNodeKernelAccess
7070 blocks <- forM (request ^. U5c. ref) $ \ blockRef -> do
7171 (slot, headerHash) <- blockRefToPoint blockRef
7272 let throwNotFound =
@@ -77,7 +77,8 @@ fetchBlockMethod request = do
7777 <> serialiseToRawBytesHexText headerHash
7878 (rawBytes, blockInMode) <-
7979 fetchBlock nodeKernelAccess slot headerHash >>= maybe throwNotFound pure
80- timestamp <- slotTimestampOrThrow systemStart readEraHistory slot
80+ timestamp <-
81+ slotTimestampOrThrow (nodeKernelSystemStart nodeKernelAccess) (readEraHistory nodeKernelAccess) slot
8182 pure $ mkAnyChainBlock rawBytes blockInMode timestamp
8283 pure $ defMessage & U5c. block .~ blocks
8384
@@ -94,8 +95,11 @@ readTipMethod
9495 => Proto U5c. ReadTipRequest
9596 -> m (Proto U5c. ReadTipResponse )
9697readTipMethod _request = do
97- NodeKernelAccess {chainDb, systemStart, readEraHistory} <- grabNodeKernelAccess
98- tip <- readTipBlockRef chainDb (slotTimestampOrThrow systemStart readEraHistory)
98+ nodeKernelAccess <- grabNodeKernelAccess
99+ tip <-
100+ readTipBlockRef
101+ nodeKernelAccess
102+ (slotTimestampOrThrow (nodeKernelSystemStart nodeKernelAccess) (readEraHistory nodeKernelAccess))
99103 pure $ defMessage & U5c. maybe'tip .~ tip
100104
101105-- | Handle the @FollowTip@ SyncService RPC method: stream fully parsed
@@ -115,7 +119,7 @@ readTipMethod _request = do
115119-- slot and hash only, like ChainSync's @MsgRollBackward@. The tracked
116120-- window is sized to the node's security parameter /k/, so no rollback
117121-- consensus can produce falls outside it (see
118- -- 'Cardano.Rpc.Server.NodeKernelAccess.Type.NodeKernelAccess ').
122+ -- 'Cardano.Rpc.Server.NodeKernelAccess.securityParam ').
119123-- Every response also carries the current chain tip.
120124--
121125-- Errors: @INVALID_ARGUMENT@ if an intersection block ref has an invalid
@@ -131,28 +135,27 @@ followTipMethod
131135 -- ^ Callback used to send each streamed response
132136 -> m ()
133137followTipMethod request send = do
134- nodeKernelAccess@ NodeKernelAccess {chainDb, systemStart, readEraHistory, securityParam} <-
135- grabNodeKernelAccess
138+ nodeKernelAccess <- grabNodeKernelAccess
136139 requestedPoints <- traverse blockRefToIntersectPoint (request ^. U5c. intersect)
137140 withFollower nodeKernelAccess $ \ follower -> do
138141 -- an empty intersect list follows from the current tip; resolving it
139142 -- reaches into ChainDB directly (there is no 'ChainFollower' operation
140143 -- for "the current tip point"), so this step stays here rather than
141144 -- moving into 'followTipStream', which only takes an already-resolved,
142145 -- non-empty point list
143- let slotTimestamp = slotTimestampOrThrow systemStart readEraHistory
146+ let slotTimestamp = slotTimestampOrThrow (nodeKernelSystemStart nodeKernelAccess) ( readEraHistory nodeKernelAccess)
144147 startPoints <-
145148 if null requestedPoints
146149 then do
147- tipHeader <- liftIO $ Consensus. getTipHeader chainDb
150+ tipHeader <- readChainTipHeader nodeKernelAccess
148151 pure [maybe ChainPointAtGenesis tipHeaderPoint tipHeader]
149152 else pure requestedPoints
150153 followTipStream
151154 follower
152- (readTipBlockRef chainDb slotTimestamp)
155+ (readTipBlockRef nodeKernelAccess slotTimestamp)
153156 slotTimestamp
154157 (fetchBlockByChainPoint nodeKernelAccess)
155- (fromIntegral . L. unNonZero $ Consensus. maxRollbacks securityParam)
158+ (fromIntegral . L. unNonZero $ Consensus. maxRollbacks ( securityParam nodeKernelAccess) )
156159 send
157160 startPoints
158161
@@ -262,7 +265,7 @@ followTipStream
262265 -> Int
263266 -- ^ How many applied points to track for undo re-fetch. In production
264267 -- this is the node's security parameter /k/
265- -- ('Cardano.Rpc.Server.NodeKernelAccess.Type. securityParam'). Consensus
268+ -- ('Cardano.Rpc.Server.NodeKernelAccess.securityParam'). Consensus
266269 -- never rolls back more than /k/ blocks, so tracking /k/ points covers
267270 -- every rollback the protocol can produce, on any network. An entry
268271 -- costs roughly 40 bytes, so the window costs about @40 * k@ bytes per
@@ -378,12 +381,12 @@ followTipStream ChainFollower{nextChange, findIntersect} readTip slotTimestamp f
378381-- 'mkTipBlockRef', or 'Nothing' at origin.
379382readTipBlockRef
380383 :: MonadIO m
381- => Consensus. ChainDB IO ( Consensus. CardanoBlock Consensus. StandardCrypto )
384+ => NodeKernelAccess
382385 -> (SlotNo -> m UTCTime )
383386 -- ^ Convert a slot to its wall-clock timestamp
384387 -> m (Maybe (Proto U5c. BlockRef ))
385- readTipBlockRef chainDb slotTimestamp = do
386- tipHeader <- liftIO $ Consensus. getTipHeader chainDb
388+ readTipBlockRef nodeKernelAccess slotTimestamp = do
389+ tipHeader <- readChainTipHeader nodeKernelAccess
387390 forM tipHeader $ \ header ->
388391 mkTipBlockRef header <$> slotTimestamp (Consensus. blockSlot header)
389392
@@ -396,8 +399,8 @@ slotTimestampOrThrow
396399 -- ^ Read current era history from the ledger state
397400 -> SlotNo
398401 -> m UTCTime
399- slotTimestampOrThrow systemStart readEraHistory slot = do
400- eraHistory <- readEraHistory
402+ slotTimestampOrThrow systemStart readEraHistoryAction slot = do
403+ eraHistory <- readEraHistoryAction
401404 slotToUTCTime systemStart eraHistory slot
402405 & either (const throwPastHorizon) pure
403406 where
0 commit comments