@@ -751,34 +751,34 @@ static void FindNextBlocksToDownload(NodeId nodeid, unsigned int count, std::vec
751
751
}
752
752
}
753
753
754
- void EraseTxRequest (const uint256& txid ) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
754
+ void EraseTxRequest (const GenTxid& gtxid ) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
755
755
{
756
- g_already_asked_for.erase (txid );
756
+ g_already_asked_for.erase (gtxid. GetHash () );
757
757
}
758
758
759
- std::chrono::microseconds GetTxRequestTime (const uint256& txid ) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
759
+ std::chrono::microseconds GetTxRequestTime (const GenTxid& gtxid ) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
760
760
{
761
- auto it = g_already_asked_for.find (txid );
761
+ auto it = g_already_asked_for.find (gtxid. GetHash () );
762
762
if (it != g_already_asked_for.end ()) {
763
763
return it->second ;
764
764
}
765
765
return {};
766
766
}
767
767
768
- void UpdateTxRequestTime (const uint256& txid , std::chrono::microseconds request_time) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
768
+ void UpdateTxRequestTime (const GenTxid& gtxid , std::chrono::microseconds request_time) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
769
769
{
770
- auto it = g_already_asked_for.find (txid );
770
+ auto it = g_already_asked_for.find (gtxid. GetHash () );
771
771
if (it == g_already_asked_for.end ()) {
772
- g_already_asked_for.insert (std::make_pair (txid , request_time));
772
+ g_already_asked_for.insert (std::make_pair (gtxid. GetHash () , request_time));
773
773
} else {
774
774
g_already_asked_for.update (it, request_time);
775
775
}
776
776
}
777
777
778
- std::chrono::microseconds CalculateTxGetDataTime (const uint256& txid , std::chrono::microseconds current_time, bool use_inbound_delay, bool use_txid_delay) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
778
+ std::chrono::microseconds CalculateTxGetDataTime (const GenTxid& gtxid , std::chrono::microseconds current_time, bool use_inbound_delay, bool use_txid_delay) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
779
779
{
780
780
std::chrono::microseconds process_time;
781
- const auto last_request_time = GetTxRequestTime (txid );
781
+ const auto last_request_time = GetTxRequestTime (gtxid );
782
782
// First time requesting this tx
783
783
if (last_request_time.count () == 0 ) {
784
784
process_time = current_time;
@@ -811,7 +811,7 @@ void RequestTx(CNodeState* state, const GenTxid& gtxid, std::chrono::microsecond
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 (gtxid. GetHash () , current_time, !state->fPreferredDownload , !state->m_wtxid_relay && g_wtxid_relay_peers > 0 );
814
+ const auto process_time = CalculateTxGetDataTime (gtxid, current_time, !state->fPreferredDownload , !state->m_wtxid_relay && g_wtxid_relay_peers > 0 );
815
815
816
816
peer_download_state.m_tx_process_time .emplace (process_time, gtxid);
817
817
}
@@ -2933,10 +2933,10 @@ void ProcessMessage(
2933
2933
2934
2934
TxValidationState state;
2935
2935
2936
- for (uint256 hash : {txid, wtxid}) {
2937
- nodestate->m_tx_download .m_tx_announced .erase (hash );
2938
- nodestate->m_tx_download .m_tx_in_flight .erase (hash );
2939
- EraseTxRequest (hash );
2936
+ for (const GenTxid& gtxid : {GenTxid ( false , txid), GenTxid ( true , wtxid) }) {
2937
+ nodestate->m_tx_download .m_tx_announced .erase (gtxid. GetHash () );
2938
+ nodestate->m_tx_download .m_tx_in_flight .erase (gtxid. GetHash () );
2939
+ EraseTxRequest (gtxid );
2940
2940
}
2941
2941
2942
2942
std::list<CTransactionRef> lRemovedTxn;
@@ -4539,15 +4539,15 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
4539
4539
if (!AlreadyHave (inv, m_mempool)) {
4540
4540
// If this transaction was last requested more than 1 minute ago,
4541
4541
// then request.
4542
- const auto last_request_time = GetTxRequestTime (gtxid. GetHash () );
4542
+ const auto last_request_time = GetTxRequestTime (gtxid);
4543
4543
if (last_request_time <= current_time - GETDATA_TX_INTERVAL) {
4544
4544
LogPrint (BCLog::NET, " Requesting %s peer=%d\n " , inv.ToString (), pto->GetId ());
4545
4545
vGetData.push_back (inv);
4546
4546
if (vGetData.size () >= MAX_GETDATA_SZ) {
4547
4547
connman->PushMessage (pto, msgMaker.Make (NetMsgType::GETDATA, vGetData));
4548
4548
vGetData.clear ();
4549
4549
}
4550
- UpdateTxRequestTime (gtxid. GetHash () , current_time);
4550
+ UpdateTxRequestTime (gtxid, current_time);
4551
4551
state.m_tx_download .m_tx_in_flight .emplace (gtxid.GetHash (), current_time);
4552
4552
} else {
4553
4553
// This transaction is in flight from someone else; queue
@@ -4562,7 +4562,7 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
4562
4562
// would open us up to an attacker using inbound
4563
4563
// wtxid-relay to prevent us from requesting transactions
4564
4564
// from outbound txid-relay peers).
4565
- const auto next_process_time = CalculateTxGetDataTime (gtxid. GetHash () , current_time, !state.fPreferredDownload , false );
4565
+ const auto next_process_time = CalculateTxGetDataTime (gtxid, current_time, !state.fPreferredDownload , false );
4566
4566
tx_process_time.emplace (next_process_time, gtxid);
4567
4567
}
4568
4568
} else {
0 commit comments