Skip to main content

Module planner

Module planner 

Source

StructsΒ§

DiversityObservation πŸ”’
What a rebuild observed about return-path relayer diversity for its key.
PathBuilder πŸ”’
What a cache entry is rebuilt from, shared by the planner and its background sweep.
PathPlanner
Path planner that resolves [DestinationRouting] to [ResolvedTransportRouting].
PathPlannerConfig
Configuration for PathPlanner’s internal path cache.
ProbeBudget πŸ”’
The node-wide allowance of IMPLAUSIBLE_PROBE_INTERVAL.
WeightingParams πŸ”’
Parameters that shape how per-path aggregates modulate the WeightedCollection weight.

ConstantsΒ§

IMPLAUSIBLE_PROBE_INTERVAL πŸ”’
How often an exploring return draw may pick a candidate below PLAUSIBLE_WEIGHT_FRACTION, node-wide.
MIN_REFRESH_PERIOD πŸ”’
Shortest accepted refresh_period. A zero period makes the sweep loop rebuild every cached multi-hop path back to back, keeping the selector and resolver continuously busy.
MIN_SHARE_SHIFT πŸ”’
Smallest change in a candidate’s share of the draws that counts as traffic having moved.
PLAUSIBLE_WEIGHT_FRACTION πŸ”’
The fraction of the best candidate’s (tempered) weight below which a candidate is one the cost function all but rejects.

FunctionsΒ§

apply_diversity_transition πŸ”’
Records a diversity transition and logs it once: a WARN when a key first collapses to a single relayer, an INFO when it first recovers. Idempotent across repeated rebuilds of the same state, so the WARN fires on the transition, not on every rebuild.
capacity_factor πŸ”’
Continuous, monotonically increasing capacity factor, bounded in (0.05, 1.0].
composite_weight πŸ”’
Composite selection weight for a candidate path.
drop_if_unchanged πŸ”’
gate_implausible πŸ”’
Zeroes every weight below PLAUSIBLE_WEIGHT_FRACTION of the best, so that a weighted draw over weights never lands on a candidate the weights all but reject.
identify_candidates πŸ”’
Gives every rebuilt collection a new process-local ID before any dictionary records are emitted. All production rebuilds and test-created replacements use this constructor; cache hits reuse the pair through its Arc. The counter is shared across planners to keep their logs unambiguous.
latency_factor πŸ”’
Continuous, monotonically decreasing latency factor, bounded in (0, 1].
pick_exploring_index πŸ”’
An exploring draw: uniform over the candidates whose weight is at least PLAUSIBLE_WEIGHT_FRACTION of the best, and over the others only when allow_implausible grants it (it is asked only when the draw lands on one).
pick_uniform_index πŸ”’
Picks a uniformly random index over len entries.
pick_weighted_index πŸ”’
Picks an index into weights with probability proportional to the weight; None if all are non-positive.
put_if_unchanged πŸ”’
Writes value under key only if swept is still the entry cached there, returning whether it was.
selection_weight πŸ”’
The weight a candidate is drawn by, as the walk valued it, tempered to spread the draws over relayers (see PathPlannerConfig::return_path_weight_temper), relayer health included.
shares_by_route πŸ”’
Each candidate’s share of the total weight, keyed by the route it takes.
should_explore πŸ”’
Whether this draw should explore β€” ignore the weights and pick uniformly among the plausible candidates (see pick_exploring_index).
temper_weights πŸ”’
Flattens weights by raising each to temper, compressing the spread between good and bad candidates without reordering them.
validate_loopback_return_rate πŸ”’
A share of loops that must return, in (0.0, 1.0]: zero is met by any relay returning the odd loop, which is what a dropping relay does, so it would never starve one.
validate_refresh_period πŸ”’
validate_refresh_within_ttl πŸ”’
A sweep that runs less often than entries expire never reaches them: the sweep walks live entries only, so an expired one is refilled on demand, and a refill that finds no paths is PathNotFound where a refreshed entry would have kept its previous weights.
validate_unit_interval πŸ”’
validate_weight_temper πŸ”’
Rejects a temper exponent outside (0, 1].
weights_moved πŸ”’
Whether re-weighting would send a materially different share of the draws somewhere else.

Type AliasesΒ§

CandidateSet πŸ”’
A dictionary key paired with the immutable collection it identifies. IDs do not order cache updates: pointer equality below remains the authority for rejecting stale refreshes.
PlannerCacheKey πŸ”’
Cache key for the path planner: (source, destination, hops).
PlannerCacheValue πŸ”’
RebuiltPaths πŸ”’