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
This commit is contained in:
Samuel Dobson 2020-09-07 15:44:02 +12:00 committed by pasta
parent 7fbcba4503
commit 5492191904
No known key found for this signature in database
GPG Key ID: 52527BEDABE87984

View File

@ -2713,6 +2713,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) {
@ -3984,6 +3985,7 @@ bool CWallet::DelAddressBook(const CTxDestination& address)
return false;
}
WalletBatch batch(GetDatabase());
{
LOCK(cs_wallet);
@ -3991,15 +3993,15 @@ 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(GetDatabase()).EraseDestData(strAddress, item.first);
batch.EraseDestData(strAddress, item.first);
}
m_address_book.erase(address);
}
NotifyAddressBookChanged(this, address, "", IsMine(address) != ISMINE_NO, "", CT_DELETED);
WalletBatch(GetDatabase()).ErasePurpose(EncodeDestination(address));
return WalletBatch(GetDatabase()).EraseName(EncodeDestination(address));
batch.ErasePurpose(EncodeDestination(address));
return batch.EraseName(EncodeDestination(address));
}
size_t CWallet::KeypoolCountExternalKeys() const