diff options
author | Andrew Chow <github@achow101.com> | 2023-05-01 08:09:36 -0400 |
---|---|---|
committer | Andrew Chow <github@achow101.com> | 2023-05-01 08:16:54 -0400 |
commit | 5325a61167a6905dae60f670a0e6c5855e5d658c (patch) | |
tree | d20955acca2baae249b3e40de742f00e507dedee /src/wallet/bdb.h | |
parent | d89aca1bdbe52406f000e3fa8dda12c46dca9bdd (diff) | |
parent | a5986e82dd2b8f923d60f9e31760ef62b9010105 (diff) | |
download | bitcoin-5325a61167a6905dae60f670a0e6c5855e5d658c.tar.xz |
Merge bitcoin/bitcoin#27224: refactor: Remove CAddressBookData::destdata
a5986e82dd2b8f923d60f9e31760ef62b9010105 refactor: Remove CAddressBookData::destdata (Ryan Ofsky)
5938ad0bdb013953861c7cd15a95f00998a06f44 wallet: 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:
ACK a5986e82dd2b8f923d60f9e31760ef62b9010105
furszy:
Code ACK a5986e82
Tree-SHA512: 6bd3e402f1f60263fbd433760bdc29d04175ddaf8307207c4a67d59f6cffa732e176ba57886e02926f7a1615dce0ed9cda36c8cbc6430aa8e5b56934c23f3fe7
Diffstat (limited to 'src/wallet/bdb.h')
-rw-r--r-- | src/wallet/bdb.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/wallet/bdb.h b/src/wallet/bdb.h index ff24081696..4fac128bf1 100644 --- a/src/wallet/bdb.h +++ b/src/wallet/bdb.h @@ -192,10 +192,11 @@ private: Dbc* m_cursor; public: - explicit BerkeleyCursor(BerkeleyDatabase& database); + explicit BerkeleyCursor(BerkeleyDatabase& database, BerkeleyBatch* batch=nullptr); ~BerkeleyCursor() override; Status Next(DataStream& key, DataStream& value) override; + Dbc* dbc() const { return m_cursor; } }; /** RAII class that provides access to a Berkeley database */ @@ -206,6 +207,7 @@ private: bool WriteKey(DataStream&& key, DataStream&& value, bool overwrite = true) override; bool EraseKey(DataStream&& key) override; bool HasKey(DataStream&& key) override; + bool ErasePrefix(Span<const std::byte> prefix) override; protected: Db* pdb{nullptr}; @@ -230,6 +232,7 @@ public: bool TxnBegin() override; bool TxnCommit() override; bool TxnAbort() override; + DbTxn* txn() const { return activeTxn; } }; std::string BerkeleyDatabaseVersion(); |