mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 23:09:44 -04:00
wallet: Write best block record on unload
This commit is contained in:
parent
9113e60f55
commit
eceb848494
2 changed files with 16 additions and 0 deletions
|
@ -164,6 +164,7 @@ bool RemoveWallet(WalletContext& context, const std::shared_ptr<CWallet>& wallet
|
|||
|
||||
interfaces::Chain& chain = wallet->chain();
|
||||
std::string name = wallet->GetName();
|
||||
wallet->WriteBestBlock();
|
||||
|
||||
// Unregister with the validation interface which also drops shared pointers.
|
||||
wallet->m_chain_notifications_handler.reset();
|
||||
|
@ -4721,4 +4722,17 @@ std::optional<CKey> CWallet::GetKey(const CKeyID& keyid) const
|
|||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
void CWallet::WriteBestBlock() const
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
|
||||
if (!m_last_block_processed.IsNull()) {
|
||||
CBlockLocator loc;
|
||||
chain().findBlock(m_last_block_processed, FoundBlock().locator(loc));
|
||||
|
||||
WalletBatch batch(GetDatabase());
|
||||
batch.WriteBestBlock(loc);
|
||||
}
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -994,6 +994,8 @@ public:
|
|||
}
|
||||
/** Set last block processed height, and write to database */
|
||||
void SetLastBlockProcessed(int block_height, uint256 block_hash) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||
/** Write the current best block to database */
|
||||
void WriteBestBlock() const;
|
||||
|
||||
//! Connect the signals from ScriptPubKeyMans to the signals in CWallet
|
||||
void ConnectScriptPubKeyManNotifiers();
|
||||
|
|
Loading…
Add table
Reference in a new issue