aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2016-06-07 16:29:03 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2016-06-07 16:29:03 +0200
commit888483098e60f2a944f1d246bbfec4d14a2975f8 (patch)
tree3c1ebad509c274f0bdedbc9193aef45aefb1e104 /src/main.cpp
parentc31b24f745a84669f2af729052da7fd7ed2da868 (diff)
downloadbitcoin-888483098e60f2a944f1d246bbfec4d14a2975f8.tar.xz
Use C++11 thread-safe static initializers
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 bf6e6d04b5..da140cffac 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -4784,11 +4784,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));