mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
random: fixes read buffer resizing in RandAddSeedPerfmon
+ Replaces std::max with std::min to resize buffer in RandAddSeedPerfmon + Documents behavior of RandAddSeedPerfmon
This commit is contained in:
parent
cce1513179
commit
bd5215103e
1 changed files with 3 additions and 2 deletions
|
@ -67,7 +67,8 @@ void RandAddSeedPerfmon(CSHA512& hasher)
|
|||
#ifdef WIN32
|
||||
// Seed with the entire set of perfmon data
|
||||
|
||||
// This can take up to 2 seconds, so only do it every 10 minutes
|
||||
// This can take up to 2 seconds, so only do it every 10 minutes.
|
||||
// Initialize last_perfmon to 0 seconds, we don't skip the first call.
|
||||
static std::atomic<std::chrono::seconds> last_perfmon{std::chrono::seconds{0}};
|
||||
auto last_time = last_perfmon.load();
|
||||
auto current_time = GetTime<std::chrono::seconds>();
|
||||
|
@ -83,7 +84,7 @@ void RandAddSeedPerfmon(CSHA512& hasher)
|
|||
ret = RegQueryValueExA(HKEY_PERFORMANCE_DATA, "Global", nullptr, nullptr, vData.data(), &nSize);
|
||||
if (ret != ERROR_MORE_DATA || vData.size() >= nMaxSize)
|
||||
break;
|
||||
vData.resize(std::max((vData.size() * 3) / 2, nMaxSize)); // Grow size of buffer exponentially
|
||||
vData.resize(std::min((vData.size() * 3) / 2, nMaxSize)); // Grow size of buffer exponentially
|
||||
}
|
||||
RegCloseKey(HKEY_PERFORMANCE_DATA);
|
||||
if (ret == ERROR_SUCCESS) {
|
||||
|
|
Loading…
Add table
Reference in a new issue