Skip to content

Commit d1c0277

Browse files
committed
Report amount of data gathered from environment
1 parent 64e1e02 commit d1c0277

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/crypto/sha512.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class CSHA512
2323
CSHA512& Write(const unsigned char* data, size_t len);
2424
void Finalize(unsigned char hash[OUTPUT_SIZE]);
2525
CSHA512& Reset();
26+
uint64_t Size() const { return bytes; }
2627
};
2728

2829
#endif // BITCOIN_CRYPTO_SHA512_H

src/random.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,9 @@ static void SeedPeriodic(CSHA512& hasher, RNGState& rng)
525525
SeedTimestamp(hasher);
526526

527527
// Dynamic environment data (performance monitoring, ...)
528+
auto old_size = hasher.Size();
528529
RandAddDynamicEnv(hasher);
530+
LogPrintf("Feeding %i bytes of dynamic environment data into RNG\n", hasher.Size() - old_size);
529531

530532
// Strengthen for 10 ms
531533
SeedStrengthen(hasher, rng, 10000);
@@ -540,10 +542,12 @@ static void SeedStartup(CSHA512& hasher, RNGState& rng) noexcept
540542
SeedSlow(hasher);
541543

542544
// Dynamic environment data (performance monitoring, ...)
545+
auto old_size = hasher.Size();
543546
RandAddDynamicEnv(hasher);
544547

545548
// Static environment data
546549
RandAddStaticEnv(hasher);
550+
LogPrintf("Feeding %i bytes of environment data into RNG\n", hasher.Size() - old_size);
547551

548552
// Strengthen for 100 ms
549553
SeedStrengthen(hasher, rng, 100000);

0 commit comments

Comments
 (0)