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

Ouroboros.Network.BlockFetch.Decision

Synopsis

Deciding what to fetch

fetchDecisions ∷ (Ord peer, Hashable peer, HasHeader header, HeaderHash header ~ HeaderHash block) ⇒ FetchDecisionPolicy header → FetchModeAnchoredFragment header → (Point block → Bool) → MaxSlotNo → [(AnchoredFragment header, PeerInfo header peer extra)] → [(FetchDecision (FetchRequest header), PeerInfo header peer extra)] Source #

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
Eq FetchMode Source # 
Instance details

Defined in Ouroboros.Network.BlockFetch.Decision

Show FetchMode Source # 
Instance details

Defined in Ouroboros.Network.BlockFetch.Decision

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.

filterNotAlreadyInFlightWithPeerHasHeader header ⇒ [(FetchDecision (CandidateFragments header), PeerFetchInFlight header, peerinfo)] → [(FetchDecision (CandidateFragments header), peerinfo)] Source #

prioritisePeerChains ∷ ∀ extra header peer. (HasHeader header, Hashable peer, Ord peer) ⇒ FetchModeInt → (AnchoredFragment header → AnchoredFragment header → Ordering) → (header → SizeInBytes) → [(FetchDecision (CandidateFragments header), PeerFetchInFlight header, PeerGSV, peer, extra)] → [(FetchDecision [AnchoredFragment header], extra)] Source #

filterNotAlreadyInFlightWithOtherPeersHasHeader 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.

fetchRequestDecisions ∷ ∀ extra header peer. (Hashable peer, HasHeader header, Ord peer) ⇒ FetchDecisionPolicy header → FetchMode → [(FetchDecision [AnchoredFragment header], PeerFetchStatus header, PeerFetchInFlight header, PeerGSV, peer, extra)] → [(FetchDecision (FetchRequest header), extra)] Source #