wallet: introduce 'SetWalletFlagWithDB'

This commit is contained in:
furszy 2023-09-29 16:18:56 -03:00
parent 6052c7891d
commit 122d103ca2
No known key found for this signature in database
GPG Key ID: 5DD23CCC686AA623
2 changed files with 10 additions and 1 deletions

View File

@ -1701,10 +1701,16 @@ bool CWallet::CanGetAddresses(bool internal) const
}
void CWallet::SetWalletFlag(uint64_t flags)
{
WalletBatch batch(GetDatabase());
return SetWalletFlagWithDB(batch, flags);
}
void CWallet::SetWalletFlagWithDB(WalletBatch& batch, uint64_t flags)
{
LOCK(cs_wallet);
m_wallet_flags |= flags;
if (!WalletBatch(GetDatabase()).WriteWalletFlags(m_wallet_flags))
if (!batch.WriteWalletFlags(m_wallet_flags))
throw std::runtime_error(std::string(__func__) + ": writing wallet flags failed");
}

View File

@ -422,6 +422,9 @@ private:
// Same as 'AddActiveScriptPubKeyMan' but designed for use within a batch transaction context
void AddActiveScriptPubKeyManWithDb(WalletBatch& batch, uint256 id, OutputType type, bool internal);
/** Store wallet flags */
void SetWalletFlagWithDB(WalletBatch& batch, uint64_t flags);
//! Cache of descriptor ScriptPubKeys used for IsMine. Maps ScriptPubKey to set of spkms
std::unordered_map<CScript, std::vector<ScriptPubKeyMan*>, SaltedSipHasher> m_cached_spks;