diff options
author | John Newbery <john@johnnewbery.com> | 2021-07-23 10:48:34 +0100 |
---|---|---|
committer | John Newbery <john@johnnewbery.com> | 2021-08-05 17:10:30 +0100 |
commit | fa9710f62c29c7f8d71c9f281001c9b5e70946bf (patch) | |
tree | 25117f2104f8d4a848e3760f3d02f76cef828faa /src/addrman.h | |
parent | ee458d84fc187d69f002ebead6fccc4f4f9c0744 (diff) |
[addrman] Add deterministic argument to CAddrMan ctor
Removes the need for tests to update nKey and insecure_rand after constructing
a CAddrMan.
Diffstat (limited to 'src/addrman.h')
-rw-r--r-- | src/addrman.h | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/addrman.h b/src/addrman.h index 16be374f7b..2503f53a35 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -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 |