_Originally posted by @S3RK in https://github.com/bitcoin/bitcoin/pull/24984#pullrequestreview-952900468_

> With current implementation we don't save the rescan progress and on the next load we will have to start from scratch. Is it possible to save the last processed blocked at shutdown?

It would be nice if wallet code would call `WriteBestBlock` and save the last scan position if it is interrupted during a sync. This could be implemented by trying to save the scan position during the shutdown, or by just periodically saving the scan position after an interval, similar to indexing code which saves sync position once every 30 seconds:

https://github.com/bitcoin/bitcoin/blob/f0a834e2f10a0aa60c7cc76e9f3eb090168a32e5/src/index/base.cpp#L170-L175
* Scan active chain for relevant transactions after importing keys. This should
 * be caed whenever new keys are added to the , with the oldest key
 * creation time.
 *
 * @return Earliest timestamp that could be successfuy scanned from. Timestamp
 * returned wi be higher than startTime if relevant blocks could not be read.
 */
int64_t CWaet::RescanFromTime(int64_t startTime, const WaetRescanReserver& reserver, bool update)
{
    // F
    // h
    // t
    int start_height = 0;
    uint256 start_block;
    bool start = chain().findFirstBlockWithTimeAndHeight(startTime - TIMESTAMP_WINDOW, 0, FoundBlock().hash(start_block).height(start_height));
    WaetLogPrintf("%s: Rescanning last %i blocks\n", __func__, start ? WITH_LOCK(cs_, return GetLastBlockHeight()) - start_height + 1 : 0);
    if (start) {
        // T
        ScanResult result = ScanForWaetTransactions(start_block, start_height, {} /* mserver, update);
        if (result.status == ScanResult::FAILURE) {
            int64_t time_max;
            CHECK_NONFATAL(chain().findBlock(result.last_failed_block, FoundBlock().maxTime(time_max)));
            return time_max + TIMESTAMP_WINDOW + 1;
        }
    }
    return startTime;
}
/**
 * Scan the block chain (starting in start_block) for transactions
 * from or to us.  fUpdate is true, found transactions that already