From d1c02775aa74a0610809ac54bb241ddad61d2d8c Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Tue, 5 Nov 2019 10:54:20 -0800 Subject: [PATCH] Report amount of data gathered from environment --- src/crypto/sha512.h | 1 + src/random.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/crypto/sha512.h b/src/crypto/sha512.h index 4118ac1b18..fc7dd1b87e 100644 --- a/src/crypto/sha512.h +++ b/src/crypto/sha512.h @@ -23,6 +23,7 @@ public: CSHA512& Write(const unsigned char* data, size_t len); void Finalize(unsigned char hash[OUTPUT_SIZE]); CSHA512& Reset(); + uint64_t Size() const { return bytes; } }; #endif // BITCOIN_CRYPTO_SHA512_H diff --git a/src/random.cpp b/src/random.cpp index 2847aacf6f..3e6398f7b4 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -525,7 +525,9 @@ static void SeedPeriodic(CSHA512& hasher, RNGState& rng) SeedTimestamp(hasher); // Dynamic environment data (performance monitoring, ...) + auto old_size = hasher.Size(); RandAddDynamicEnv(hasher); + LogPrintf("Feeding %i bytes of dynamic environment data into RNG\n", hasher.Size() - old_size); // Strengthen for 10 ms SeedStrengthen(hasher, rng, 10000); @@ -540,10 +542,12 @@ static void SeedStartup(CSHA512& hasher, RNGState& rng) noexcept SeedSlow(hasher); // Dynamic environment data (performance monitoring, ...) + auto old_size = hasher.Size(); RandAddDynamicEnv(hasher); // Static environment data RandAddStaticEnv(hasher); + LogPrintf("Feeding %i bytes of environment data into RNG\n", hasher.Size() - old_size); // Strengthen for 100 ms SeedStrengthen(hasher, rng, 100000);