diff options
author | Patrick Varilly <patvarilly@gmail.com> | 2011-07-14 02:45:34 +0200 |
---|---|---|
committer | Stéphane Gimenez <dev@gim.name> | 2011-07-14 03:29:07 +0200 |
commit | 8c41469140584f3cbdd09fb62a1287da0216f431 (patch) | |
tree | da2b8d9445fb2db927f3f3f0fd19da36378bb0a9 /src/net.cpp | |
parent | 9cd22ab86296ae7039132423c7f9847bdc19a644 (diff) |
Single DB transaction for all addresses in a message
Cuts disk activity at startup immensely
Diffstat (limited to 'src/net.cpp')
-rw-r--r-- | src/net.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/net.cpp b/src/net.cpp index ac5a2834b0..dcfff934b6 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -440,7 +440,7 @@ void ThreadGetMyExternalIP(void* parg) -bool AddAddress(CAddress addr, int64 nTimePenalty) +bool AddAddress(CAddress addr, int64 nTimePenalty, CAddrDB *pAddrDB) { if (!addr.IsRoutable()) return false; @@ -455,7 +455,10 @@ bool AddAddress(CAddress addr, int64 nTimePenalty) // New address printf("AddAddress(%s)\n", addr.ToString().c_str()); mapAddresses.insert(make_pair(addr.GetKey(), addr)); - CAddrDB().WriteAddress(addr); + if (pAddrDB) + pAddrDB->WriteAddress(addr); + else + CAddrDB().WriteAddress(addr); return true; } else @@ -477,7 +480,12 @@ bool AddAddress(CAddress addr, int64 nTimePenalty) fUpdated = true; } if (fUpdated) - CAddrDB().WriteAddress(addrFound); + { + if (pAddrDB) + pAddrDB->WriteAddress(addrFound); + else + CAddrDB().WriteAddress(addrFound); + } } } return false; |