Skip to content

Commit

Permalink
[net/refactor] Extract m_addr_known logic from initializer list
Browse files Browse the repository at this point in the history
Summary:
Partial backport (6/19) of core [[bitcoin/bitcoin#19316 | PR19316]]:
bitcoin/bitcoin@af59feb

Depends on D8715.

Test Plan:
  ninja all check-all

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Differential Revision: https://reviews.bitcoinabc.org/D8716
  • Loading branch information
amitiuttarwar authored and Fabcien committed Dec 21, 2020
1 parent 503fd17 commit e1e5aca
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2996,16 +2996,14 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn,
// Don't relay addr messages to peers that we connect to as
// block-relay-only peers (to prevent adversaries from inferring these
// links from addr traffic).
m_addr_known{conn_type_in == ConnectionType::BLOCK_RELAY
? nullptr
: std::make_unique<CRollingBloomFilter>(5000, 0.001)},
id(idIn), nLocalHostNonce(nLocalHostNonceIn),
nLocalServices(nLocalServicesIn), nMyStartingHeight(nMyStartingHeightIn) {
hSocket = hSocketIn;
addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn;
hashContinue = BlockHash();
if (conn_type_in != ConnectionType::BLOCK_RELAY) {
m_tx_relay = std::make_unique<TxRelay>();
m_addr_known = std::make_unique<CRollingBloomFilter>(5000, 0.001);
}

for (const std::string &msg : getAllNetMessageTypes()) {
Expand Down
2 changes: 1 addition & 1 deletion src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ class CNode {

// flood relay
std::vector<CAddress> vAddrToSend;
const std::unique_ptr<CRollingBloomFilter> m_addr_known;
std::unique_ptr<CRollingBloomFilter> m_addr_known = nullptr;
bool fGetAddr{false};
std::chrono::microseconds m_next_addr_send GUARDED_BY(cs_sendProcessing){0};
std::chrono::microseconds
Expand Down

0 comments on commit e1e5aca

Please sign in to comment.