mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
Single DB transaction for all addresses in a message
Cuts disk activity at startup immensely
This commit is contained in:
committed by
Stéphane Gimenez
parent
9cd22ab862
commit
8c41469140
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user