Skip to content

Commit 4cfb7b9

Browse files
committed
[net processing] Use ignore_incoming_txs from m_opts
1 parent 8b87725 commit 4cfb7b9

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/net_processing.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ class PeerManagerImpl final : public PeerManager
515515
std::optional<std::string> FetchBlock(NodeId peer_id, const CBlockIndex& block_index) override
516516
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
517517
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) const override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
518-
bool IgnoresIncomingTxs() override { return m_ignore_incoming_txs; }
518+
bool IgnoresIncomingTxs() override { return m_opts.ignore_incoming_txs; }
519519
void SendPings() override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
520520
void RelayTransaction(const uint256& txid, const uint256& wtxid) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
521521
void SetBestHeight(int height) override { m_best_height = height; };
@@ -718,9 +718,6 @@ class PeerManagerImpl final : public PeerManager
718718
/** Next time to check for stale tip */
719719
std::chrono::seconds m_stale_tip_check_time GUARDED_BY(cs_main){0s};
720720

721-
/** Whether this node is running in -blocksonly mode */
722-
const bool m_ignore_incoming_txs;
723-
724721
const Options m_opts;
725722

726723
bool RejectIncomingTxs(const CNode& peer) const;
@@ -1214,7 +1211,7 @@ void PeerManagerImpl::MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid)
12141211
// When in -blocksonly mode, never request high-bandwidth mode from peers. Our
12151212
// mempool will not contain the transactions necessary to reconstruct the
12161213
// compact block.
1217-
if (m_ignore_incoming_txs) return;
1214+
if (m_opts.ignore_incoming_txs) return;
12181215

12191216
CNodeState* nodestate = State(nodeid);
12201217
if (!nodestate || !nodestate->m_provides_cmpctblocks) {
@@ -1825,7 +1822,6 @@ PeerManagerImpl::PeerManagerImpl(CConnman& connman, AddrMan& addrman,
18251822
m_banman(banman),
18261823
m_chainman(chainman),
18271824
m_mempool(pool),
1828-
m_ignore_incoming_txs(opts.ignore_incoming_txs),
18291825
m_opts{opts}
18301826
{
18311827
// While Erlay support is incomplete, it must be enabled explicitly via -txreconciliation.
@@ -2732,7 +2728,7 @@ void PeerManagerImpl::HeadersDirectFetchBlocks(CNode& pfrom, const Peer& peer, c
27322728
last_header.nHeight);
27332729
}
27342730
if (vGetData.size() > 0) {
2735-
if (!m_ignore_incoming_txs &&
2731+
if (!m_opts.ignore_incoming_txs &&
27362732
nodestate->m_provides_cmpctblocks &&
27372733
vGetData.size() == 1 &&
27382734
mapBlocksInFlight.size() == 1 &&
@@ -3437,7 +3433,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
34373433
// - we are not in -blocksonly mode.
34383434
const auto* tx_relay = peer->GetTxRelay();
34393435
if (tx_relay && WITH_LOCK(tx_relay->m_bloom_filter_mutex, return tx_relay->m_relay_txs) &&
3440-
!pfrom.IsAddrFetchConn() && !m_ignore_incoming_txs) {
3436+
!pfrom.IsAddrFetchConn() && !m_opts.ignore_incoming_txs) {
34413437
const uint64_t recon_salt = m_txreconciliation->PreRegisterPeer(pfrom.GetId());
34423438
m_connman.PushMessage(&pfrom, msg_maker.Make(NetMsgType::SENDTXRCNCL,
34433439
TXRECONCILIATION_VERSION, recon_salt));
@@ -5361,7 +5357,7 @@ void PeerManagerImpl::MaybeSendSendHeaders(CNode& node, Peer& peer)
53615357

53625358
void PeerManagerImpl::MaybeSendFeefilter(CNode& pto, Peer& peer, std::chrono::microseconds current_time)
53635359
{
5364-
if (m_ignore_incoming_txs) return;
5360+
if (m_opts.ignore_incoming_txs) return;
53655361
if (pto.GetCommonVersion() < FEEFILTER_VERSION) return;
53665362
// peers with the forcerelay permission should not filter txs to us
53675363
if (pto.HasPermission(NetPermissionFlags::ForceRelay)) return;
@@ -5429,7 +5425,7 @@ bool PeerManagerImpl::RejectIncomingTxs(const CNode& peer) const
54295425
if (peer.IsBlockOnlyConn()) return true;
54305426
if (peer.IsFeelerConn()) return true;
54315427
// In -blocksonly mode, peers need the 'relay' permission to send txs to us
5432-
if (m_ignore_incoming_txs && !peer.HasPermission(NetPermissionFlags::Relay)) return true;
5428+
if (m_opts.ignore_incoming_txs && !peer.HasPermission(NetPermissionFlags::Relay)) return true;
54335429
return false;
54345430
}
54355431

src/net_processing.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class PeerManager : public CValidationInterface, public NetEventsInterface
4444
{
4545
public:
4646
struct Options {
47+
/** Whether this node is running in -blocksonly mode */
4748
bool ignore_incoming_txs{DEFAULT_BLOCKSONLY};
4849
};
4950

0 commit comments

Comments
 (0)