Skip to content

Commit

Permalink
Latest version of modified db flushing.
Browse files Browse the repository at this point in the history
  • Loading branch information
phelixnmc committed Aug 26, 2013
1 parent bfd788d commit b40b98c
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions src/db.cpp
Expand Up @@ -8,7 +8,6 @@
#include "auxpow.h"
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/algorithm/string/predicate.hpp> // for starts_with(), ends_with()

using namespace std;
using namespace boost;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b40b98c

Please sign in to comment.