Skip to content

Commit 87c7067

Browse files
committed
[net processing] PeerManager holds a FastRandomContext
1 parent dcf6230 commit 87c7067

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/net_processing.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,8 @@ class PeerManagerImpl final : public PeerManager
695695
/** Send `feefilter` message. */
696696
void MaybeSendFeefilter(CNode& node, Peer& peer, std::chrono::microseconds current_time) EXCLUSIVE_LOCKS_REQUIRED(g_msgproc_mutex);
697697

698+
FastRandomContext m_rng GUARDED_BY(NetEventsInterface::g_msgproc_mutex);
699+
698700
const CChainParams& m_chainparams;
699701
CConnman& m_connman;
700702
AddrMan& m_addrman;
@@ -1808,7 +1810,8 @@ std::unique_ptr<PeerManager> PeerManager::make(CConnman& connman, AddrMan& addrm
18081810
PeerManagerImpl::PeerManagerImpl(CConnman& connman, AddrMan& addrman,
18091811
BanMan* banman, ChainstateManager& chainman,
18101812
CTxMemPool& pool, Options opts)
1811-
: m_chainparams(chainman.GetParams()),
1813+
: m_rng{opts.deterministic_rng},
1814+
m_chainparams(chainman.GetParams()),
18121815
m_connman(connman),
18131816
m_addrman(addrman),
18141817
m_banman(banman),

src/net_processing.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ class PeerManager : public CValidationInterface, public NetEventsInterface
5858
uint32_t max_extra_txs{DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN};
5959
//! Whether all P2P messages are captured to disk
6060
bool capture_messages{false};
61+
//! Whether or not the internal RNG behaves deterministically (this is
62+
//! a test-only option).
63+
bool deterministic_rng{false};
6164
};
6265

6366
static std::unique_ptr<PeerManager> make(CConnman& connman, AddrMan& addrman,

0 commit comments

Comments
 (0)