[addrman] Add deterministic argument to CAddrMan ctor

Removes the need for tests to update nKey and insecure_rand after constructing
a CAddrMan.
This commit is contained in:
John Newbery
2021-07-23 10:48:34 +01:00
parent ee458d84fc
commit fa9710f62c
10 changed files with 31 additions and 43 deletions

View File

@@ -493,9 +493,11 @@ public:
mapAddr.clear();
}
CAddrMan()
explicit CAddrMan(bool deterministic)
: insecure_rand{deterministic}
{
Clear();
if (deterministic) nKey.SetNull();
}
~CAddrMan()
@@ -637,13 +639,13 @@ protected:
//! secret key to randomize bucket select with
uint256 nKey;
//! Source of random numbers for randomization in inner loops
mutable FastRandomContext insecure_rand GUARDED_BY(cs);
//! A mutex to protect the inner data structures.
mutable Mutex cs;
private:
//! Source of random numbers for randomization in inner loops
mutable FastRandomContext insecure_rand GUARDED_BY(cs);
//! Serialization versions.
enum Format : uint8_t {
V0_HISTORICAL = 0, //!< historic format, before commit e6b343d88