aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/walletdb.h
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2020-06-15 16:54:58 -0400
committerAndrew Chow <achow101-github@achow101.com>2020-07-09 11:43:54 -0400
commitb82f0ca4d5465b36debb6c57f335bdccf4899c49 (patch)
treee4e0912cc3cc9d43de8308964e31b9ad2b18b928 /src/wallet/walletdb.h
parenteac9200814fa01da6522625be01dded730b26751 (diff)
downloadbitcoin-b82f0ca4d5465b36debb6c57f335bdccf4899c49.tar.xz
walletdb: Add MakeBatch function to BerkeleyDatabase and use it
Instead of having WalletBatch construct the BerkeleyBatch, have BerkeleyDatabase do it and return a std::unique_ptr<BerkeleyBatch>
Diffstat (limited to 'src/wallet/walletdb.h')
-rw-r--r--src/wallet/walletdb.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h
index 61e0f19e56..6b55361c07 100644
--- a/src/wallet/walletdb.h
+++ b/src/wallet/walletdb.h
@@ -183,12 +183,12 @@ private:
template <typename K, typename T>
bool WriteIC(const K& key, const T& value, bool fOverwrite = true)
{
- if (!m_batch.Write(key, value, fOverwrite)) {
+ if (!m_batch->Write(key, value, fOverwrite)) {
return false;
}
m_database.IncrementUpdateCounter();
if (m_database.nUpdateCounter % 1000 == 0) {
- m_batch.Flush();
+ m_batch->Flush();
}
return true;
}
@@ -196,19 +196,19 @@ private:
template <typename K>
bool EraseIC(const K& key)
{
- if (!m_batch.Erase(key)) {
+ if (!m_batch->Erase(key)) {
return false;
}
m_database.IncrementUpdateCounter();
if (m_database.nUpdateCounter % 1000 == 0) {
- m_batch.Flush();
+ m_batch->Flush();
}
return true;
}
public:
explicit WalletBatch(WalletDatabase& database, const char* pszMode = "r+", bool _fFlushOnClose = true) :
- m_batch(database, pszMode, _fFlushOnClose),
+ m_batch(database.MakeBatch(pszMode, _fFlushOnClose)),
m_database(database)
{
}
@@ -280,7 +280,7 @@ public:
//! Abort current transaction
bool TxnAbort();
private:
- BerkeleyBatch m_batch;
+ std::unique_ptr<BerkeleyBatch> m_batch;
WalletDatabase& m_database;
};