diff options
| author | Pieter Wuille <[email protected]> | 2016-06-07 16:29:03 +0200 |
|---|---|---|
| committer | Pieter Wuille <[email protected]> | 2016-06-07 16:29:03 +0200 |
| commit | 888483098e60f2a944f1d246bbfec4d14a2975f8 (patch) | |
| tree | 3c1ebad509c274f0bdedbc9193aef45aefb1e104 /src/net.cpp | |
| parent | Use 64-bit SipHash of netgroups in eviction (diff) | |
| download | discoin-888483098e60f2a944f1d246bbfec4d14a2975f8.tar.xz discoin-888483098e60f2a944f1d246bbfec4d14a2975f8.zip | |
Use C++11 thread-safe static initializers
Diffstat (limited to 'src/net.cpp')
| -rw-r--r-- | src/net.cpp | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/net.cpp b/src/net.cpp index 0bc501601..e29053cf5 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2601,12 +2601,8 @@ int64_t PoissonNextSend(int64_t nNow, int average_interval_seconds) { /* static */ uint64_t CNode::CalculateKeyedNetGroup(const CAddress& ad) { - static uint64_t k0 = 0, k1 = 0; - while (k0 == 0 && k1 == 0) { - // Make sure this only runs on the first invocation. - GetRandBytes((unsigned char*)&k0, sizeof(k0)); - GetRandBytes((unsigned char*)&k1, sizeof(k1)); - } + static const uint64_t k0 = GetRand(std::numeric_limits<uint64_t>::max()); + static const uint64_t k1 = GetRand(std::numeric_limits<uint64_t>::max()); std::vector<unsigned char> vchNetGroup(ad.GetGroup()); |