[refactor] move notfound processing to txdownload
This commit is contained in:
1 parent
042a97ce7f
commit
3a41926d1b
4 files changed
+23
-4
No files matched your search
@@ -5133,16 +5133,16 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
|||||||
if (msg_type == NetMsgType::NOTFOUND) {
|
if (msg_type == NetMsgType::NOTFOUND) {
|
||||||
std::vector<CInv> vInv;
|
std::vector<CInv> vInv;
|
||||||
vRecv >> vInv;
|
vRecv >> vInv;
|
||||||
|
std::vector<uint256> tx_invs;
|
||||||
if (vInv.size() <= node::MAX_PEER_TX_ANNOUNCEMENTS + MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
|
if (vInv.size() <= node::MAX_PEER_TX_ANNOUNCEMENTS + MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
|
||||||
LOCK(m_tx_download_mutex);
|
|
||||||
for (CInv &inv : vInv) {
|
for (CInv &inv : vInv) {
|
||||||
if (inv.IsGenTxMsg()) {
|
if (inv.IsGenTxMsg()) {
|
||||||
// If we receive a NOTFOUND message for a tx we requested, mark the announcement for it as
|
tx_invs.emplace_back(inv.hash);
|
||||||
// completed in TxRequestTracker.
|
|
||||||
m_txdownloadman.GetTxRequestRef().ReceivedResponse(pfrom.GetId(), inv.hash);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LOCK(m_tx_download_mutex);
|
||||||
|
m_txdownloadman.ReceivedNotFound(pfrom.GetId(), tx_invs);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -108,6 +108,9 @@ public:
|
|||||||
|
|
||||||
/** Get getdata requests to send. */
|
/** Get getdata requests to send. */
|
||||||
std::vector<GenTxid> GetRequestsToSend(NodeId nodeid, std::chrono::microseconds current_time);
|
std::vector<GenTxid> GetRequestsToSend(NodeId nodeid, std::chrono::microseconds current_time);
|
||||||
|
|
||||||
|
/** Should be called when a notfound for a tx has been received. */
|
||||||
|
void ReceivedNotFound(NodeId nodeid, const std::vector<uint256>& txhashes);
|
||||||
};
|
};
|
||||||
} // namespace node
|
} // namespace node
|
||||||
#endif // BITCOIN_NODE_TXDOWNLOADMAN_H
|
#endif // BITCOIN_NODE_TXDOWNLOADMAN_H
|
||||||
@@ -67,6 +67,10 @@ std::vector<GenTxid> TxDownloadManager::GetRequestsToSend(NodeId nodeid, std::ch
|
|||||||
{
|
{
|
||||||
return m_impl->GetRequestsToSend(nodeid, current_time);
|
return m_impl->GetRequestsToSend(nodeid, current_time);
|
||||||
}
|
}
|
||||||
|
void TxDownloadManager::ReceivedNotFound(NodeId nodeid, const std::vector<uint256>& txhashes)
|
||||||
|
{
|
||||||
|
m_impl->ReceivedNotFound(nodeid, txhashes);
|
||||||
|
}
|
||||||
|
|
||||||
// TxDownloadManagerImpl
|
// TxDownloadManagerImpl
|
||||||
void TxDownloadManagerImpl::ActiveTipChange()
|
void TxDownloadManagerImpl::ActiveTipChange()
|
||||||
@@ -205,4 +209,13 @@ std::vector<GenTxid> TxDownloadManagerImpl::GetRequestsToSend(NodeId nodeid, std
|
|||||||
}
|
}
|
||||||
return requests;
|
return requests;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TxDownloadManagerImpl::ReceivedNotFound(NodeId nodeid, const std::vector<uint256>& txhashes)
|
||||||
|
{
|
||||||
|
for (const auto& txhash : txhashes) {
|
||||||
|
// If we receive a NOTFOUND message for a tx we requested, mark the announcement for it as
|
||||||
|
// completed in TxRequestTracker.
|
||||||
|
m_txrequest.ReceivedResponse(nodeid, txhash);
|
||||||
|
}
|
||||||
|
}
|
||||||
} // namespace node
|
} // namespace node
|
||||||
@@ -156,6 +156,9 @@ public:
|
|||||||
|
|
||||||
/** Get getdata requests to send. */
|
/** Get getdata requests to send. */
|
||||||
std::vector<GenTxid> GetRequestsToSend(NodeId nodeid, std::chrono::microseconds current_time);
|
std::vector<GenTxid> GetRequestsToSend(NodeId nodeid, std::chrono::microseconds current_time);
|
||||||
|
|
||||||
|
/** Marks a tx as ReceivedResponse in txrequest. */
|
||||||
|
void ReceivedNotFound(NodeId nodeid, const std::vector<uint256>& txhashes);
|
||||||
};
|
};
|
||||||
} // namespace node
|
} // namespace node
|
||||||
#endif // BITCOIN_NODE_TXDOWNLOADMAN_IMPL_H
|
#endif // BITCOIN_NODE_TXDOWNLOADMAN_IMPL_H
|
||||||
Reference in new issue
Block a user