diff options
author | Ben Woosley <ben.woosley@gmail.com> | 2019-04-04 02:33:02 -0700 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2019-05-28 11:03:42 -0400 |
commit | 6cb888b37d7022fbcf5b9c88a8d4f19454f32699 (patch) | |
tree | d3e430b4bb9735eac8a176fb192c1ace9864dfcb /src/wallet | |
parent | 6154a09e01ed7433e590761a5c6957aaf7b5568d (diff) | |
download | bitcoin-6cb888b37d7022fbcf5b9c88a8d4f19454f32699.tar.xz |
Apply the batch treatment to CWallet::SetAddressBook via ImportScriptPubKeys
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/wallet.cpp | 15 | ||||
-rw-r--r-- | src/wallet/wallet.h | 2 |
2 files changed, 12 insertions, 5 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 5a98481c51..2e20c0e0a4 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1693,7 +1693,7 @@ bool CWallet::ImportScriptPubKeys(const std::string& label, const std::set<CScri CTxDestination dest; ExtractDestination(script, dest); if (!internal && IsValidDestination(dest)) { - SetAddressBook(dest, label, "receive"); + SetAddressBookWithDB(batch, dest, label, "receive"); } } return true; @@ -3280,8 +3280,7 @@ DBErrors CWallet::ZapWalletTx(std::vector<CWalletTx>& vWtx) return DBErrors::LOAD_OK; } - -bool CWallet::SetAddressBook(const CTxDestination& address, const std::string& strName, const std::string& strPurpose) +bool CWallet::SetAddressBookWithDB(WalletBatch& batch, const CTxDestination& address, const std::string& strName, const std::string& strPurpose) { bool fUpdated = false; { @@ -3294,9 +3293,15 @@ bool CWallet::SetAddressBook(const CTxDestination& address, const std::string& s } NotifyAddressBookChanged(this, address, strName, ::IsMine(*this, address) != ISMINE_NO, strPurpose, (fUpdated ? CT_UPDATED : CT_NEW) ); - if (!strPurpose.empty() && !WalletBatch(*database).WritePurpose(EncodeDestination(address), strPurpose)) + if (!strPurpose.empty() && !batch.WritePurpose(EncodeDestination(address), strPurpose)) return false; - return WalletBatch(*database).WriteName(EncodeDestination(address), strName); + return batch.WriteName(EncodeDestination(address), strName); +} + +bool CWallet::SetAddressBook(const CTxDestination& address, const std::string& strName, const std::string& strPurpose) +{ + WalletBatch batch(*database); + return SetAddressBookWithDB(batch, address, strName, strPurpose); } bool CWallet::DelAddressBook(const CTxDestination& address) diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index e22beb1381..f627cc59a2 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -715,6 +715,8 @@ private: void AddKeypoolPubkeyWithDB(const CPubKey& pubkey, const bool internal, WalletBatch& batch); + bool SetAddressBookWithDB(WalletBatch& batch, const CTxDestination& address, const std::string& strName, const std::string& strPurpose); + //! Adds a script to the store and saves it to disk bool AddCScriptWithDB(WalletBatch& batch, const CScript& script); |