@@ -652,17 +652,6 @@ bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase,
652
652
return false ;
653
653
}
654
654
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
-
666
655
void CWallet::SetLastBlockProcessedInMem (int block_height, uint256 block_hash)
667
656
{
668
657
AssertLockHeld (cs_wallet);
@@ -3143,11 +3132,6 @@ bool CWallet::AttachChain(const std::shared_ptr<CWallet>& walletInstance, interf
3143
3132
// be pending on the validation-side until lock release. Blocks that are connected while the
3144
3133
// rescan is ongoing will not be processed in the rescan but with the block connected notifications,
3145
3134
// 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
3151
3135
walletInstance->m_chain_notifications_handler = walletInstance->chain ().handleNotifications (walletInstance);
3152
3136
3153
3137
// If rescan_required = true, rescan_height remains equal to 0
@@ -3233,14 +3217,12 @@ bool CWallet::AttachChain(const std::shared_ptr<CWallet>& walletInstance, interf
3233
3217
error = _ (" Failed to rescan the wallet during initialization" );
3234
3218
return false ;
3235
3219
}
3236
- walletInstance->m_attaching_chain = false ;
3237
3220
// Set and update the best block record
3238
3221
// Set last block scanned as the last block processed as it may be different in case the case of a reorg.
3239
3222
// Also save the best block locator because rescanning only updates it intermittently.
3240
3223
walletInstance->SetLastBlockProcessed (*scan_res.last_scanned_height , scan_res.last_scanned_block );
3241
3224
}
3242
3225
}
3243
- walletInstance->m_attaching_chain = false ;
3244
3226
3245
3227
return true ;
3246
3228
}
@@ -4229,11 +4211,6 @@ util::Result<MigrationResult> MigrateLegacyToDescriptor(const std::string& walle
4229
4211
return util::Error{_ (" Error: This wallet is already a descriptor wallet" )};
4230
4212
}
4231
4213
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
-
4237
4214
if (!RemoveWallet (context, wallet, /* load_on_start=*/ std::nullopt, warnings)) {
4238
4215
return util::Error{_ (" Unable to unload the wallet before migrating" )};
4239
4216
}
0 commit comments