@@ -652,17 +652,6 @@ bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase,
652652 return false ;
653653}
654654
655- void CWallet::chainStateFlushed (ChainstateRole role, const CBlockLocator& loc)
656- {
657- // Don't update the best block until the chain is attached so that in case of a shutdown,
658- // the rescan will be restarted at next startup.
659- if (m_attaching_chain || role == ChainstateRole::BACKGROUND) {
660- return ;
661- }
662- WalletBatch batch (GetDatabase ());
663- batch.WriteBestBlock (loc);
664- }
665-
666655void CWallet::SetLastBlockProcessedInMem (int block_height, uint256 block_hash)
667656{
668657 AssertLockHeld (cs_wallet);
@@ -3143,11 +3132,6 @@ bool CWallet::AttachChain(const std::shared_ptr<CWallet>& walletInstance, interf
31433132 // be pending on the validation-side until lock release. Blocks that are connected while the
31443133 // rescan is ongoing will not be processed in the rescan but with the block connected notifications,
31453134 // so the wallet will only be completeley synced after the notifications delivery.
3146- // chainStateFlushed notifications are ignored until the rescan is finished
3147- // so that in case of a shutdown event, the rescan will be repeated at the next start.
3148- // This is temporary until rescan and notifications delivery are unified under same
3149- // interface.
3150- walletInstance->m_attaching_chain = true ; // ignores chainStateFlushed notifications
31513135 walletInstance->m_chain_notifications_handler = walletInstance->chain ().handleNotifications (walletInstance);
31523136
31533137 // If rescan_required = true, rescan_height remains equal to 0
@@ -3233,14 +3217,12 @@ bool CWallet::AttachChain(const std::shared_ptr<CWallet>& walletInstance, interf
32333217 error = _ (" Failed to rescan the wallet during initialization" );
32343218 return false ;
32353219 }
3236- walletInstance->m_attaching_chain = false ;
32373220 // Set and update the best block record
32383221 // Set last block scanned as the last block processed as it may be different in case the case of a reorg.
32393222 // Also save the best block locator because rescanning only updates it intermittently.
32403223 walletInstance->SetLastBlockProcessed (*scan_res.last_scanned_height , scan_res.last_scanned_block );
32413224 }
32423225 }
3243- walletInstance->m_attaching_chain = false ;
32443226
32453227 return true ;
32463228}
@@ -4229,11 +4211,6 @@ util::Result<MigrationResult> MigrateLegacyToDescriptor(const std::string& walle
42294211 return util::Error{_ (" Error: This wallet is already a descriptor wallet" )};
42304212 }
42314213
4232- // Flush chain state before unloading wallet
4233- CBlockLocator locator;
4234- WITH_LOCK (wallet->cs_wallet , context.chain ->findBlock (wallet->GetLastBlockHash (), FoundBlock ().locator (locator)));
4235- if (!locator.IsNull ()) wallet->chainStateFlushed (ChainstateRole::NORMAL, locator);
4236-
42374214 if (!RemoveWallet (context, wallet, /* load_on_start=*/ std::nullopt , warnings)) {
42384215 return util::Error{_ (" Unable to unload the wallet before migrating" )};
42394216 }
0 commit comments