Skip to content

Commit 0517aff

Browse files
committed
refactor: mark RelayInv{,Filtered}'s CInv argument as const
PushInv takes a `const CInv&` and we don't expect to modify the payload
1 parent 9084530 commit 0517aff

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/net_processing.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -627,10 +627,10 @@ class PeerManagerImpl final : public PeerManager
627627
bool IgnoresIncomingTxs() override { return m_ignore_incoming_txs; }
628628
void SendPings() override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);;
629629
void PushInventory(NodeId nodeid, const CInv& inv) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
630-
void RelayInv(CInv &inv) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
631-
void RelayInv(CInv &inv, const int minProtoVersion) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
632-
void RelayInvFiltered(CInv &inv, const CTransaction &relatedTx, const int minProtoVersion) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
633-
void RelayInvFiltered(CInv &inv, const uint256 &relatedTxHash, const int minProtoVersion) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
630+
void RelayInv(const CInv& inv) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
631+
void RelayInv(const CInv& inv, const int minProtoVersion) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
632+
void RelayInvFiltered(const CInv& inv, const CTransaction& relatedTx, const int minProtoVersion) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
633+
void RelayInvFiltered(const CInv& inv, const uint256& relatedTxHash, const int minProtoVersion) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
634634
void RelayTransaction(const uint256& txid) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
635635
void RelayRecoveredSig(const uint256& sigHash) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
636636
void RelayDSQ(const CCoinJoinQueue& queue) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
@@ -2343,7 +2343,7 @@ void PeerManagerImpl::PushInventory(NodeId nodeid, const CInv& inv)
23432343
PushInv(*peer, inv);
23442344
}
23452345

2346-
void PeerManagerImpl::RelayInv(CInv &inv, const int minProtoVersion)
2346+
void PeerManagerImpl::RelayInv(const CInv& inv, const int minProtoVersion)
23472347
{
23482348
// TODO: Migrate to iteration through m_peer_map
23492349
m_connman.ForEachNode([&](CNode* pnode) {
@@ -2356,7 +2356,7 @@ void PeerManagerImpl::RelayInv(CInv &inv, const int minProtoVersion)
23562356
});
23572357
}
23582358

2359-
void PeerManagerImpl::RelayInv(CInv &inv)
2359+
void PeerManagerImpl::RelayInv(const CInv& inv)
23602360
{
23612361
LOCK(m_peer_mutex);
23622362
for (const auto& [_, peer] : m_peer_map) {
@@ -2393,7 +2393,7 @@ void PeerManagerImpl::RelayDSQ(const CCoinJoinQueue& queue)
23932393
}
23942394
}
23952395

2396-
void PeerManagerImpl::RelayInvFiltered(CInv &inv, const CTransaction& relatedTx, const int minProtoVersion)
2396+
void PeerManagerImpl::RelayInvFiltered(const CInv& inv, const CTransaction& relatedTx, const int minProtoVersion)
23972397
{
23982398
// TODO: Migrate to iteration through m_peer_map
23992399
m_connman.ForEachNode([&](CNode* pnode) {
@@ -2418,7 +2418,7 @@ void PeerManagerImpl::RelayInvFiltered(CInv &inv, const CTransaction& relatedTx,
24182418
});
24192419
}
24202420

2421-
void PeerManagerImpl::RelayInvFiltered(CInv &inv, const uint256& relatedTxHash, const int minProtoVersion)
2421+
void PeerManagerImpl::RelayInvFiltered(const CInv& inv, const uint256& relatedTxHash, const int minProtoVersion)
24222422
{
24232423
// TODO: Migrate to iteration through m_peer_map
24242424
m_connman.ForEachNode([&](CNode* pnode) {

src/net_processing.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,16 @@ class PeerManager : public CValidationInterface, public NetEventsInterface
9898
virtual void RelayDSQ(const CCoinJoinQueue& queue) = 0;
9999

100100
/** Relay inventories to all peers */
101-
virtual void RelayInv(CInv &inv) = 0;
102-
virtual void RelayInv(CInv &inv, const int minProtoVersion) = 0;
103-
virtual void RelayInvFiltered(CInv &inv, const CTransaction &relatedTx,
101+
virtual void RelayInv(const CInv& inv) = 0;
102+
virtual void RelayInv(const CInv& inv, const int minProtoVersion) = 0;
103+
virtual void RelayInvFiltered(const CInv& inv, const CTransaction& relatedTx,
104104
const int minProtoVersion = MIN_PEER_PROTO_VERSION) = 0;
105105

106106
/**
107107
* This overload will not update node filters, use it only for the cases
108108
* when other messages will update related transaction data in filters
109109
*/
110-
virtual void RelayInvFiltered(CInv &inv, const uint256 &relatedTxHash,
110+
virtual void RelayInvFiltered(const CInv& inv, const uint256& relatedTxHash,
111111
const int minProtoVersion = MIN_PEER_PROTO_VERSION) = 0;
112112

113113
/** Relay transaction to all peers. */

0 commit comments

Comments
 (0)