aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorPatrick Varilly <patvarilly@gmail.com>2011-07-14 02:45:34 +0200
committerStéphane Gimenez <dev@gim.name>2011-07-14 03:29:07 +0200
commit8c41469140584f3cbdd09fb62a1287da0216f431 (patch)
treeda2b8d9445fb2db927f3f3f0fd19da36378bb0a9 /src/main.cpp
parent9cd22ab86296ae7039132423c7f9847bdc19a644 (diff)
downloadbitcoin-8c41469140584f3cbdd09fb62a1287da0216f431.tar.xz
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.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 6902194016..e3ad35044e 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;
}