From 7eaa2a696498e45123cefe58ba0ca3489ef18290 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Fri, 28 Oct 2022 22:06:15 -0500 Subject: [PATCH] wallet: skip rescan if address batch is empty --- wallet/rescan.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/wallet/rescan.go b/wallet/rescan.go index 01bdadc4ee..9ba856d9e8 100644 --- a/wallet/rescan.go +++ b/wallet/rescan.go @@ -251,14 +251,21 @@ out: // Log the newly-started rescan. numAddrs := len(batch.addrs) noun := pickNoun(numAddrs, "address", "addresses") - log.Infof("Started rescan from block %v (height %d) for %d %s", - batch.bs.Hash, batch.bs.Height, numAddrs, noun) + log.Infof("Started rescan from block %v (height %d) "+ + "for %d %s", batch.bs.Hash, batch.bs.Height, + numAddrs, noun) - err := chainClient.Rescan(&batch.bs.Hash, batch.addrs, - batch.outpoints) + if numAddrs == 0 { + batch.done(nil) + continue + } + + err := chainClient.Rescan( + &batch.bs.Hash, batch.addrs, batch.outpoints, + ) if err != nil { - log.Errorf("Rescan for %d %s failed: %v", numAddrs, - noun, err) + log.Errorf("Rescan for %d %s failed: %v", + numAddrs, noun, err) } batch.done(err) case <-quit: