From b40b98cd5c31ddf6073ff12a6ddf108a8264199f Mon Sep 17 00:00:00 2001 From: phelixnmc Date: Mon, 26 Aug 2013 11:46:40 +0200 Subject: [PATCH] Latest version of modified db flushing. --- src/db.cpp | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/db.cpp b/src/db.cpp index b4f0af1f9..a262de641 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -8,7 +8,6 @@ #include "auxpow.h" #include #include -#include // for starts_with(), ends_with() using namespace std; using namespace boost; @@ -143,23 +142,15 @@ void CDB::Close() pdb = NULL; // Flush database activity from memory pool to disk log - unsigned int nMinutes = 0; + // wallet.dat is always flushed, the other files only every couple of minutes + // note Namecoin has more .dat files than Bitcoin + unsigned int nMinutes = 2; if (fReadOnly) nMinutes = 1; - - if (strFile == "addr.dat") - nMinutes = 2; - else if (strFile == "nameindex.dat" || strFile == "nameindexfull.dat") - nMinutes = 2; - else if (strFile == "blkindex.dat") - { - nMinutes = 2; - if (IsInitialBlockDownload() && nBestHeight % 5000 != 0) + if (strFile == "wallet.dat") + nMinutes = 0; + if (strFile == "blkindex.dat" && IsInitialBlockDownload() && nBestHeight % 5000 != 0) nMinutes = 5; - } - else if (boost::algorithm::starts_with(strFile, "blk") && boost::algorithm::ends_with(strFile, ".dat")) - nMinutes = 2; - dbenv.txn_checkpoint(0, nMinutes, 0); CRITICAL_BLOCK(cs_db)