_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
boost::signals2::signal<void (const std::string &title, int nProgress)> ShowProgress;
    
    boost::signals2::signal<void (bool fHaveWatchOnly)> NotifyWatchonlyChanged;
    
    boost::signals2::signal<void ()> NotifyCanGetAddressesChanged;
    /**
     * Wallet status (encrypted, locked) changed.
     * Note: Called without locks held.
     */
    boost::signals2::signal<void (CWallet* wallet)> NotifyStatusChanged;
    
    bool GetBroadcastTransactions() const { return fBroadcastTransactions; }
    
    void SetBroadcastTransactions(bool broadcast) { fBroadcastTransactions = broadcast; }
    
    bool TransactionCanBeAbandoned(const uint256& hashTx) const;
    
    bool AbandonTransaction(const uint256& hashTx);
    
    bool MarkReplaced(const uint256& originalHash, const uint256& newHash);
    
    static std::shared_ptr<CWallet> Create(WalletContext& context, const std::string& name, std::unique_ptr<WalletDatabase> database, uint64_t wallet_creation_flags, bilingual_str& error, std::vector<bilingual_str>& warnings);
    /**
     * Wallet post-init setup
     * Gives the wallet a chance to register repetitive tasks and complete post-init tasks
     */
    void postInitProcess();
    bool BackupWallet(const std::string& strDest) const;
    
    bool IsHDEnabled() const;