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:
0diff --git a/src/net_processing.cpp b/src/net_processing.cpp
1index 6cee368ed72..36c890e395b 100644
2--- a/src/net_processing.cpp
3+++ b/src/net_processing.cpp
4@@ -459,7 +459,7 @@ struct CNodeState {
5 };
6
7 // Keeps track of the time (in microseconds) when transactions were requested last time
8-limitedmap<GenTxid, std::chrono::microseconds> g_already_asked_for GUARDED_BY(cs_main)(MAX_INV_SZ);
9+limitedmap<uint256, std::chrono::microseconds> g_already_asked_for GUARDED_BY(cs_main)(MAX_INV_SZ);
10
11 /** Map maintaining per-node state. */
12 static std::map<NodeId, CNodeState> mapNodeState GUARDED_BY(cs_main);
13@@ -756,12 +756,12 @@ static void FindNextBlocksToDownload(NodeId nodeid, unsigned int count, std::vec
14
15 void EraseTxRequest(const GenTxid& gtxid) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
16 {
17- g_already_asked_for.erase(gtxid);
18+ g_already_asked_for.erase(gtxid.GetHash());
19 }
20
21 std::chrono::microseconds GetTxRequestTime(const GenTxid& gtxid) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
22 {
23- auto it = g_already_asked_for.find(gtxid);
24+ auto it = g_already_asked_for.find(gtxid.GetHash());
25 if (it != g_already_asked_for.end()) {
26 return it->second;
27 }
28@@ -770,9 +770,9 @@ std::chrono::microseconds GetTxRequestTime(const GenTxid& gtxid) EXCLUSIVE_LOCKS
29
30 void UpdateTxRequestTime(const GenTxid& gtxid, std::chrono::microseconds request_time) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
31 {
32- auto it = g_already_asked_for.find(gtxid);
33+ auto it = g_already_asked_for.find(gtxid.GetHash());
34 if (it == g_already_asked_for.end()) {
35- g_already_asked_for.insert(std::make_pair(gtxid, request_time));
36+ g_already_asked_for.insert(std::make_pair(gtxid.GetHash(), request_time));
37 } else {
38 g_already_asked_for.update(it, request_time);
39 }
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.