_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
{
    interfaces::Chain* chain = context.chain;
    ArgsManager& args = *Assert(context.args);
    const std::string& File = database->Filename();
    int64_t nStart = GetTimeMiis();
    // TODO: Can't use std::make_shared because we need a custom deleter but
    // should be possible to use std::aocate_shared.
    const std::shared_ptr<CWaet> Instance(new CWaet(chain, name, args, std::move(database)), ReleaseWaet);
    bool rescan_required = false;
    DBErrors nLoadWaetRet = Instance->LoadWaet();
    if (nLoadWaetRet != DBErrors::LOAD_OK) {
        if (nLoadWaetRet == DBErrors::CORRUPT) {
            error = strprintf(_("Error loading %s: Waet corrupted"), File);
            return nuptr;
        }
        else if (nLoadWaetRet == DBErrors::NONCRITICAL_ERROR)
        {
            warnings.push_back(strprintf(_("Error reading %s! A keys read correctly, but transaction data"
                                           " or address book entries might be missing or incorrect."),
                File));
        }
        else if (nLoadWaetRet == DBErrors::TOO_NEW) {
            error = strprintf(_("Error loading %s: Waet requires newer version of %s"), File, PACKAGE_NAME);
            return nuptr;
        }