Skip to content

Commit 09c63b0

Browse files
committed
simln-lib/refactor: remove duplicate payment tracker lookup
Also shorten some log lines while we're here.
1 parent a1c4f6d commit 09c63b0

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

simln-lib/src/lib.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,17 +1141,18 @@ async fn produce_payment_events<C: Clock>(
11411141
Duration::from_secs(0)
11421142
}
11431143
};
1144-
let payment_tracker = payments_tracker.get(&source).ok_or(SimulationError::PaymentGenerationError(
1144+
let payment_tracker = payments_tracker.get_mut(&source).ok_or(SimulationError::PaymentGenerationError(
11451145
PaymentGenerationError(format!("executor {} not found", source)),
11461146
))?;
11471147

11481148
if let Some(c) = payment_tracker.executor.payment_generator.payment_count() {
11491149
if c == payment_tracker.payments_completed {
1150-
log::info!( "Payment count has been met for {}: {c} payments. Stopping the activity.", payment_tracker.executor.source_info);
1150+
log::info!( "Payment count has been met for {}: {c} payments. Stopping the activity.", source);
11511151
continue
11521152
}
11531153
}
1154-
let node = nodes.get(&payment_tracker.executor.source_info.pubkey).ok_or(SimulationError::MissingNodeError(format!("Source node not found, {}", payment_tracker.executor.source_info.pubkey)))?.clone();
1154+
let node = nodes.get(&source).ok_or(
1155+
SimulationError::MissingNodeError(format!("Source node not found, {}", source)))?.clone();
11551156

11561157
// pe: produce events
11571158
let pe_shutdown = shutdown.clone();
@@ -1169,9 +1170,7 @@ async fn produce_payment_events<C: Clock>(
11691170
continue;
11701171
}
11711172

1172-
payments_tracker
1173-
.entry(source)
1174-
.and_modify(|p| p.payments_completed = p.payments_completed + 1);
1173+
payment_tracker.payments_completed +=1;
11751174

11761175
select! {
11771176
biased;
@@ -1192,7 +1191,6 @@ async fn produce_payment_events<C: Clock>(
11921191
pe_shutdown.trigger();
11931192
log::debug!("Not able to send event payment for {amount}: {source} -> {}. Exited with error {e}.", destination);
11941193
} else {
1195-
11961194
log::debug!("Send event payment for {source} completed successfully.");
11971195
}
11981196
});

0 commit comments

Comments
 (0)