diff options
author | Andrew Chow <achow101-github@achow101.com> | 2019-04-05 15:11:47 -0400 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2019-05-18 12:58:50 -0400 |
commit | d6576e349e8a18289b0b1caa409c4de509250c3b (patch) | |
tree | 73b6a8b18c5b26146625921cd7c6d42466fe750e /src/wallet/walletdb.h | |
parent | 366fe0be0b9b9691b7d26f9b592e586112ef645b (diff) |
Have WalletBatch automatically flush every 1000 updates
Since it now automatically flushes, we don't need to have
UpgradeKeyMetadata count and flush separately
Diffstat (limited to 'src/wallet/walletdb.h')
-rw-r--r-- | src/wallet/walletdb.h | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h index 0532a55ff5..d4a3bba97a 100644 --- a/src/wallet/walletdb.h +++ b/src/wallet/walletdb.h @@ -143,9 +143,11 @@ public: }; /** Access to the wallet database. - * This represents a single transaction at the - * database. It will be committed when the object goes out of scope. - * Optionally (on by default) it will flush to disk as well. + * Opens the database and provides read and write access to it. Each read and write is its own transaction. + * Multiple operation transactions can be started using TxnBegin() and committed using TxnCommit() + * Otherwise the transaction will be committed when the object goes out of scope. + * Optionally (on by default) it will flush to disk on close. + * Every 1000 writes will automatically trigger a flush to disk. */ class WalletBatch { @@ -157,6 +159,9 @@ private: return false; } m_database.IncrementUpdateCounter(); + if (m_database.nUpdateCounter % 1000 == 0) { + m_batch.Flush(); + } return true; } @@ -167,6 +172,9 @@ private: return false; } m_database.IncrementUpdateCounter(); + if (m_database.nUpdateCounter % 1000 == 0) { + m_batch.Flush(); + } return true; } |