Use C++11 thread-safe static initializers

This commit is contained in:
Pieter Wuille
2016-06-07 16:29:03 +02:00
committed by lateminer
parent a1d4facb14
commit 3a1602b31d
4 changed files with 6 additions and 17 deletions

View File

@@ -2589,12 +2589,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());