NetDir::pick_relay: preemptively handle empty sequence

The choose_weighted behavior given an empty sequence isn't well documented and has changed over time. Handle it ourselves for consistency, and for clearer logs.

Currently, the choose_weighted behavior appears to be to return WeightError::InvalidInput. This means the corresponding is_empty branch when handling WeightError::InsufficientNonZero was never exercised. (Though may have been with previous versions of the rand crate).

Edited by Jim Newsome

Merge request reports

Loading