fn compute_paths_spread<G, W>(
graph: &G,
src: &OffchainPublicKey,
dest: &OffchainPublicKey,
length: NonZeroUsize,
take: usize,
value_fn: MetricsValueFn<W>,
) -> (Vec<PathWithMetrics>, usize)where
G: NetworkGraphTraverse<NodeId = OffchainPublicKey, Observed = W>,
W: EdgeObservableRead + Send + 'static,Expand description
Candidate paths from src to dest, spread evenly over src’s first relayers.
The traversal is depth-first and take keeps the paths it finds first, so a single traversal
returns the whole subtree of one first relayer before it reaches the next. Over seven relayers
a three-hop subtree holds 30 paths, so 50 candidates named one or two first relayers, and
every path drawn until the next refresh went through them. Pruning for distinct first relayers
cannot restore what the pool never held: a return pool of one first relayer put a Session’s
whole SURB stock behind it, and when that relayer died nothing the Exit sent got home.
So the first edges are found once, and each first relayer’s continuations are searched
separately within an even share of take, continued from the value after the first edge so
that each path costs exactly what the single traversal would have made it cost. The shares
are interleaved, so a pool cut short at take still keeps every first relayer.
Returns the pool and the total number of continuations returned by all searches, including
retries, before filtering and limiting each share or the pool.