aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/db.cpp
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2019-04-05 15:11:47 -0400
committerAndrew Chow <achow101-github@achow101.com>2019-05-18 12:58:50 -0400
commitd6576e349e8a18289b0b1caa409c4de509250c3b (patch)
tree73b6a8b18c5b26146625921cd7c6d42466fe750e /src/wallet/db.cpp
parent366fe0be0b9b9691b7d26f9b592e586112ef645b (diff)
downloadbitcoin-d6576e349e8a18289b0b1caa409c4de509250c3b.tar.xz
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/db.cpp')
-rw-r--r--src/wallet/db.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp
index 6a326bfd97..13fe5a2918 100644
--- a/src/wallet/db.cpp
+++ b/src/wallet/db.cpp
@@ -614,7 +614,9 @@ void BerkeleyBatch::Flush()
if (fReadOnly)
nMinutes = 1;
- env->dbenv->txn_checkpoint(nMinutes ? gArgs.GetArg("-dblogsize", DEFAULT_WALLET_DBLOGSIZE) * 1024 : 0, nMinutes, 0);
+ if (env) { // env is nullptr for dummy databases (i.e. in tests). Don't actually flush if env is nullptr so we don't segfault
+ env->dbenv->txn_checkpoint(nMinutes ? gArgs.GetArg("-dblogsize", DEFAULT_WALLET_DBLOGSIZE) * 1024 : 0, nMinutes, 0);
+ }
}
void BerkeleyDatabase::IncrementUpdateCounter()