Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data FetchClientRegistry peer header block (m :: Type -> Type) = FetchClientRegistry {
- fcrCtxVar :: StrictTMVar m (Tracer m (TraceLabelPeer peer (TraceFetchClientState header)), STM m (FetchClientPolicy header block m))
- fcrFetchRegistry :: StrictTVar m (Map peer (FetchClientStateVars m header))
- fcrSyncRegistry :: StrictTVar m (Map peer (ThreadId m, StrictTMVar m (), StrictTMVar m ()))
- fcrDqRegistry :: StrictTVar m (Map peer PeerGSV)
- fcrKeepRegistry :: StrictTVar m (Map peer (ThreadId m, StrictTMVar m ()))
- fcrDying :: StrictTVar m (Set peer)
- newFetchClientRegistry :: MonadSTM m => m (FetchClientRegistry peer header block m)
- bracketFetchClient :: forall m a peer header block version. (MonadFork m, MonadMask m, MonadTimer m, Ord peer) => FetchClientRegistry peer header block m -> version -> peer -> (FetchClientContext header block m -> m a) -> m a
- bracketKeepAliveClient :: forall m a peer header block. (MonadSTM m, MonadFork m, MonadMask m, Ord peer) => FetchClientRegistry peer header block m -> peer -> (StrictTVar m (Map peer PeerGSV) -> m a) -> m a
- bracketSyncWithFetchClient :: forall m a peer header block. (MonadSTM m, MonadFork m, MonadCatch m, Ord peer) => FetchClientRegistry peer header block m -> peer -> m a -> m a
- setFetchClientContext :: MonadSTM m => FetchClientRegistry peer header block m -> Tracer m (TraceLabelPeer peer (TraceFetchClientState header)) -> STM m (FetchClientPolicy header block m) -> m ()
- data FetchClientPolicy header block (m :: Type -> Type) = FetchClientPolicy {
- blockFetchSize :: header -> SizeInBytes
- blockMatchesHeader :: header -> block -> Bool
- addFetchedBlock :: Point block -> block -> m ()
- headerForgeUTCTime :: FromConsensus header -> STM m UTCTime
- readFetchClientsStatus :: forall (m :: Type -> Type) peer header block. MonadSTM m => FetchClientRegistry peer header block m -> STM m (Map peer (PeerFetchStatus header))
- readFetchClientsStateVars :: forall (m :: Type -> Type) peer header block. MonadSTM m => FetchClientRegistry peer header block m -> STM m (Map peer (FetchClientStateVars m header))
- readPeerGSVs :: forall block header (m :: Type -> Type) peer. (MonadSTM m, Ord peer) => FetchClientRegistry peer header block m -> STM m (Map peer PeerGSV)
Registry of block fetch clients
data FetchClientRegistry peer header block (m :: Type -> Type) Source #
A registry for the threads that are executing the client side of the
BlockFetch
protocol to communicate with our peers.
The registry contains the shared variables we use to communicate with these threads, both to track their status and to provide instructions.
The threads add/remove themselves to/from this registry when they start up and shut down.
FetchClientRegistry | |
|
newFetchClientRegistry :: MonadSTM m => m (FetchClientRegistry peer header block m) Source #
bracketFetchClient :: forall m a peer header block version. (MonadFork m, MonadMask m, MonadTimer m, Ord peer) => FetchClientRegistry peer header block m -> version -> peer -> (FetchClientContext header block m -> m a) -> m a Source #
This is needed to start a block fetch client. It provides the required
FetchClientContext
. It registers and unregisters the fetch client on
start and end.
It also manages synchronisation with the corresponding chain sync client.
bracketKeepAliveClient :: forall m a peer header block. (MonadSTM m, MonadFork m, MonadMask m, Ord peer) => FetchClientRegistry peer header block m -> peer -> (StrictTVar m (Map peer PeerGSV) -> m a) -> m a Source #
bracketSyncWithFetchClient :: forall m a peer header block. (MonadSTM m, MonadFork m, MonadCatch m, Ord peer) => FetchClientRegistry peer header block m -> peer -> m a -> m a Source #
The block fetch and chain sync clients for each peer need to synchronise their startup and shutdown. This bracket operation provides that synchronisation for the chain sync client.
This must be used for the chain sync client outside of its own state registration and deregistration.
setFetchClientContext :: MonadSTM m => FetchClientRegistry peer header block m -> Tracer m (TraceLabelPeer peer (TraceFetchClientState header)) -> STM m (FetchClientPolicy header block m) -> m () Source #
data FetchClientPolicy header block (m :: Type -> Type) Source #
The policy used by the fetch clients. It is set by the central block fetch
logic, and passed to them via the FetchClientRegistry
.
FetchClientPolicy | |
|
readFetchClientsStatus :: forall (m :: Type -> Type) peer header block. MonadSTM m => FetchClientRegistry peer header block m -> STM m (Map peer (PeerFetchStatus header)) Source #
A read-only STM
action to get the current PeerFetchStatus
for all
fetch clients in the FetchClientRegistry
.
readFetchClientsStateVars :: forall (m :: Type -> Type) peer header block. MonadSTM m => FetchClientRegistry peer header block m -> STM m (Map peer (FetchClientStateVars m header)) Source #
A read-only STM
action to get the FetchClientStateVars
for all fetch
clients in the FetchClientRegistry
.
readPeerGSVs :: forall block header (m :: Type -> Type) peer. (MonadSTM m, Ord peer) => FetchClientRegistry peer header block m -> STM m (Map peer PeerGSV) Source #
A read-only STM
action to get the PeerGSV
s for all fetch
clients in the FetchClientRegistry
.