diff options
| author | Patrick Varilly <[email protected]> | 2011-07-14 02:45:34 +0200 |
|---|---|---|
| committer | Stéphane Gimenez <[email protected]> | 2011-07-14 03:29:07 +0200 |
| commit | 8c41469140584f3cbdd09fb62a1287da0216f431 (patch) | |
| tree | da2b8d9445fb2db927f3f3f0fd19da36378bb0a9 /src/main.cpp | |
| parent | Merge pull request #406 from muggenhor/warning-fixes (diff) | |
| download | discoin-8c41469140584f3cbdd09fb62a1287da0216f431.tar.xz discoin-8c41469140584f3cbdd09fb62a1287da0216f431.zip | |
Single DB transaction for all addresses in a message
Cuts disk activity at startup immensely
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp index 690219401..e3ad35044 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1899,6 +1899,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) return error("message addr size() = %d", vAddr.size()); // Store the new addresses + CAddrDB addrDB; + addrDB.TxnBegin(); int64 nNow = GetAdjustedTime(); int64 nSince = nNow - 10 * 60; BOOST_FOREACH(CAddress& addr, vAddr) @@ -1910,7 +1912,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) continue; if (addr.nTime <= 100000000 || addr.nTime > nNow + 10 * 60) addr.nTime = nNow - 5 * 24 * 60 * 60; - AddAddress(addr, 2 * 60 * 60); + AddAddress(addr, 2 * 60 * 60, &addrDB); pfrom->AddAddressKnown(addr); if (addr.nTime > nSince && !pfrom->fGetAddr && vAddr.size() <= 10 && addr.IsRoutable()) { @@ -1941,6 +1943,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) } } } + addrDB.TxnCommit(); // Save addresses (it's ok if this fails) if (vAddr.size() < 1000) pfrom->fGetAddr = false; } |