Skip to content

Commit 0a0fe9d

Browse files
committed
f Make it a closure
1 parent 615a5fc commit 0a0fe9d

File tree

1 file changed

+5
-26
lines changed

1 file changed

+5
-26
lines changed

src/chain/mod.rs

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -756,12 +756,8 @@ impl ChainSource {
756756
let incremental_sync =
757757
node_metrics.read().unwrap().latest_onchain_wallet_sync_timestamp.is_some();
758758

759-
fn apply_wallet_update(
760-
update_res: Result<BdkUpdate, Error>, incremental_sync: bool, now: Instant,
761-
node_metrics: Arc<RwLock<NodeMetrics>>, onchain_wallet: Arc<Wallet>,
762-
kv_store: Arc<DynStore>, logger: Arc<Logger>,
763-
) -> Result<(), Error> {
764-
match update_res {
759+
let apply_wallet_update =
760+
|update_res: Result<BdkUpdate, Error>, now: Instant| match update_res {
765761
Ok(update) => match onchain_wallet.apply_update(update) {
766762
Ok(()) => {
767763
log_info!(
@@ -789,8 +785,7 @@ impl ChainSource {
789785
Err(e) => Err(e),
790786
},
791787
Err(e) => Err(e),
792-
}
793-
}
788+
};
794789

795790
let cached_txs = onchain_wallet.get_cached_txs();
796791

@@ -801,30 +796,14 @@ impl ChainSource {
801796

802797
let now = Instant::now();
803798
let update_res = incremental_sync_fut.await.map(|u| u.into());
804-
apply_wallet_update(
805-
update_res,
806-
incremental_sync,
807-
now,
808-
Arc::clone(&node_metrics),
809-
Arc::clone(&onchain_wallet),
810-
Arc::clone(&kv_store),
811-
Arc::clone(&logger),
812-
)
799+
apply_wallet_update(update_res, now)
813800
} else {
814801
let full_scan_request = onchain_wallet.get_full_scan_request();
815802
let full_scan_fut =
816803
electrum_client.get_full_scan_wallet_update(full_scan_request, cached_txs);
817804
let now = Instant::now();
818805
let update_res = full_scan_fut.await.map(|u| u.into());
819-
apply_wallet_update(
820-
update_res,
821-
incremental_sync,
822-
now,
823-
Arc::clone(&node_metrics),
824-
Arc::clone(&onchain_wallet),
825-
Arc::clone(&kv_store),
826-
Arc::clone(&logger),
827-
)
806+
apply_wallet_update(update_res, now)
828807
};
829808

830809
onchain_wallet_sync_status.lock().unwrap().propagate_result_to_subscribers(res);

0 commit comments

Comments
 (0)