Skip to content

Commit 7a4962b

Browse files
iohk-bors[bot]nfrisbyamesgen
authored
Merge #3688
3688: Block diffusion pipelining r=nfrisby a=nfrisby This PR adds block diffusion pipelining, primarily by finally introducing the long-existing concept of _the tentative chain_ into the code. Main changes: - add the tentative chain header to the ChainDB state. - have the `Follower`s for the Node-To-Node ChainSync server follow the tentative chain instead of only the selected chain, thus sending the tentative header before the underlying block has been validated - this now means some honest nodes will send us an invalid block, when the block is tentative, so we adjust ChainSync and BlockFetch clients to allow that in limited number of scenarios necessary for the common pipelining scenarios Co-authored-by: Nicolas Frisby <[email protected]> Co-authored-by: Alexander Esgen <[email protected]>
2 parents 57fc6e2 + 3d3f9e5 commit 7a4962b

File tree

1 file changed

+10
-0
lines changed
  • strict-stm/src/Control/Monad/Class/MonadSTM

1 file changed

+10
-0
lines changed

strict-stm/src/Control/Monad/Class/MonadSTM/Strict.hs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module Control.Monad.Class.MonadSTM.Strict
2323
, fromLazyTVar
2424
, newTVar
2525
, newTVarIO
26+
, newTVarWithInvariant
2627
, newTVarWithInvariantIO
2728
, readTVar
2829
, readTVarIO
@@ -149,6 +150,15 @@ newTVarM :: MonadSTM m => a -> m (StrictTVar m a)
149150
newTVarM = newTVarIO
150151
{-# DEPRECATED newTVarM "Use newTVarIO" #-}
151152

153+
newTVarWithInvariant :: (MonadSTM m, HasCallStack)
154+
=> (a -> Maybe String) -- ^ Invariant (expect 'Nothing')
155+
-> a
156+
-> STM m (StrictTVar m a)
157+
newTVarWithInvariant invariant !a =
158+
checkInvariant (invariant a) $
159+
(\tvar -> mkStrictTVar invariant tvar)
160+
<$> Lazy.newTVar a
161+
152162
newTVarWithInvariantIO :: (MonadSTM m, HasCallStack)
153163
=> (a -> Maybe String) -- ^ Invariant (expect 'Nothing')
154164
-> a

0 commit comments

Comments
 (0)