ouroboros-network-0.1.0.0: A networking layer for the Ouroboros blockchain protocol

Ouroboros.Network.BlockFetch.Decision

Synopsis

# Deciding what to fetch

Constructors

 FetchDecisionPolicy FieldsmaxInFlightReqsPerPeer ∷ Word maxConcurrencyBulkSync ∷ Word maxConcurrencyDeadline ∷ Word decisionLoopInterval ∷ DiffTime peerSalt ∷ Int plausibleCandidateChain ∷ HasCallStack ⇒ AnchoredFragment header → AnchoredFragment header → Bool compareCandidateChains ∷ HasCallStack ⇒ AnchoredFragment header → AnchoredFragment header → Ordering blockFetchSize ∷ header → SizeInBytes

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.

#### Instances

Instances details
 Source # Instance detailsDefined in Ouroboros.Network.BlockFetch.Decision Methods Source # Instance detailsDefined in Ouroboros.Network.BlockFetch.Decision Methods

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.

All the various reasons we can decide not to fetch blocks from a peer.

#### Instances

Instances details
 Source # Instance detailsDefined in Ouroboros.Network.BlockFetch.Decision Methods Source # Instance detailsDefined in Ouroboros.Network.BlockFetch.Decision Methods

## Components of the decision-making process

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.

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.

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