mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-06 14:19:59 -05:00
[net processing] Don't pass CConnman to RelayTransactions
Use the local m_connman instead
This commit is contained in:
parent
a38a4e8f03
commit
680eb56d82
3 changed files with 11 additions and 12 deletions
|
@ -242,7 +242,7 @@ public:
|
||||||
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) override;
|
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) override;
|
||||||
bool IgnoresIncomingTxs() override { return m_ignore_incoming_txs; }
|
bool IgnoresIncomingTxs() override { return m_ignore_incoming_txs; }
|
||||||
void SendPings() override;
|
void SendPings() override;
|
||||||
void RelayTransaction(const uint256& txid, const uint256& wtxid, const CConnman& connman) override;
|
void RelayTransaction(const uint256& txid, const uint256& wtxid) override;
|
||||||
void SetBestHeight(int height) override { m_best_height = height; };
|
void SetBestHeight(int height) override { m_best_height = height; };
|
||||||
void Misbehaving(const NodeId pnode, const int howmuch, const std::string& message) override;
|
void Misbehaving(const NodeId pnode, const int howmuch, const std::string& message) override;
|
||||||
void ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRecv,
|
void ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRecv,
|
||||||
|
@ -964,7 +964,7 @@ void PeerManagerImpl::ReattemptInitialBroadcast(CScheduler& scheduler)
|
||||||
|
|
||||||
if (tx != nullptr) {
|
if (tx != nullptr) {
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
RelayTransaction(txid, tx->GetWitnessHash(), m_connman);
|
RelayTransaction(txid, tx->GetWitnessHash());
|
||||||
} else {
|
} else {
|
||||||
m_mempool.RemoveUnbroadcastTx(txid, true);
|
m_mempool.RemoveUnbroadcastTx(txid, true);
|
||||||
}
|
}
|
||||||
|
@ -1465,9 +1465,9 @@ void PeerManagerImpl::SendPings()
|
||||||
for(auto& it : m_peer_map) it.second->m_ping_queued = true;
|
for(auto& it : m_peer_map) it.second->m_ping_queued = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerManagerImpl::RelayTransaction(const uint256& txid, const uint256& wtxid, const CConnman& connman)
|
void PeerManagerImpl::RelayTransaction(const uint256& txid, const uint256& wtxid)
|
||||||
{
|
{
|
||||||
connman.ForEachNode([&txid, &wtxid](CNode* pnode) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
|
m_connman.ForEachNode([&txid, &wtxid](CNode* pnode) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
|
||||||
AssertLockHeld(::cs_main);
|
AssertLockHeld(::cs_main);
|
||||||
|
|
||||||
CNodeState* state = State(pnode->GetId());
|
CNodeState* state = State(pnode->GetId());
|
||||||
|
@ -2047,7 +2047,7 @@ void PeerManagerImpl::ProcessOrphanTx(std::set<uint256>& orphan_work_set)
|
||||||
|
|
||||||
if (result.m_result_type == MempoolAcceptResult::ResultType::VALID) {
|
if (result.m_result_type == MempoolAcceptResult::ResultType::VALID) {
|
||||||
LogPrint(BCLog::MEMPOOL, " accepted orphan tx %s\n", orphanHash.ToString());
|
LogPrint(BCLog::MEMPOOL, " accepted orphan tx %s\n", orphanHash.ToString());
|
||||||
RelayTransaction(orphanHash, porphanTx->GetWitnessHash(), m_connman);
|
RelayTransaction(orphanHash, porphanTx->GetWitnessHash());
|
||||||
m_orphanage.AddChildrenToWorkSet(*porphanTx, orphan_work_set);
|
m_orphanage.AddChildrenToWorkSet(*porphanTx, orphan_work_set);
|
||||||
m_orphanage.EraseTx(orphanHash);
|
m_orphanage.EraseTx(orphanHash);
|
||||||
for (const CTransactionRef& removedTx : result.m_replaced_transactions.value()) {
|
for (const CTransactionRef& removedTx : result.m_replaced_transactions.value()) {
|
||||||
|
@ -3051,7 +3051,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||||
LogPrintf("Not relaying non-mempool transaction %s from forcerelay peer=%d\n", tx.GetHash().ToString(), pfrom.GetId());
|
LogPrintf("Not relaying non-mempool transaction %s from forcerelay peer=%d\n", tx.GetHash().ToString(), pfrom.GetId());
|
||||||
} else {
|
} else {
|
||||||
LogPrintf("Force relaying tx %s from peer=%d\n", tx.GetHash().ToString(), pfrom.GetId());
|
LogPrintf("Force relaying tx %s from peer=%d\n", tx.GetHash().ToString(), pfrom.GetId());
|
||||||
RelayTransaction(tx.GetHash(), tx.GetWitnessHash(), m_connman);
|
RelayTransaction(tx.GetHash(), tx.GetWitnessHash());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -3066,7 +3066,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||||
// requests for it.
|
// requests for it.
|
||||||
m_txrequest.ForgetTxHash(tx.GetHash());
|
m_txrequest.ForgetTxHash(tx.GetHash());
|
||||||
m_txrequest.ForgetTxHash(tx.GetWitnessHash());
|
m_txrequest.ForgetTxHash(tx.GetWitnessHash());
|
||||||
RelayTransaction(tx.GetHash(), tx.GetWitnessHash(), m_connman);
|
RelayTransaction(tx.GetHash(), tx.GetWitnessHash());
|
||||||
m_orphanage.AddChildrenToWorkSet(tx, peer->m_orphan_work_set);
|
m_orphanage.AddChildrenToWorkSet(tx, peer->m_orphan_work_set);
|
||||||
|
|
||||||
pfrom.nLastTXTime = GetTime();
|
pfrom.nLastTXTime = GetTime();
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
virtual bool IgnoresIncomingTxs() = 0;
|
virtual bool IgnoresIncomingTxs() = 0;
|
||||||
|
|
||||||
/** Relay transaction to all peers. */
|
/** Relay transaction to all peers. */
|
||||||
virtual void RelayTransaction(const uint256& txid, const uint256& wtxid, const CConnman& connman)
|
virtual void RelayTransaction(const uint256& txid, const uint256& wtxid)
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main) = 0;
|
EXCLUSIVE_LOCKS_REQUIRED(cs_main) = 0;
|
||||||
|
|
||||||
/** Send ping message to all peers */
|
/** Send ping message to all peers */
|
||||||
|
|
|
@ -29,9 +29,8 @@ static TransactionError HandleATMPError(const TxValidationState& state, std::str
|
||||||
TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef tx, std::string& err_string, const CAmount& max_tx_fee, bool relay, bool wait_callback)
|
TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef tx, std::string& err_string, const CAmount& max_tx_fee, bool relay, bool wait_callback)
|
||||||
{
|
{
|
||||||
// BroadcastTransaction can be called by either sendrawtransaction RPC or wallet RPCs.
|
// BroadcastTransaction can be called by either sendrawtransaction RPC or wallet RPCs.
|
||||||
// node.connman is assigned both before chain clients and before RPC server is accepting calls,
|
// node.peerman is assigned both before chain clients and before RPC server is accepting calls,
|
||||||
// and reset after chain clients and RPC sever are stopped. node.connman should never be null here.
|
// and reset after chain clients and RPC sever are stopped. node.peerman should never be null here.
|
||||||
assert(node.connman);
|
|
||||||
assert(node.peerman);
|
assert(node.peerman);
|
||||||
assert(node.mempool);
|
assert(node.mempool);
|
||||||
std::promise<void> promise;
|
std::promise<void> promise;
|
||||||
|
@ -101,7 +100,7 @@ TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef t
|
||||||
node.mempool->AddUnbroadcastTx(hashTx);
|
node.mempool->AddUnbroadcastTx(hashTx);
|
||||||
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
node.peerman->RelayTransaction(hashTx, tx->GetWitnessHash(), *node.connman);
|
node.peerman->RelayTransaction(hashTx, tx->GetWitnessHash());
|
||||||
}
|
}
|
||||||
|
|
||||||
return TransactionError::OK;
|
return TransactionError::OK;
|
||||||
|
|
Loading…
Add table
Reference in a new issue