Skip to content

Commit

Permalink
Add SlotNo and BlockNo parameters to foldEpochState's callback
Browse files Browse the repository at this point in the history
function. This gives access to the current `SlotNo` and `BlockNo` in a
given requested block.
  • Loading branch information
Jimbo4350 committed Mar 5, 2024
1 parent 10acff0 commit 570fab1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cardano-api/internal/Cardano/Api/LedgerState.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1874,7 +1874,9 @@ foldEpochState
-> s
-- ^ an initial value for the condition state
-> ( AnyNewEpochState
-> StateT s IO LedgerStateCondition
-> SlotNo -- ^ Current (not necessarily the modt recent) slot number
-> BlockNo -- ^ Current (not necessarily the modt recent) block number
-> StateT s IO LedgerStateCondition
)
-- ^ Condition you want to check against the new epoch state.
--
Expand Down Expand Up @@ -2020,7 +2022,7 @@ foldEpochState nodeConfigFilePath socketPath validationMode terminationEpoch ini
-- There can be only one place where `takeMVar stateMv` exists otherwise this
-- code will deadlock!
condition <- bracket (takeMVar stateMv) (tryPutMVar stateMv) $ \(_prevCondition, previousState) -> do
updatedState@(!newCondition, !_) <- runStateT (checkCondition newEpochState) previousState
updatedState@(!newCondition, !_) <- runStateT (checkCondition newEpochState slotNo currBlockNo) previousState
putMVar stateMv updatedState
pure newCondition
-- Have we reached the termination epoch?
Expand Down

0 comments on commit 570fab1

Please sign in to comment.