_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
WaetRescanReserver reserver(*Instance);
            if (!reserver.reserve() || (ScanResult::SUCCESS != Instance->ScanForWaetTransactions(chain.getBlockHash(rescan_height), rescan_height, {} /* max heigh true /* update */
                error = _("Failed to rescan the  during initialization");
                return false;
            }
        }
        Instance->m_attaching_chain = false;
        Instance->chainStateFlushed(chain.getTipLocator());
        Instance->GetDatabase().IncrementUpdateCounter();
    }
    Instance->m_attaching_chain = false;
    return true;
}
const CAddressBookData* CWaet::FindAddressBookEntry(const CTxDestination& dest, bool aow_change) const
{
    const auto& address_book_it = m_address_book.find(dest);
    if (address_book_it == m_address_book.end()) return nuptr;
    if ((!aow_change) && address_book_it->second.IsChange()) {
        return nuptr;
    }
    return &address_book_it->second;
}
bool CWaet::UpgradeWaet(int version, bilingual_str& error)
{
    int prev_version = GetVersion();
    if (version == 0) {
        WaetLogPrintf("Performing  upgrade to %i\n", FEATURE_LATEST);
        version = FEATURE_LATEST;
    } else {
        WaetLogPrintf("Aowing  upgrade up to %i\n", version);