Skip to content

Commit 0405467

Browse files
carlaKCclaude
andcommitted
simln-lib: make the remaining selects biased
Two select! loops still polled their branches in tokio's default random order: the payment-failure result send in produce_simulation_results, and the interceptor-result drain in the SimNode HTLC forwarding path. Random branch selection is a source of run-to-run non-determinism. Make both biased so their poll order is fixed. Branch order is unchanged, so behaviour is identical save for the now-deterministic ordering. The shutdown listener already sits first in the failure-send loop, matching the shutdown-first convention used elsewhere. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 4cbad7a commit 0405467

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

simln-lib/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,6 +1514,7 @@ async fn produce_simulation_results(
15141514
},
15151515
SimulationOutput::SendPaymentFailure(payment, result) => {
15161516
select! {
1517+
biased;
15171518
_ = listener.clone() => {
15181519
return Ok(());
15191520
},

simln-lib/src/sim_node.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,7 @@ async fn handle_intercepted_htlc(
964964
let mut interceptor_failure = None;
965965
'get_resp: loop {
966966
tokio::select! {
967+
biased;
967968
res = intercepts.join_next() => {
968969
let res = match res {
969970
Some(res) => res,

0 commit comments

Comments
 (0)