diff options
author | Samuel Dobson <dobsonsa68@gmail.com> | 2020-09-07 15:44:02 +1200 |
---|---|---|
committer | Samuel Dobson <dobsonsa68@gmail.com> | 2020-09-07 15:56:31 +1200 |
commit | 78cb45d72251e85db07e8500bbdd2e9460b132b2 (patch) | |
tree | f0595dcc0ac791b84bb0af39450a2f854c485cdd | |
parent | 56d47e19edca0c3f9898d904de271251de6d6dc5 (diff) | |
parent | abac4367607d8d2b628e4db6a9663c960bacdacc (diff) |
Merge #19738: wallet: Avoid multiple BerkeleyBatch in DelAddressBook
abac4367607d8d2b628e4db6a9663c960bacdacc wallet: Avoid multiple BerkeleyBatch in DelAddressBook (João Barbosa)
Pull request description:
ACKs for top commit:
achow101:
ACK abac4367607d8d2b628e4db6a9663c960bacdacc
jonatack:
ACK abac4367607d8d2b628e4db6a9663c960bacdacc
meshcollider:
re-utACK abac4367607d8d2b628e4db6a9663c960bacdacc
Tree-SHA512: 92309fb74c48694160807326c0fe9793044a75cd77ed19400cceab54a7eefeb54ffc9334535e6021b3af7b9a364dbbeda3a9173540fff8144dfd437e96d76b5c
-rw-r--r-- | src/wallet/wallet.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 0d07904924..e2a2503035 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2350,6 +2350,7 @@ std::map<CTxDestination, std::vector<COutput>> CWallet::ListCoins() const const CTxOut& CWallet::FindNonChangeParentOutput(const CTransaction& tx, int output) const { + AssertLockHeld(cs_wallet); const CTransaction* ptx = &tx; int n = output; while (IsChange(ptx->vout[n]) && ptx->vin.size() > 0) { @@ -3268,6 +3269,7 @@ bool CWallet::SetAddressBook(const CTxDestination& address, const std::string& s bool CWallet::DelAddressBook(const CTxDestination& address) { bool is_mine; + WalletBatch batch(*database); { LOCK(cs_wallet); // If we want to delete receiving addresses, we need to take care that DestData "used" (and possibly newer DestData) gets preserved (and the "deleted" address transformed into a change entry instead of actually being deleted) @@ -3281,7 +3283,7 @@ bool CWallet::DelAddressBook(const CTxDestination& address) std::string strAddress = EncodeDestination(address); for (const std::pair<const std::string, std::string> &item : m_address_book[address].destdata) { - WalletBatch(*database).EraseDestData(strAddress, item.first); + batch.EraseDestData(strAddress, item.first); } m_address_book.erase(address); is_mine = IsMine(address) != ISMINE_NO; @@ -3289,8 +3291,8 @@ bool CWallet::DelAddressBook(const CTxDestination& address) NotifyAddressBookChanged(this, address, "", is_mine, "", CT_DELETED); - WalletBatch(*database).ErasePurpose(EncodeDestination(address)); - return WalletBatch(*database).EraseName(EncodeDestination(address)); + batch.ErasePurpose(EncodeDestination(address)); + return batch.EraseName(EncodeDestination(address)); } size_t CWallet::KeypoolCountExternalKeys() const |