I haven't yet reviewed #19184, so I'll try to do that to get a better sense of what you're referring to.
Could this be addressed by instead testing for both WTX+wtxid and TX+wtxid?
I think that would also work, but if that's how we would do all lookups into g_already_asked_for, I don't know why we'd bother with that complexity?
To be clear, my suggested change is fairly minimal code:
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 6cee368ed72..36c890e395b 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -459,7 +459,7 @@ struct CNodeState {
};
// Keeps track of the time (in microseconds) when transactions were requested last time
-limitedmap<GenTxid, std::chrono::microseconds> g_already_asked_for GUARDED_BY(cs_main)(MAX_INV_SZ);
+limitedmap<uint256, std::chrono::microseconds> g_already_asked_for GUARDED_BY(cs_main)(MAX_INV_SZ);
/** Map maintaining per-node state. */
static std::map<NodeId, CNodeState> mapNodeState GUARDED_BY(cs_main);
@@ -756,12 +756,12 @@ static void FindNextBlocksToDownload(NodeId nodeid, unsigned int count, std::vec
void EraseTxRequest(const GenTxid& gtxid) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
{
- g_already_asked_for.erase(gtxid);
+ g_already_asked_for.erase(gtxid.GetHash());
}
std::chrono::microseconds GetTxRequestTime(const GenTxid& gtxid) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
{
- auto it = g_already_asked_for.find(gtxid);
+ auto it = g_already_asked_for.find(gtxid.GetHash());
if (it != g_already_asked_for.end()) {
return it->second;
}
@@ -770,9 +770,9 @@ std::chrono::microseconds GetTxRequestTime(const GenTxid& gtxid) EXCLUSIVE_LOCKS
void UpdateTxRequestTime(const GenTxid& gtxid, std::chrono::microseconds request_time) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
{
- auto it = g_already_asked_for.find(gtxid);
+ auto it = g_already_asked_for.find(gtxid.GetHash());
if (it == g_already_asked_for.end()) {
- g_already_asked_for.insert(std::make_pair(gtxid, request_time));
+ g_already_asked_for.insert(std::make_pair(gtxid.GetHash(), request_time));
} else {
g_already_asked_for.update(it, request_time);
}
This would capture my understanding of the g_already_asked_for data structure: when scheduling transaction requests, we don't care how a given txid/wtxid was requested (via txid or wtxid), just that a getdata for that hash was sent out at a certain time.