diff --git a/src/net.h b/src/net.h --- a/src/net.h +++ b/src/net.h @@ -641,7 +641,7 @@ }; // m_tx_relay == nullptr if we're not relaying transactions with this peer - std::unique_ptr m_tx_relay; + const std::unique_ptr m_tx_relay; struct ProofRelay { mutable RecursiveMutex cs_proof_inventory; @@ -654,7 +654,7 @@ }; // m_proof_relay == nullptr if we're not relaying proofs with this peer - std::unique_ptr m_proof_relay; + const std::unique_ptr m_proof_relay; class AvalancheState { /** diff --git a/src/net.cpp b/src/net.cpp --- a/src/net.cpp +++ b/src/net.cpp @@ -3603,6 +3603,11 @@ : m_connected(GetTime()), addr(addrIn), addrBind(addrBindIn), m_inbound_onion(inbound_onion), nKeyedNetGroup(nKeyedNetGroupIn), + m_tx_relay(conn_type_in != ConnectionType::BLOCK_RELAY + ? std::make_unique() + : nullptr), + m_proof_relay(isAvalancheEnabled(gArgs) ? std::make_unique() + : nullptr), // 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). @@ -3614,14 +3619,6 @@ } hSocket = hSocketIn; addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn; - if (conn_type_in != ConnectionType::BLOCK_RELAY) { - m_tx_relay = std::make_unique(); - } - - // Don't relay proofs if avalanche is disabled - if (isAvalancheEnabled(gArgs)) { - m_proof_relay = std::make_unique(); - } for (const std::string &msg : getAllNetMessageTypes()) { mapRecvBytesPerMsgCmd[msg] = 0;