Skip to main content

plan_transfer

Function plan_transfer 

Source
pub fn plan_transfer(
    snapshot: &PathSnapshot,
    link: LinkBehaviour,
    advice: HeldAdvice,
    bounds: LaneWindows,
) -> TransferPlan
Expand description

Plan transfers on snapshot, given what the link has shown (link), the server’s advice, and the client’s compiled window bounds. Pure: the same inputs always plan the same.

The rules, in precedence order:

  1. An unreachable path admits nothing (Hold::Offline); a critical thermal state admits nothing (Hold::ThermalCritical).
  2. The class is the cost’s, promoted to adverse while the link behaves adversely.
  3. Bulk tiers wait on anything but an unmetered, well-behaved link (Hold::Cost, Hold::Adverse), then on low-power mode, a serious thermal state, and a background deadline under MIN_BULK_DEADLINE, in that order. The index tier still runs.
  4. The windows are bounds, lowered by fresh advice, and narrowed to one session in low-power mode or from a serious thermal state up.
  5. Under adverse a chunk targets ADVERSE_TARGET_REQUEST_DURATION and a fetch uses the bounded range window; otherwise TARGET_REQUEST_DURATION and the open remainder.