Skip to content

Commit 7b7117e

Browse files
committed
net_processing: simplify ProcessGetData and FindTxForGetData args
No need to pass mempool or connman to PeerManagerImpl methods.
1 parent 34207b9 commit 7b7117e

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/net_processing.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,9 @@ class PeerManagerImpl final : public PeerManager
442442
std::atomic<int64_t> m_last_tip_update{0};
443443

444444
/** Determine whether or not a peer can request a transaction, and return it (or nullptr if not found or not allowed). */
445-
CTransactionRef FindTxForGetData(const CTxMemPool& mempool, const CNode& peer, const GenTxid& gtxid, const std::chrono::seconds mempool_req, const std::chrono::seconds now) LOCKS_EXCLUDED(cs_main);
445+
CTransactionRef FindTxForGetData(const CNode& peer, const GenTxid& gtxid, const std::chrono::seconds mempool_req, const std::chrono::seconds now) LOCKS_EXCLUDED(cs_main);
446446

447-
void ProcessGetData(CNode& pfrom, Peer& peer, const CChainParams& chainparams, CConnman& connman, CTxMemPool& mempool, const std::atomic<bool>& interruptMsgProc) EXCLUSIVE_LOCKS_REQUIRED(!cs_main, peer.m_getdata_requests_mutex);
447+
void ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic<bool>& interruptMsgProc) EXCLUSIVE_LOCKS_REQUIRED(!cs_main, peer.m_getdata_requests_mutex);
448448

449449
/** Relay map (txid or wtxid -> CTransactionRef) */
450450
typedef std::map<uint256, CTransactionRef> MapRelay;
@@ -1851,9 +1851,9 @@ void static ProcessGetBlockData(CNode& pfrom, Peer& peer, const CChainParams& ch
18511851
}
18521852
}
18531853

1854-
CTransactionRef PeerManagerImpl::FindTxForGetData(const CTxMemPool& mempool, const CNode& peer, const GenTxid& gtxid, const std::chrono::seconds mempool_req, const std::chrono::seconds now) LOCKS_EXCLUDED(cs_main)
1854+
CTransactionRef PeerManagerImpl::FindTxForGetData(const CNode& peer, const GenTxid& gtxid, const std::chrono::seconds mempool_req, const std::chrono::seconds now) LOCKS_EXCLUDED(cs_main)
18551855
{
1856-
auto txinfo = mempool.info(gtxid);
1856+
auto txinfo = m_mempool.info(gtxid);
18571857
if (txinfo.tx) {
18581858
// If a TX could have been INVed in reply to a MEMPOOL request,
18591859
// or is older than UNCONDITIONAL_RELAY_DELAY, permit the request
@@ -1878,7 +1878,7 @@ CTransactionRef PeerManagerImpl::FindTxForGetData(const CTxMemPool& mempool, con
18781878
return {};
18791879
}
18801880

1881-
void PeerManagerImpl::ProcessGetData(CNode& pfrom, Peer& peer, const CChainParams& chainparams, CConnman& connman, CTxMemPool& mempool, const std::atomic<bool>& interruptMsgProc) EXCLUSIVE_LOCKS_REQUIRED(!cs_main, peer.m_getdata_requests_mutex)
1881+
void PeerManagerImpl::ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic<bool>& interruptMsgProc) EXCLUSIVE_LOCKS_REQUIRED(!cs_main, peer.m_getdata_requests_mutex)
18821882
{
18831883
AssertLockNotHeld(cs_main);
18841884

@@ -1907,17 +1907,17 @@ void PeerManagerImpl::ProcessGetData(CNode& pfrom, Peer& peer, const CChainParam
19071907
continue;
19081908
}
19091909

1910-
CTransactionRef tx = FindTxForGetData(mempool, pfrom, ToGenTxid(inv), mempool_req, now);
1910+
CTransactionRef tx = FindTxForGetData(pfrom, ToGenTxid(inv), mempool_req, now);
19111911
if (tx) {
19121912
// WTX and WITNESS_TX imply we serialize with witness
19131913
int nSendFlags = (inv.IsMsgTx() ? SERIALIZE_TRANSACTION_NO_WITNESS : 0);
1914-
connman.PushMessage(&pfrom, msgMaker.Make(nSendFlags, NetMsgType::TX, *tx));
1915-
mempool.RemoveUnbroadcastTx(tx->GetHash());
1914+
m_connman.PushMessage(&pfrom, msgMaker.Make(nSendFlags, NetMsgType::TX, *tx));
1915+
m_mempool.RemoveUnbroadcastTx(tx->GetHash());
19161916
// As we're going to send tx, make sure its unconfirmed parents are made requestable.
19171917
std::vector<uint256> parent_ids_to_add;
19181918
{
1919-
LOCK(mempool.cs);
1920-
auto txiter = mempool.GetIter(tx->GetHash());
1919+
LOCK(m_mempool.cs);
1920+
auto txiter = m_mempool.GetIter(tx->GetHash());
19211921
if (txiter) {
19221922
const CTxMemPoolEntry::Parents& parents = (*txiter)->GetMemPoolParentsConst();
19231923
parent_ids_to_add.reserve(parents.size());
@@ -1945,7 +1945,7 @@ void PeerManagerImpl::ProcessGetData(CNode& pfrom, Peer& peer, const CChainParam
19451945
if (it != peer.m_getdata_requests.end() && !pfrom.fPauseSend) {
19461946
const CInv &inv = *it++;
19471947
if (inv.IsGenBlkMsg()) {
1948-
ProcessGetBlockData(pfrom, peer, chainparams, inv, connman);
1948+
ProcessGetBlockData(pfrom, peer, m_chainparams, inv, m_connman);
19491949
}
19501950
// else: If the first item on the queue is an unknown type, we erase it
19511951
// and continue processing the queue on the next call.
@@ -1968,7 +1968,7 @@ void PeerManagerImpl::ProcessGetData(CNode& pfrom, Peer& peer, const CChainParam
19681968
// In normal operation, we often send NOTFOUND messages for parents of
19691969
// transactions that we relay; if a peer is missing a parent, they may
19701970
// assume we have them and request the parents from us.
1971-
connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::NOTFOUND, vNotFound));
1971+
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::NOTFOUND, vNotFound));
19721972
}
19731973
}
19741974

@@ -2968,7 +2968,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
29682968
{
29692969
LOCK(peer->m_getdata_requests_mutex);
29702970
peer->m_getdata_requests.insert(peer->m_getdata_requests.end(), vInv.begin(), vInv.end());
2971-
ProcessGetData(pfrom, *peer, m_chainparams, m_connman, m_mempool, interruptMsgProc);
2971+
ProcessGetData(pfrom, *peer, interruptMsgProc);
29722972
}
29732973

29742974
return;
@@ -4043,7 +4043,7 @@ bool PeerManagerImpl::ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt
40434043
{
40444044
LOCK(peer->m_getdata_requests_mutex);
40454045
if (!peer->m_getdata_requests.empty()) {
4046-
ProcessGetData(*pfrom, *peer, m_chainparams, m_connman, m_mempool, interruptMsgProc);
4046+
ProcessGetData(*pfrom, *peer, interruptMsgProc);
40474047
}
40484048
}
40494049

0 commit comments

Comments
 (0)