@@ -398,7 +398,7 @@ struct CNodeState {
398
398
/* Track when to attempt download of announced transactions (process
399
399
* time in micros -> txid)
400
400
*/
401
- std::multimap<std::chrono::microseconds, uint256 > m_tx_process_time;
401
+ std::multimap<std::chrono::microseconds, GenTxid > m_tx_process_time;
402
402
403
403
// ! Store all the transactions a peer has recently announced
404
404
std::set<uint256> m_tx_announced;
@@ -797,23 +797,23 @@ std::chrono::microseconds CalculateTxGetDataTime(const uint256& txid, std::chron
797
797
return process_time;
798
798
}
799
799
800
- void RequestTx (CNodeState* state, const uint256& txid , std::chrono::microseconds current_time) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
800
+ void RequestTx (CNodeState* state, const GenTxid& gtxid , std::chrono::microseconds current_time) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
801
801
{
802
802
CNodeState::TxDownloadState& peer_download_state = state->m_tx_download ;
803
803
if (peer_download_state.m_tx_announced .size () >= MAX_PEER_TX_ANNOUNCEMENTS ||
804
804
peer_download_state.m_tx_process_time .size () >= MAX_PEER_TX_ANNOUNCEMENTS ||
805
- peer_download_state.m_tx_announced .count (txid )) {
805
+ peer_download_state.m_tx_announced .count (gtxid. GetHash () )) {
806
806
// Too many queued announcements from this peer, or we already have
807
807
// this announcement
808
808
return ;
809
809
}
810
- peer_download_state.m_tx_announced .insert (txid );
810
+ peer_download_state.m_tx_announced .insert (gtxid. GetHash () );
811
811
812
812
// Calculate the time to try requesting this transaction. Use
813
813
// fPreferredDownload as a proxy for outbound peers.
814
- const auto process_time = CalculateTxGetDataTime (txid , current_time, !state->fPreferredDownload , !state->m_wtxid_relay && g_wtxid_relay_peers > 0 );
814
+ const auto process_time = CalculateTxGetDataTime (gtxid. GetHash () , current_time, !state->fPreferredDownload , !state->m_wtxid_relay && g_wtxid_relay_peers > 0 );
815
815
816
- peer_download_state.m_tx_process_time .emplace (process_time, txid );
816
+ peer_download_state.m_tx_process_time .emplace (process_time, gtxid );
817
817
}
818
818
819
819
} // namespace
@@ -2678,7 +2678,7 @@ void ProcessMessage(
2678
2678
pfrom.fDisconnect = true ;
2679
2679
return ;
2680
2680
} else if (!fAlreadyHave && !chainman.ActiveChainstate ().IsInitialBlockDownload ()) {
2681
- RequestTx (State (pfrom.GetId ()), inv. hash , current_time);
2681
+ RequestTx (State (pfrom.GetId ()), ToGenTxid ( inv) , current_time);
2682
2682
}
2683
2683
}
2684
2684
}
@@ -2994,7 +2994,7 @@ void ProcessMessage(
2994
2994
// protocol for getting all unconfirmed parents.
2995
2995
CInv _inv (MSG_TX | nFetchFlags, txin.prevout .hash );
2996
2996
pfrom.AddKnownTx (txin.prevout .hash );
2997
- if (!AlreadyHave (_inv, mempool)) RequestTx (State (pfrom.GetId ()), _inv. hash , current_time);
2997
+ if (!AlreadyHave (_inv, mempool)) RequestTx (State (pfrom.GetId ()), ToGenTxid ( _inv) , current_time);
2998
2998
}
2999
2999
}
3000
3000
AddOrphanTx (ptx, pfrom.GetId ());
@@ -4529,24 +4529,24 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
4529
4529
4530
4530
auto & tx_process_time = state.m_tx_download .m_tx_process_time ;
4531
4531
while (!tx_process_time.empty () && tx_process_time.begin ()->first <= current_time && state.m_tx_download .m_tx_in_flight .size () < MAX_PEER_TX_IN_FLIGHT) {
4532
- const uint256 txid = tx_process_time.begin ()->second ;
4532
+ const GenTxid gtxid = tx_process_time.begin ()->second ;
4533
4533
// Erase this entry from tx_process_time (it may be added back for
4534
4534
// processing at a later time, see below)
4535
4535
tx_process_time.erase (tx_process_time.begin ());
4536
- CInv inv (state. m_wtxid_relay ? MSG_WTX : (MSG_TX | GetFetchFlags (*pto)), txid );
4536
+ CInv inv (gtxid. IsWtxid () ? MSG_WTX : (MSG_TX | GetFetchFlags (*pto)), gtxid. GetHash () );
4537
4537
if (!AlreadyHave (inv, m_mempool)) {
4538
4538
// If this transaction was last requested more than 1 minute ago,
4539
4539
// then request.
4540
- const auto last_request_time = GetTxRequestTime (inv. hash );
4540
+ const auto last_request_time = GetTxRequestTime (gtxid. GetHash () );
4541
4541
if (last_request_time <= current_time - GETDATA_TX_INTERVAL) {
4542
4542
LogPrint (BCLog::NET, " Requesting %s peer=%d\n " , inv.ToString (), pto->GetId ());
4543
4543
vGetData.push_back (inv);
4544
4544
if (vGetData.size () >= MAX_GETDATA_SZ) {
4545
4545
connman->PushMessage (pto, msgMaker.Make (NetMsgType::GETDATA, vGetData));
4546
4546
vGetData.clear ();
4547
4547
}
4548
- UpdateTxRequestTime (inv. hash , current_time);
4549
- state.m_tx_download .m_tx_in_flight .emplace (inv. hash , current_time);
4548
+ UpdateTxRequestTime (gtxid. GetHash () , current_time);
4549
+ state.m_tx_download .m_tx_in_flight .emplace (gtxid. GetHash () , current_time);
4550
4550
} else {
4551
4551
// This transaction is in flight from someone else; queue
4552
4552
// up processing to happen after the download times out
@@ -4560,13 +4560,13 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
4560
4560
// would open us up to an attacker using inbound
4561
4561
// wtxid-relay to prevent us from requesting transactions
4562
4562
// from outbound txid-relay peers).
4563
- const auto next_process_time = CalculateTxGetDataTime (txid , current_time, !state.fPreferredDownload , false );
4564
- tx_process_time.emplace (next_process_time, txid );
4563
+ const auto next_process_time = CalculateTxGetDataTime (gtxid. GetHash () , current_time, !state.fPreferredDownload , false );
4564
+ tx_process_time.emplace (next_process_time, gtxid );
4565
4565
}
4566
4566
} else {
4567
4567
// We have already seen this transaction, no need to download.
4568
- state.m_tx_download .m_tx_announced .erase (inv. hash );
4569
- state.m_tx_download .m_tx_in_flight .erase (inv. hash );
4568
+ state.m_tx_download .m_tx_announced .erase (gtxid. GetHash () );
4569
+ state.m_tx_download .m_tx_in_flight .erase (gtxid. GetHash () );
4570
4570
}
4571
4571
}
4572
4572
0 commit comments