diff options
| author | Gavin Andresen <[email protected]> | 2011-10-05 07:22:52 -0700 |
|---|---|---|
| committer | Gavin Andresen <[email protected]> | 2011-10-05 07:22:52 -0700 |
| commit | 9ec4fa7b50e6389cab5792acd4210397c77f9f44 (patch) | |
| tree | be8357af320f1c2d3c413ffdce5c640f01a73914 /src/net.cpp | |
| parent | Send "Connection: close" HTTP header with JSON-RPC requests (client) (diff) | |
| parent | Only GetAdjustedTime once for the retry loop (diff) | |
| download | discoin-9ec4fa7b50e6389cab5792acd4210397c77f9f44.tar.xz discoin-9ec4fa7b50e6389cab5792acd4210397c77f9f44.zip | |
Merge pull request #561 from luke-jr/optimize_conn_adjtime
Only GetAdjustedTime once for the retry loop
Diffstat (limited to 'src/net.cpp')
| -rw-r--r-- | src/net.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/net.cpp b/src/net.cpp index 1792bf78a..b1069132c 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1438,6 +1438,8 @@ void ThreadOpenConnections2(void* parg) BOOST_FOREACH(CNode* pnode, vNodes) setConnected.insert(pnode->addr.ip & 0x0000ffff); + int64 nANow = GetAdjustedTime(); + CRITICAL_BLOCK(cs_mapAddresses) { BOOST_FOREACH(const PAIRTYPE(vector<unsigned char>, CAddress)& item, mapAddresses) @@ -1445,8 +1447,8 @@ void ThreadOpenConnections2(void* parg) const CAddress& addr = item.second; if (!addr.IsIPv4() || !addr.IsValid() || setConnected.count(addr.ip & 0x0000ffff)) continue; - int64 nSinceLastSeen = GetAdjustedTime() - addr.nTime; - int64 nSinceLastTry = GetAdjustedTime() - addr.nLastTry; + int64 nSinceLastSeen = nANow - addr.nTime; + int64 nSinceLastTry = nANow - addr.nLastTry; // Randomize the order in a deterministic way, putting the standard port first int64 nRandomizer = (uint64)(nStart * 4951 + addr.nLastTry * 9567851 + addr.ip * 7789) % (2 * 60 * 60); |