mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-01 00:34:01 +02:00
Merge bitcoin/bitcoin#27224: refactor: Remove CAddressBookData::destdata
a5986e82ddrefactor: Remove CAddressBookData::destdata (Ryan Ofsky)5938ad0bdbwallet: Add DatabaseBatch::ErasePrefix method (Ryan Ofsky) Pull request description: This is cleanup that doesn't change external behavior. Benefits of the cleanup are: - Removes awkward `StringMap` intermediate representation for wallet address metadata. - Simplifies `CWallet`, deals with used address and received request serialization in `walletdb.cpp` instead of higher level wallet code - Adds test coverage and documentation This PR doesn't change externally observable behavior. Internally, the only change in behavior is that `EraseDestData` deletes rows directly from the database because they are no longer stored in memory. This is more direct and efficient because it uses a single lookup and scan instead of multiple lookups. Motivation for this cleanup is making changes like #18550, #18192, #13756 easier to reason about and less likely to result in unintended behavior and bugs --- This PR is a rebased copy of #18608. For some reason that PR is locked and couldn't be reopened or commented on. This PR is an alternative to #27215 with differences described in https://github.com/bitcoin/bitcoin/pull/27215#pullrequestreview-1329028143 ACKs for top commit: achow101: ACKa5986e82ddfurszy: Code ACKa5986e82Tree-SHA512: 6bd3e402f1f60263fbd433760bdc29d04175ddaf8307207c4a67d59f6cffa732e176ba57886e02926f7a1615dce0ed9cda36c8cbc6430aa8e5b56934c23f3fe7
This commit is contained in:
@@ -228,9 +228,22 @@ public:
|
||||
return m_wallet->GetAddressReceiveRequests();
|
||||
}
|
||||
bool setAddressReceiveRequest(const CTxDestination& dest, const std::string& id, const std::string& value) override {
|
||||
// Note: The setAddressReceiveRequest interface used by the GUI to store
|
||||
// receive requests is a little awkward and could be improved in the
|
||||
// future:
|
||||
//
|
||||
// - The same method is used to save requests and erase them, but
|
||||
// having separate methods could be clearer and prevent bugs.
|
||||
//
|
||||
// - Request ids are passed as strings even though they are generated as
|
||||
// integers.
|
||||
//
|
||||
// - Multiple requests can be stored for the same address, but it might
|
||||
// be better to only allow one request or only keep the current one.
|
||||
LOCK(m_wallet->cs_wallet);
|
||||
WalletBatch batch{m_wallet->GetDatabase()};
|
||||
return m_wallet->SetAddressReceiveRequest(batch, dest, id, value);
|
||||
return value.empty() ? m_wallet->EraseAddressReceiveRequest(batch, dest, id)
|
||||
: m_wallet->SetAddressReceiveRequest(batch, dest, id, value);
|
||||
}
|
||||
bool displayAddress(const CTxDestination& dest) override
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user