Extract print_status_change so it is easily testable

This commit is contained in:
Thomas Eizinger 2021-07-08 12:38:03 +10:00
parent 2eb7fab0c3
commit 991dbf496e
No known key found for this signature in database
GPG Key ID: 651AC83A6C6C8B96

View File

@ -149,16 +149,7 @@ impl Wallet {
}
};
match (last_status, new_status) {
(None, new_status) => {
tracing::debug!(%txid, status = %new_status, "Found relevant Bitcoin transaction");
},
(Some(old_status), new_status) => {
tracing::debug!(%txid, %new_status, %old_status, "Bitcoin transaction status changed");
}
}
last_status = Some(new_status);
last_status = Some(print_status_change(txid, last_status, new_status));
let all_receivers_gone = sender.send(new_status).is_err();
@ -182,6 +173,19 @@ impl Wallet {
}
}
fn print_status_change(txid: Txid, old: Option<ScriptStatus>, new: ScriptStatus) -> ScriptStatus {
match (old, new) {
(None, new_status) => {
tracing::debug!(%txid, status = %new_status, "Found relevant Bitcoin transaction");
}
(Some(old_status), new_status) => {
tracing::debug!(%txid, %new_status, %old_status, "Bitcoin transaction status changed");
}
}
new
}
/// Represents a subscription to the status of a given transaction.
#[derive(Debug, Clone)]
pub struct Subscription {