Skip to content

Commit 680eb56

Browse files
committed
[net processing] Don't pass CConnman to RelayTransactions
Use the local m_connman instead
1 parent a38a4e8 commit 680eb56

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

src/net_processing.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ class PeerManagerImpl final : public PeerManager
242242
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) override;
243243
bool IgnoresIncomingTxs() override { return m_ignore_incoming_txs; }
244244
void SendPings() override;
245-
void RelayTransaction(const uint256& txid, const uint256& wtxid, const CConnman& connman) override;
245+
void RelayTransaction(const uint256& txid, const uint256& wtxid) override;
246246
void SetBestHeight(int height) override { m_best_height = height; };
247247
void Misbehaving(const NodeId pnode, const int howmuch, const std::string& message) override;
248248
void ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRecv,
@@ -964,7 +964,7 @@ void PeerManagerImpl::ReattemptInitialBroadcast(CScheduler& scheduler)
964964

965965
if (tx != nullptr) {
966966
LOCK(cs_main);
967-
RelayTransaction(txid, tx->GetWitnessHash(), m_connman);
967+
RelayTransaction(txid, tx->GetWitnessHash());
968968
} else {
969969
m_mempool.RemoveUnbroadcastTx(txid, true);
970970
}
@@ -1465,9 +1465,9 @@ void PeerManagerImpl::SendPings()
14651465
for(auto& it : m_peer_map) it.second->m_ping_queued = true;
14661466
}
14671467

1468-
void PeerManagerImpl::RelayTransaction(const uint256& txid, const uint256& wtxid, const CConnman& connman)
1468+
void PeerManagerImpl::RelayTransaction(const uint256& txid, const uint256& wtxid)
14691469
{
1470-
connman.ForEachNode([&txid, &wtxid](CNode* pnode) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
1470+
m_connman.ForEachNode([&txid, &wtxid](CNode* pnode) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
14711471
AssertLockHeld(::cs_main);
14721472

14731473
CNodeState* state = State(pnode->GetId());
@@ -2047,7 +2047,7 @@ void PeerManagerImpl::ProcessOrphanTx(std::set<uint256>& orphan_work_set)
20472047

20482048
if (result.m_result_type == MempoolAcceptResult::ResultType::VALID) {
20492049
LogPrint(BCLog::MEMPOOL, " accepted orphan tx %s\n", orphanHash.ToString());
2050-
RelayTransaction(orphanHash, porphanTx->GetWitnessHash(), m_connman);
2050+
RelayTransaction(orphanHash, porphanTx->GetWitnessHash());
20512051
m_orphanage.AddChildrenToWorkSet(*porphanTx, orphan_work_set);
20522052
m_orphanage.EraseTx(orphanHash);
20532053
for (const CTransactionRef& removedTx : result.m_replaced_transactions.value()) {
@@ -3051,7 +3051,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
30513051
LogPrintf("Not relaying non-mempool transaction %s from forcerelay peer=%d\n", tx.GetHash().ToString(), pfrom.GetId());
30523052
} else {
30533053
LogPrintf("Force relaying tx %s from peer=%d\n", tx.GetHash().ToString(), pfrom.GetId());
3054-
RelayTransaction(tx.GetHash(), tx.GetWitnessHash(), m_connman);
3054+
RelayTransaction(tx.GetHash(), tx.GetWitnessHash());
30553055
}
30563056
}
30573057
return;
@@ -3066,7 +3066,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
30663066
// requests for it.
30673067
m_txrequest.ForgetTxHash(tx.GetHash());
30683068
m_txrequest.ForgetTxHash(tx.GetWitnessHash());
3069-
RelayTransaction(tx.GetHash(), tx.GetWitnessHash(), m_connman);
3069+
RelayTransaction(tx.GetHash(), tx.GetWitnessHash());
30703070
m_orphanage.AddChildrenToWorkSet(tx, peer->m_orphan_work_set);
30713071

30723072
pfrom.nLastTXTime = GetTime();

src/net_processing.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class PeerManager : public CValidationInterface, public NetEventsInterface
4848
virtual bool IgnoresIncomingTxs() = 0;
4949

5050
/** Relay transaction to all peers. */
51-
virtual void RelayTransaction(const uint256& txid, const uint256& wtxid, const CConnman& connman)
51+
virtual void RelayTransaction(const uint256& txid, const uint256& wtxid)
5252
EXCLUSIVE_LOCKS_REQUIRED(cs_main) = 0;
5353

5454
/** Send ping message to all peers */

src/node/transaction.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ static TransactionError HandleATMPError(const TxValidationState& state, std::str
2929
TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef tx, std::string& err_string, const CAmount& max_tx_fee, bool relay, bool wait_callback)
3030
{
3131
// BroadcastTransaction can be called by either sendrawtransaction RPC or wallet RPCs.
32-
// node.connman is assigned both before chain clients and before RPC server is accepting calls,
33-
// and reset after chain clients and RPC sever are stopped. node.connman should never be null here.
34-
assert(node.connman);
32+
// node.peerman is assigned both before chain clients and before RPC server is accepting calls,
33+
// and reset after chain clients and RPC sever are stopped. node.peerman should never be null here.
3534
assert(node.peerman);
3635
assert(node.mempool);
3736
std::promise<void> promise;
@@ -101,7 +100,7 @@ TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef t
101100
node.mempool->AddUnbroadcastTx(hashTx);
102101

103102
LOCK(cs_main);
104-
node.peerman->RelayTransaction(hashTx, tx->GetWitnessHash(), *node.connman);
103+
node.peerman->RelayTransaction(hashTx, tx->GetWitnessHash());
105104
}
106105

107106
return TransactionError::OK;

0 commit comments

Comments
 (0)