Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- fetchDecisions :: ( Ord peer, Hashable peer, HasHeader header, HeaderHash header ~ HeaderHash block) => FetchDecisionPolicy header -> FetchMode -> AnchoredFragment header -> ( Point block -> Bool ) -> MaxSlotNo -> [( AnchoredFragment header, PeerInfo header peer extra)] -> [( FetchDecision ( FetchRequest header), PeerInfo header peer extra)]
-
data
FetchDecisionPolicy
header =
FetchDecisionPolicy
{
- maxInFlightReqsPerPeer :: 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
- type PeerInfo header peer extra = ( PeerFetchStatus header, PeerFetchInFlight header, PeerGSV , peer, extra)
- type FetchDecision result = Either FetchDecline result
-
data
FetchDecline
- = FetchDeclineChainNotPlausible
- | FetchDeclineChainNoIntersection
- | FetchDeclineAlreadyFetched
- | FetchDeclineInFlightThisPeer
- | FetchDeclineInFlightOtherPeer
- | FetchDeclinePeerShutdown
- | FetchDeclinePeerSlow
- | FetchDeclineReqsInFlightLimit ! Word
- | FetchDeclineBytesInFlightLimit ! SizeInBytes ! SizeInBytes ! SizeInBytes
- | FetchDeclinePeerBusy ! SizeInBytes ! SizeInBytes ! SizeInBytes
- | FetchDeclineConcurrencyLimit ! FetchMode ! Word
- filterPlausibleCandidates :: ( AnchoredFragment block -> AnchoredFragment header -> Bool ) -> AnchoredFragment block -> [( AnchoredFragment header, peerinfo)] -> [( FetchDecision ( AnchoredFragment header), peerinfo)]
- selectForkSuffixes :: ( HasHeader header, HasHeader block, HeaderHash header ~ HeaderHash block) => AnchoredFragment block -> [( FetchDecision ( AnchoredFragment header), peerinfo)] -> [( FetchDecision (ChainSuffix header), peerinfo)]
- filterNotAlreadyFetched :: ( HasHeader header, HeaderHash header ~ HeaderHash block) => ( Point block -> Bool ) -> MaxSlotNo -> [( FetchDecision (ChainSuffix header), peerinfo)] -> [( FetchDecision (CandidateFragments header), peerinfo)]
- filterNotAlreadyInFlightWithPeer :: HasHeader header => [( FetchDecision (CandidateFragments header), PeerFetchInFlight header, peerinfo)] -> [( FetchDecision (CandidateFragments header), peerinfo)]
- 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)]
- filterNotAlreadyInFlightWithOtherPeers :: HasHeader header => FetchMode -> [( FetchDecision [ AnchoredFragment header], PeerFetchStatus header, PeerFetchInFlight header, peerinfo)] -> [( FetchDecision [ AnchoredFragment header], peerinfo)]
- fetchRequestDecisions :: forall 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)]
Deciding what to fetch
fetchDecisions :: ( Ord peer, Hashable peer, HasHeader header, HeaderHash header ~ HeaderHash block) => FetchDecisionPolicy header -> FetchMode -> AnchoredFragment header -> ( Point block -> Bool ) -> MaxSlotNo -> [( AnchoredFragment header, PeerInfo header peer extra)] -> [( FetchDecision ( FetchRequest header), PeerInfo header peer extra)] Source #
data FetchDecisionPolicy header Source #
FetchDecisionPolicy | |
|
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.
data FetchDecline Source #
All the various reasons we can decide not to fetch blocks from a peer.
Instances
Eq FetchDecline Source # | |
Defined in Ouroboros.Network.BlockFetch.Decision (==) :: FetchDecline -> FetchDecline -> Bool Source # (/=) :: FetchDecline -> FetchDecline -> Bool Source # |
|
Show FetchDecline Source # | |
Defined in Ouroboros.Network.BlockFetch.Decision |
Components of the decision-making process
filterPlausibleCandidates Source #
:: ( 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
.
fetchRequestDecisions :: forall 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 #