Skip to main content

Module flow_control

Module flow_control 

Source
Expand description

HOPR-transport wiring for the Session send-window flow control.

The algorithm itself (the AIMD [WindowController], the honest-clock [DeliverySignal], the [SupplyConstraint] trait) lives in [hopr_protocol_session::flow_control]. This module supplies the two HOPR-specific pieces:

  • SurbSupply — the anti-grief SURB ceiling, reading the existing atomic BalancerStateValues as a down-only clamp (never a signal to speed up — invariant 2).
  • PacedWriter — wraps the Session socket’s write half and admits bytes only while the window has room, parking on a keep-progress timer otherwise. It never gates the read half, so the duplex socket cannot deadlock.

Structs§

PacedWriter
Wraps a Session socket, admitting writes only while the [WindowController] has room against the honest delivery clock and the SURB ceiling. Reads are delegated untouched (never gated), so the duplex socket cannot deadlock; the window always keeps at least min_window_size admissible.
SurbSupply
SURB-supply ceiling over the balancer’s atomic state. Down-only: it can cap or shrink the window (invariant 2), never open it. A healthy buffer returns no backoff — that is not a signal to go faster; only proven delivery opens the window.

Functions§

admit_bytes 🔒
Pure admission decision, including the persist probe. Extracted for unit testing.
sleep 🔒
Runtime-agnostic sleep returning a ()-future (via futures-time).