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

Method Initializer

src/test/fuzz/txrequest.cpp:30–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28struct Initializer
29{
30 Initializer()
31 {
32 for (uint8_t txhash = 0; txhash < MAX_TXHASHES; txhash += 1) {
33 CSHA256().Write(&txhash, 1).Finalize(TXHASHES[txhash].begin());
34 }
35 int i = 0;
36 // DELAYS[N] for N=0..15 is just N microseconds.
37 for (; i < 16; ++i) {
38 DELAYS[i] = std::chrono::microseconds{i};
39 }
40 // DELAYS[N] for N=16..127 has randomly-looking but roughly exponentially increasing values up to
41 // 198.416453 seconds.
42 for (; i < 128; ++i) {
43 int diff_bits = ((i - 10) * 2) / 9;
44 uint64_t diff = 1 + (CSipHasher(0, 0).Write(i).Finalize() >> (64 - diff_bits));
45 DELAYS[i] = DELAYS[i - 1] + std::chrono::microseconds{diff};
46 }
47 // DELAYS[N] for N=128..255 are negative delays with the same magnitude as N=0..127.
48 for (; i < 256; ++i) {
49 DELAYS[i] = -DELAYS[255 - i];
50 }
51 }
52} g_initializer;
53
54/** Tester class for TxRequestTracker

Callers

nothing calls this directly

Calls 5

CSHA256Class · 0.85
CSipHasherClass · 0.85
FinalizeMethod · 0.45
WriteMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected