ouroboros-network-0.1.0.1: A networking layer for the Ouroboros blockchain protocol
Safe Haskell None
Language Haskell2010

Ouroboros.Network.BlockFetch.Decision

Synopsis

Deciding what to fetch

data FetchMode Source #

Constructors

FetchModeBulkSync

Use this mode when we are catching up on the chain but are stil well behind. In this mode the fetch logic will optimise for throughput rather than latency.

FetchModeDeadline

Use this mode for block-producing nodes that have a known deadline to produce a block and need to get the best chain before that. In this mode the fetch logic will optimise for picking the best chain within the given deadline.

type PeerInfo header peer extra = ( PeerFetchStatus header, PeerFetchInFlight header, PeerGSV , peer, extra) Source #

type FetchDecision result = Either FetchDecline result Source #

Throughout the decision making process we accumulate reasons to decline to fetch any blocks. This type is used to wrap intermediate and final results.

Components of the decision-making process

filterPlausibleCandidates Source #

Arguments

:: ( AnchoredFragment block -> AnchoredFragment header -> Bool )
-> AnchoredFragment block

The current chain

-> [( AnchoredFragment header, peerinfo)]
-> [( FetchDecision ( AnchoredFragment header), peerinfo)]

Keep only those candidate chains that are preferred over the current chain. Typically, this means that their length is longer than the length of the current chain.

selectForkSuffixes :: ( HasHeader header, HasHeader block, HeaderHash header ~ HeaderHash block) => AnchoredFragment block -> [( FetchDecision ( AnchoredFragment header), peerinfo)] -> [( FetchDecision (ChainSuffix header), peerinfo)] Source #

filterNotAlreadyFetched :: ( HasHeader header, HeaderHash header ~ HeaderHash block) => ( Point block -> Bool ) -> MaxSlotNo -> [( FetchDecision (ChainSuffix header), peerinfo)] -> [( FetchDecision (CandidateFragments header), peerinfo)] Source #

Find the fragments of the chain suffix that we still need to fetch, these are the fragments covering blocks that have not yet been fetched and are not currently in the process of being fetched from this peer.

Typically this is a single fragment forming a suffix of the chain, but in the general case we can get a bunch of discontiguous chain fragments.

filterNotAlreadyInFlightWithPeer :: HasHeader header => [( FetchDecision (CandidateFragments header), PeerFetchInFlight header, peerinfo)] -> [( FetchDecision (CandidateFragments header), peerinfo)] Source #

prioritisePeerChains :: forall extra header peer. ( HasHeader header, Hashable peer, Ord peer) => FetchMode -> Int -> ( AnchoredFragment header -> AnchoredFragment header -> Ordering ) -> (header -> SizeInBytes ) -> [( FetchDecision (CandidateFragments header), PeerFetchInFlight header, PeerGSV , peer, extra)] -> [( FetchDecision [ AnchoredFragment header], extra)] Source #

filterNotAlreadyInFlightWithOtherPeers :: HasHeader header => FetchMode -> [( FetchDecision [ AnchoredFragment header], PeerFetchStatus header, PeerFetchInFlight header, peerinfo)] -> [( FetchDecision [ AnchoredFragment header], peerinfo)] Source #

A penultimate step of filtering, but this time across peers, rather than individually for each peer. If we're following the parallel fetch mode then we filter out blocks that are already in-flight with other peers.

Note that this does not cover blocks that are proposed to be fetched in this round of decisions. That step is covered in fetchRequestDecisions .