diff options
author | furszy <matiasfurszyfer@protonmail.com> | 2024-02-08 12:34:26 -0300 |
---|---|---|
committer | furszy <matiasfurszyfer@protonmail.com> | 2024-02-12 16:05:14 -0300 |
commit | cf4d72a75e9603e947b3d47e1f3ac7c7f37bb401 (patch) | |
tree | 7ba3c8cd493d1d523d647cf44fabe439ee29b4b8 /src/wallet/wallet.cpp | |
parent | 6ff0aa089c01ff3e610ecb47814ed739d685a14c (diff) | |
download | bitcoin-cf4d72a75e9603e947b3d47e1f3ac7c7f37bb401.tar.xz |
wallet: db, introduce 'RunWithinTxn()' helper function
'RunWithinTxn()' provides a way to execute db operations within a
transactional context. It avoids writing repetitive boilerplate code for
starting and committing the database transaction.
Diffstat (limited to 'src/wallet/wallet.cpp')
-rw-r--r-- | src/wallet/wallet.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 11203ca3a4..db5f54cbb7 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2411,8 +2411,9 @@ bool CWallet::SetAddressBook(const CTxDestination& address, const std::string& s bool CWallet::DelAddressBook(const CTxDestination& address) { - WalletBatch batch(GetDatabase()); - return DelAddressBookWithDB(batch, address); + return RunWithinTxn(GetDatabase(), /*process_desc=*/"address book entry removal", [&](WalletBatch& batch){ + return DelAddressBookWithDB(batch, address); + }); } bool CWallet::DelAddressBookWithDB(WalletBatch& batch, const CTxDestination& address) |