Skip to content

Commit 0167938

Browse files
committed
Merge pull request bitcoin#1045 from sipa/fastblocks2
Flush on log size instead of transaction count
2 parents 399ff1f + e88ed65 commit 0167938

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

Diff for: src/db.cpp

+1-10
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ static bool fDbEnvInit = false;
2828
DbEnv dbenv(0);
2929
static map<string, int> mapFileUseCount;
3030
static map<string, Db*> mapDb;
31-
static int64 nTxn = 0;
3231

3332
static void EnvShutdown()
3433
{
@@ -164,13 +163,7 @@ void CDB::Close()
164163
if (strFile == "blkindex.dat" && IsInitialBlockDownload())
165164
nMinutes = 5;
166165

167-
if (nMinutes == 0 || nTxn > 200000)
168-
{
169-
nTxn = 0;
170-
nMinutes = 0;
171-
}
172-
173-
dbenv.txn_checkpoint(0, nMinutes, 0);
166+
dbenv.txn_checkpoint(nMinutes ? GetArg("-dblogsize", 100)*1024 : 0, nMinutes, 0);
174167

175168
CRITICAL_BLOCK(cs_db)
176169
--mapFileUseCount[strFile];
@@ -344,7 +337,6 @@ bool CTxDB::ReadTxIndex(uint256 hash, CTxIndex& txindex)
344337
bool CTxDB::UpdateTxIndex(uint256 hash, const CTxIndex& txindex)
345338
{
346339
assert(!fClient);
347-
nTxn++;
348340
return Write(make_pair(string("tx"), hash), txindex);
349341
}
350342

@@ -355,7 +347,6 @@ bool CTxDB::AddTxIndex(const CTransaction& tx, const CDiskTxPos& pos, int nHeigh
355347
// Add to tx index
356348
uint256 hash = tx.GetHash();
357349
CTxIndex txindex(pos, tx.vout.size());
358-
nTxn++;
359350
return Write(make_pair(string("tx"), hash), txindex);
360351
}
361352

Diff for: src/init.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ bool AppInit2(int argc, char* argv[])
171171
" -splash \t\t " + _("Show splash screen on startup (default: 1)") + "\n" +
172172
" -datadir=<dir> \t\t " + _("Specify data directory") + "\n" +
173173
" -dbcache=<n> \t\t " + _("Set database cache size in megabytes (default: 25)") + "\n" +
174+
" -dblogsize=<n> \t\t " + _("Set database disk log size in megabytes (default: 100)") + "\n" +
174175
" -timeout=<n> \t " + _("Specify connection timeout (in milliseconds)") + "\n" +
175176
" -proxy=<ip:port> \t " + _("Connect through socks4 proxy") + "\n" +
176177
" -dns \t " + _("Allow DNS lookups for addnode and connect") + "\n" +

0 commit comments

Comments
 (0)