aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2016-06-08 18:05:01 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2016-06-08 18:32:34 +0200
commit4286f43025149cf44207c3ad98e4a1f068520ada (patch)
treec2f41222409f2ab55c167a62ffd9ce325dde31b5 /src/main.cpp
parentcd0c5135ab2291aaa5410ac919bad3fc87249a4a (diff)
parenteebc23218758d89bce0b7cb0eced9fd654cd3d15 (diff)
downloadbitcoin-4286f43025149cf44207c3ad98e4a1f068520ada.tar.xz
Merge #8173: Use SipHash for node eviction (cont'd)
eebc232 test: Add more test vectors for siphash (Wladimir J. van der Laan) 8884830 Use C++11 thread-safe static initializers (Pieter Wuille) c31b24f Use 64-bit SipHash of netgroups in eviction (Pieter Wuille) 9bf156b Support SipHash with arbitrary byte writes (Pieter Wuille) 053930f Avoid recalculating vchKeyedNetGroup in eviction logic. (Patrick Strateman)
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 84edaebb82..72d9a3d441 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -4783,11 +4783,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
LOCK(cs_vNodes);
// Use deterministic randomness to send to the same nodes for 24 hours
// at a time so the addrKnowns of the chosen nodes prevent repeats
- static uint64_t salt0 = 0, salt1 = 0;
- while (salt0 == 0 && salt1 == 0) {
- GetRandBytes((unsigned char*)&salt0, sizeof(salt0));
- GetRandBytes((unsigned char*)&salt1, sizeof(salt1));
- }
+ static const uint64_t salt0 = GetRand(std::numeric_limits<uint64_t>::max());
+ static const uint64_t salt1 = GetRand(std::numeric_limits<uint64_t>::max());
uint64_t hashAddr = addr.GetHash();
multimap<uint64_t, CNode*> mapMix;
const CSipHasher hasher = CSipHasher(salt0, salt1).Write(hashAddr << 32).Write((GetTime() + hashAddr) / (24*60*60));