@@ -166,6 +166,21 @@ void ChainScanner::UpdateTipIfChanged() {
166166 }
167167}
168168
169+ void ChainScanner::ProcessBlock (const uint256& block_hash, int block_height, bool fetch_block, bool next_interval, ScanResult& result) {
170+ if (fetch_block) {
171+ if (ScanBlock (block_hash, block_height, m_save_progress && next_interval)) {
172+ result.last_scanned_block = block_hash;
173+ result.last_scanned_height = block_height;
174+ } else {
175+ result.last_failed_block = block_hash;
176+ result.status = ScanResult::FAILURE;
177+ }
178+ } else {
179+ result.last_scanned_block = block_hash;
180+ result.last_scanned_height = block_height;
181+ }
182+ }
183+
169184bool ChainScanner::ScanBlock (const uint256& block_hash, int block_height, bool save_progress) {
170185 // Read block data and locator if needed (the locator is usually null unless we need to save progress)
171186 CBlock block;
@@ -238,28 +253,10 @@ ScanResult ChainScanner::Scan() {
238253 m_wallet.WalletLogPrintf (" Still rescanning. At block %d. Progress=%f\n " , block_height, m_progress_current);
239254 }
240255
241- bool fetch_block{true };
242- if (fast_rescan_filter) {
243- fast_rescan_filter->UpdateIfNeeded ();
244- fetch_block = ShouldFetchBlock (fast_rescan_filter, block_hash, block_height);
245- if (!fetch_block) {
246- result.last_scanned_block = block_hash;
247- result.last_scanned_height = block_height;
248- }
249- }
250-
251- if (fetch_block) {
252- if (ScanBlock (block_hash, block_height, m_save_progress && next_interval)) {
253- // scan succeeded, record block as most recent successfully scanned
254- result.last_scanned_block = block_hash;
255- result.last_scanned_height = block_height;
256- } else {
257- // could not scan block, keep scanning but record this block as the most recent failure
258- result.last_failed_block = block_hash;
259- result.status = ScanResult::FAILURE;
260- }
261- }
256+ bool fetch_block = !fast_rescan_filter ||
257+ (fast_rescan_filter->UpdateIfNeeded (), ShouldFetchBlock (fast_rescan_filter, block_hash, block_height));
262258
259+ ProcessBlock (block_hash, block_height, fetch_block, next_interval, result);
263260 m_progress_current = chain.guessVerificationProgress (block_hash);
264261 if (!m_max_height) UpdateTipIfChanged ();
265262 }
0 commit comments