MCPcopy Create free account
hub / github.com/ElementsProject/elements / RandAddDynamicEnv

Function RandAddDynamicEnv

src/randomenv.cpp:226–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224} // namespace
225
226void RandAddDynamicEnv(CSHA512& hasher)
227{
228 RandAddSeedPerfmon(hasher);
229
230 // Various clocks
231#ifdef WIN32
232 FILETIME ftime;
233 GetSystemTimeAsFileTime(&ftime);
234 hasher << ftime;
235#else
236 struct timespec ts = {};
237# ifdef CLOCK_MONOTONIC
238 clock_gettime(CLOCK_MONOTONIC, &ts);
239 hasher << ts;
240# endif
241# ifdef CLOCK_REALTIME
242 clock_gettime(CLOCK_REALTIME, &ts);
243 hasher << ts;
244# endif
245# ifdef CLOCK_BOOTTIME
246 clock_gettime(CLOCK_BOOTTIME, &ts);
247 hasher << ts;
248# endif
249 // gettimeofday is available on all UNIX systems, but only has microsecond precision.
250 struct timeval tv = {};
251 gettimeofday(&tv, nullptr);
252 hasher << tv;
253#endif
254 // Probably redundant, but also use all the clocks C++11 provides:
255 hasher << std::chrono::system_clock::now().time_since_epoch().count();
256 hasher << std::chrono::steady_clock::now().time_since_epoch().count();
257 hasher << std::chrono::high_resolution_clock::now().time_since_epoch().count();
258
259#ifndef WIN32
260 // Current resource usage.
261 struct rusage usage = {};
262 if (getrusage(RUSAGE_SELF, &usage) == 0) hasher << usage;
263#endif
264
265#ifdef __linux__
266 AddFile(hasher, "/proc/diskstats");
267 AddFile(hasher, "/proc/vmstat");
268 AddFile(hasher, "/proc/schedstat");
269 AddFile(hasher, "/proc/zoneinfo");
270 AddFile(hasher, "/proc/meminfo");
271 AddFile(hasher, "/proc/softirqs");
272 AddFile(hasher, "/proc/stat");
273 AddFile(hasher, "/proc/self/schedstat");
274 AddFile(hasher, "/proc/self/status");
275#endif
276
277#if HAVE_SYSCTL
278# ifdef CTL_KERN
279# if defined(KERN_PROC) && defined(KERN_PROC_ALL)
280 AddSysctl<CTL_KERN, KERN_PROC, KERN_PROC_ALL>(hasher);
281# endif
282# endif
283# ifdef CTL_HW

Callers 2

SeedPeriodicFunction · 0.85
SeedStartupFunction · 0.85

Calls 3

RandAddSeedPerfmonFunction · 0.85
AddFileFunction · 0.85
countMethod · 0.80

Tested by

no test coverage detected