mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-31 10:41:08 +00:00
scripted-diff: Replace GenTxidVariant with GenTxid
-BEGIN VERIFY SCRIPT- sed -i 's/GenTxidVariant/GenTxid/g' $(git grep -l 'GenTxidVariant') -END VERIFY SCRIPT-
This commit is contained in:
parent
c8ba199598
commit
a60f863d3e
@ -302,7 +302,7 @@ struct Peer {
|
||||
* non-wtxid-relay peers, wtxid for wtxid-relay peers). We use the
|
||||
* mempool to sort transactions in dependency order before relay, so
|
||||
* this does not have to be sorted. */
|
||||
std::set<GenTxidVariant> m_tx_inventory_to_send GUARDED_BY(m_tx_inventory_mutex);
|
||||
std::set<GenTxid> m_tx_inventory_to_send GUARDED_BY(m_tx_inventory_mutex);
|
||||
/** Whether the peer has requested us to send our complete mempool. Only
|
||||
* permitted if the peer has NetPermissionFlags::Mempool or we advertise
|
||||
* NODE_BLOOM. See BIP35. */
|
||||
@ -856,7 +856,7 @@ private:
|
||||
std::shared_ptr<const CBlock> m_most_recent_block GUARDED_BY(m_most_recent_block_mutex);
|
||||
std::shared_ptr<const CBlockHeaderAndShortTxIDs> m_most_recent_compact_block GUARDED_BY(m_most_recent_block_mutex);
|
||||
uint256 m_most_recent_block_hash GUARDED_BY(m_most_recent_block_mutex);
|
||||
std::unique_ptr<const std::map<GenTxidVariant, CTransactionRef>> m_most_recent_block_txs GUARDED_BY(m_most_recent_block_mutex);
|
||||
std::unique_ptr<const std::map<GenTxid, CTransactionRef>> m_most_recent_block_txs GUARDED_BY(m_most_recent_block_mutex);
|
||||
|
||||
// Data about the low-work headers synchronization, aggregated from all peers' HeadersSyncStates.
|
||||
/** Mutex guarding the other m_headers_presync_* variables. */
|
||||
@ -2027,7 +2027,7 @@ void PeerManagerImpl::NewPoWValidBlock(const CBlockIndex *pindex, const std::sha
|
||||
std::async(std::launch::deferred, [&] { return NetMsg::Make(NetMsgType::CMPCTBLOCK, *pcmpctblock); })};
|
||||
|
||||
{
|
||||
auto most_recent_block_txs = std::make_unique<std::map<GenTxidVariant, CTransactionRef>>();
|
||||
auto most_recent_block_txs = std::make_unique<std::map<GenTxid, CTransactionRef>>();
|
||||
for (const auto& tx : pblock->vtx) {
|
||||
most_recent_block_txs->emplace(tx->GetHash(), tx);
|
||||
most_recent_block_txs->emplace(tx->GetWitnessHash(), tx);
|
||||
@ -2166,7 +2166,7 @@ void PeerManagerImpl::RelayTransaction(const Txid& txid, const Wtxid& wtxid)
|
||||
// in the announcement.
|
||||
if (tx_relay->m_next_inv_send_time == 0s) continue;
|
||||
|
||||
const auto gtxid{peer.m_wtxid_relay ? GenTxidVariant{wtxid} : GenTxidVariant{txid}};
|
||||
const auto gtxid{peer.m_wtxid_relay ? GenTxid{wtxid} : GenTxid{txid}};
|
||||
if (!tx_relay->m_tx_inventory_known_filter.contains(gtxid.ToUint256())) {
|
||||
tx_relay->m_tx_inventory_to_send.insert(gtxid);
|
||||
}
|
||||
@ -4011,7 +4011,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||
pfrom.fDisconnect = true;
|
||||
return;
|
||||
}
|
||||
const GenTxidVariant gtxid = ToGenTxid(inv);
|
||||
const GenTxid gtxid = ToGenTxid(inv);
|
||||
AddKnownTx(*peer, inv.hash);
|
||||
|
||||
if (!m_chainman.IsInitialBlockDownload()) {
|
||||
@ -4942,7 +4942,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||
if (msg_type == NetMsgType::NOTFOUND) {
|
||||
std::vector<CInv> vInv;
|
||||
vRecv >> vInv;
|
||||
std::vector<GenTxidVariant> tx_invs;
|
||||
std::vector<GenTxid> tx_invs;
|
||||
if (vInv.size() <= node::MAX_PEER_TX_ANNOUNCEMENTS + MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
|
||||
for (CInv &inv : vInv) {
|
||||
if (inv.IsGenTxMsg()) {
|
||||
@ -5450,7 +5450,7 @@ class CompareInvMempoolOrder
|
||||
public:
|
||||
explicit CompareInvMempoolOrder(CTxMemPool* mempool) : m_mempool{mempool} {}
|
||||
|
||||
bool operator()(std::set<GenTxidVariant>::iterator a, std::set<GenTxidVariant>::iterator b)
|
||||
bool operator()(std::set<GenTxid>::iterator a, std::set<GenTxid>::iterator b)
|
||||
{
|
||||
/* As std::make_heap produces a max-heap, we want the entries with the
|
||||
* fewest ancestors/highest fee to sort later. */
|
||||
@ -5793,9 +5793,9 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
|
||||
// Determine transactions to relay
|
||||
if (fSendTrickle) {
|
||||
// Produce a vector with all candidates for sending
|
||||
std::vector<std::set<GenTxidVariant>::iterator> vInvTx;
|
||||
std::vector<std::set<GenTxid>::iterator> vInvTx;
|
||||
vInvTx.reserve(tx_relay->m_tx_inventory_to_send.size());
|
||||
for (std::set<GenTxidVariant>::iterator it = tx_relay->m_tx_inventory_to_send.begin(); it != tx_relay->m_tx_inventory_to_send.end(); it++) {
|
||||
for (std::set<GenTxid>::iterator it = tx_relay->m_tx_inventory_to_send.begin(); it != tx_relay->m_tx_inventory_to_send.end(); it++) {
|
||||
vInvTx.push_back(it);
|
||||
}
|
||||
const CFeeRate filterrate{tx_relay->m_fee_filter_received.load()};
|
||||
@ -5812,9 +5812,9 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
|
||||
while (!vInvTx.empty() && nRelayedTransactions < broadcast_max) {
|
||||
// Fetch the top element from the heap
|
||||
std::pop_heap(vInvTx.begin(), vInvTx.end(), compareInvMempoolOrder);
|
||||
std::set<GenTxidVariant>::iterator it = vInvTx.back();
|
||||
std::set<GenTxid>::iterator it = vInvTx.back();
|
||||
vInvTx.pop_back();
|
||||
GenTxidVariant hash = *it;
|
||||
GenTxid hash = *it;
|
||||
Assume(peer->m_wtxid_relay == hash.IsWtxid());
|
||||
CInv inv(peer->m_wtxid_relay ? MSG_WTX : MSG_TX, hash.ToUint256());
|
||||
// Remove it from the to-be-sent set
|
||||
@ -5962,7 +5962,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
|
||||
//
|
||||
{
|
||||
LOCK(m_tx_download_mutex);
|
||||
for (const GenTxidVariant& gtxid : m_txdownloadman.GetRequestsToSend(pto->GetId(), current_time)) {
|
||||
for (const GenTxid& gtxid : m_txdownloadman.GetRequestsToSend(pto->GetId(), current_time)) {
|
||||
vGetData.emplace_back(gtxid.IsWtxid() ? MSG_WTX : (MSG_TX | GetFetchFlags(*peer)), gtxid.ToUint256());
|
||||
if (vGetData.size() >= MAX_GETDATA_SZ) {
|
||||
MakeAndPushMessage(*pto, NetMsgType::GETDATA, vGetData);
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
class CBlock;
|
||||
class CRollingBloomFilter;
|
||||
class CTxMemPool;
|
||||
class GenTxidVariant;
|
||||
class GenTxid;
|
||||
class TxRequestTracker;
|
||||
namespace node {
|
||||
class TxDownloadManagerImpl;
|
||||
@ -138,13 +138,13 @@ public:
|
||||
/** Consider adding this tx hash to txrequest. Should be called whenever a new inv has been received.
|
||||
* Also called internally when a transaction is missing parents so that we can request them.
|
||||
* Returns true if this was a dropped inv (p2p_inv=true and we already have the tx), false otherwise. */
|
||||
bool AddTxAnnouncement(NodeId peer, const GenTxidVariant& gtxid, std::chrono::microseconds now);
|
||||
bool AddTxAnnouncement(NodeId peer, const GenTxid& gtxid, std::chrono::microseconds now);
|
||||
|
||||
/** Get getdata requests to send. */
|
||||
std::vector<GenTxidVariant> 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<GenTxidVariant>& gtxids);
|
||||
void ReceivedNotFound(NodeId nodeid, const std::vector<GenTxid>& gtxids);
|
||||
|
||||
/** Respond to successful transaction submission to mempool */
|
||||
void MempoolAcceptedTx(const CTransactionRef& tx);
|
||||
|
||||
@ -39,15 +39,15 @@ void TxDownloadManager::DisconnectedPeer(NodeId nodeid)
|
||||
{
|
||||
m_impl->DisconnectedPeer(nodeid);
|
||||
}
|
||||
bool TxDownloadManager::AddTxAnnouncement(NodeId peer, const GenTxidVariant& gtxid, std::chrono::microseconds now)
|
||||
bool TxDownloadManager::AddTxAnnouncement(NodeId peer, const GenTxid& gtxid, std::chrono::microseconds now)
|
||||
{
|
||||
return m_impl->AddTxAnnouncement(peer, gtxid, now);
|
||||
}
|
||||
std::vector<GenTxidVariant> TxDownloadManager::GetRequestsToSend(NodeId nodeid, std::chrono::microseconds current_time)
|
||||
std::vector<GenTxid> TxDownloadManager::GetRequestsToSend(NodeId nodeid, std::chrono::microseconds current_time)
|
||||
{
|
||||
return m_impl->GetRequestsToSend(nodeid, current_time);
|
||||
}
|
||||
void TxDownloadManager::ReceivedNotFound(NodeId nodeid, const std::vector<GenTxidVariant>& gtxids)
|
||||
void TxDownloadManager::ReceivedNotFound(NodeId nodeid, const std::vector<GenTxid>& gtxids)
|
||||
{
|
||||
m_impl->ReceivedNotFound(nodeid, gtxids);
|
||||
}
|
||||
@ -122,7 +122,7 @@ void TxDownloadManagerImpl::BlockDisconnected()
|
||||
RecentConfirmedTransactionsFilter().reset();
|
||||
}
|
||||
|
||||
bool TxDownloadManagerImpl::AlreadyHaveTx(const GenTxidVariant& gtxid, bool include_reconsiderable)
|
||||
bool TxDownloadManagerImpl::AlreadyHaveTx(const GenTxid& gtxid, bool include_reconsiderable)
|
||||
{
|
||||
const uint256& hash = gtxid.ToUint256();
|
||||
|
||||
@ -167,7 +167,7 @@ void TxDownloadManagerImpl::DisconnectedPeer(NodeId nodeid)
|
||||
|
||||
}
|
||||
|
||||
bool TxDownloadManagerImpl::AddTxAnnouncement(NodeId peer, const GenTxidVariant& gtxid, std::chrono::microseconds now)
|
||||
bool TxDownloadManagerImpl::AddTxAnnouncement(NodeId peer, const GenTxid& gtxid, std::chrono::microseconds now)
|
||||
{
|
||||
// If this is an orphan we are trying to resolve, consider this peer as a orphan resolution candidate instead.
|
||||
// - is wtxid matching something in orphanage
|
||||
@ -261,16 +261,16 @@ bool TxDownloadManagerImpl::MaybeAddOrphanResolutionCandidate(const std::vector<
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<GenTxidVariant> TxDownloadManagerImpl::GetRequestsToSend(NodeId nodeid, std::chrono::microseconds current_time)
|
||||
std::vector<GenTxid> TxDownloadManagerImpl::GetRequestsToSend(NodeId nodeid, std::chrono::microseconds current_time)
|
||||
{
|
||||
std::vector<GenTxidVariant> requests;
|
||||
std::vector<std::pair<NodeId, GenTxidVariant>> expired;
|
||||
std::vector<GenTxid> requests;
|
||||
std::vector<std::pair<NodeId, GenTxid>> expired;
|
||||
auto requestable = m_txrequest.GetRequestable(nodeid, current_time, &expired);
|
||||
for (const auto& [expired_nodeid, gtxid] : expired) {
|
||||
LogDebug(BCLog::NET, "timeout of inflight %s %s from peer=%d\n", gtxid.IsWtxid() ? "wtx" : "tx",
|
||||
gtxid.ToUint256().ToString(), expired_nodeid);
|
||||
}
|
||||
for (const GenTxidVariant& gtxid : requestable) {
|
||||
for (const GenTxid& gtxid : requestable) {
|
||||
if (!AlreadyHaveTx(gtxid, /*include_reconsiderable=*/false)) {
|
||||
LogDebug(BCLog::NET, "Requesting %s %s peer=%d\n", gtxid.IsWtxid() ? "wtx" : "tx",
|
||||
gtxid.ToUint256().ToString(), nodeid);
|
||||
@ -285,7 +285,7 @@ std::vector<GenTxidVariant> TxDownloadManagerImpl::GetRequestsToSend(NodeId node
|
||||
return requests;
|
||||
}
|
||||
|
||||
void TxDownloadManagerImpl::ReceivedNotFound(NodeId nodeid, const std::vector<GenTxidVariant>& gtxids)
|
||||
void TxDownloadManagerImpl::ReceivedNotFound(NodeId nodeid, const std::vector<GenTxid>& gtxids)
|
||||
{
|
||||
for (const auto& gtxid : gtxids) {
|
||||
// If we receive a NOTFOUND message for a tx we requested, mark the announcement for it as
|
||||
|
||||
@ -155,7 +155,7 @@ public:
|
||||
* - m_recent_rejects_reconsiderable (if include_reconsiderable = true)
|
||||
* - m_recent_confirmed_transactions
|
||||
* */
|
||||
bool AlreadyHaveTx(const GenTxidVariant& gtxid, bool include_reconsiderable);
|
||||
bool AlreadyHaveTx(const GenTxid& gtxid, bool include_reconsiderable);
|
||||
|
||||
void ConnectedPeer(NodeId nodeid, const TxDownloadConnectionInfo& info);
|
||||
void DisconnectedPeer(NodeId nodeid);
|
||||
@ -163,13 +163,13 @@ public:
|
||||
/** Consider adding this tx hash to txrequest. Should be called whenever a new inv has been received.
|
||||
* Also called internally when a transaction is missing parents so that we can request them.
|
||||
*/
|
||||
bool AddTxAnnouncement(NodeId peer, const GenTxidVariant& gtxid, std::chrono::microseconds now);
|
||||
bool AddTxAnnouncement(NodeId peer, const GenTxid& gtxid, std::chrono::microseconds now);
|
||||
|
||||
/** Get getdata requests to send. */
|
||||
std::vector<GenTxidVariant> 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<GenTxidVariant>& gtxids);
|
||||
void ReceivedNotFound(NodeId nodeid, const std::vector<GenTxid>& gtxids);
|
||||
|
||||
/** Look for a child of this transaction in the orphanage to form a 1-parent-1-child package,
|
||||
* skipping any combinations that have already been tried. Return the resulting package along with
|
||||
|
||||
@ -118,8 +118,8 @@ std::vector<std::string> serviceFlagsToStr(uint64_t flags)
|
||||
return str_flags;
|
||||
}
|
||||
|
||||
GenTxidVariant ToGenTxid(const CInv& inv)
|
||||
GenTxid ToGenTxid(const CInv& inv)
|
||||
{
|
||||
assert(inv.IsGenTxMsg());
|
||||
return inv.IsMsgWtx() ? GenTxidVariant{Wtxid::FromUint256(inv.hash)} : GenTxidVariant{Txid::FromUint256(inv.hash)};
|
||||
return inv.IsMsgWtx() ? GenTxid{Wtxid::FromUint256(inv.hash)} : GenTxid{Txid::FromUint256(inv.hash)};
|
||||
}
|
||||
|
||||
@ -526,6 +526,6 @@ public:
|
||||
};
|
||||
|
||||
/** Convert a TX/WITNESS_TX/WTX CInv to a GenTxid. */
|
||||
GenTxidVariant ToGenTxid(const CInv& inv);
|
||||
GenTxid ToGenTxid(const CInv& inv);
|
||||
|
||||
#endif // BITCOIN_PROTOCOL_H
|
||||
|
||||
@ -228,8 +228,8 @@ FUZZ_TARGET(txdownloadman, .init = initialize)
|
||||
},
|
||||
[&] {
|
||||
auto gtxid = fuzzed_data_provider.ConsumeBool() ?
|
||||
GenTxidVariant{rand_tx->GetHash()} :
|
||||
GenTxidVariant{rand_tx->GetWitnessHash()};
|
||||
GenTxid{rand_tx->GetHash()} :
|
||||
GenTxid{rand_tx->GetWitnessHash()};
|
||||
txdownloadman.AddTxAnnouncement(rand_peer, gtxid, time);
|
||||
},
|
||||
[&] {
|
||||
@ -373,8 +373,8 @@ FUZZ_TARGET(txdownloadman_impl, .init = initialize)
|
||||
},
|
||||
[&] {
|
||||
auto gtxid = fuzzed_data_provider.ConsumeBool() ?
|
||||
GenTxidVariant{rand_tx->GetHash()} :
|
||||
GenTxidVariant{rand_tx->GetWitnessHash()};
|
||||
GenTxid{rand_tx->GetHash()} :
|
||||
GenTxid{rand_tx->GetWitnessHash()};
|
||||
txdownload_impl.AddTxAnnouncement(rand_peer, gtxid, time);
|
||||
},
|
||||
[&] {
|
||||
|
||||
@ -204,7 +204,7 @@ public:
|
||||
}
|
||||
|
||||
// Call TxRequestTracker's implementation.
|
||||
auto gtxid = is_wtxid ? GenTxidVariant{Wtxid::FromUint256(TXHASHES[txhash])} : GenTxidVariant{Txid::FromUint256(TXHASHES[txhash])};
|
||||
auto gtxid = is_wtxid ? GenTxid{Wtxid::FromUint256(TXHASHES[txhash])} : GenTxid{Txid::FromUint256(TXHASHES[txhash])};
|
||||
m_tracker.ReceivedInv(peer, gtxid, preferred, reqtime);
|
||||
}
|
||||
|
||||
@ -247,13 +247,13 @@ public:
|
||||
|
||||
//! list of (sequence number, txhash, is_wtxid) tuples.
|
||||
std::vector<std::tuple<uint64_t, int, bool>> result;
|
||||
std::vector<std::pair<NodeId, GenTxidVariant>> expected_expired;
|
||||
std::vector<std::pair<NodeId, GenTxid>> expected_expired;
|
||||
for (int txhash = 0; txhash < MAX_TXHASHES; ++txhash) {
|
||||
// Mark any expired REQUESTED announcements as COMPLETED.
|
||||
for (int peer2 = 0; peer2 < MAX_PEERS; ++peer2) {
|
||||
Announcement& ann2 = m_announcements[txhash][peer2];
|
||||
if (ann2.m_state == State::REQUESTED && ann2.m_time <= m_now) {
|
||||
auto gtxid = ann2.m_is_wtxid ? GenTxidVariant{Wtxid::FromUint256(TXHASHES[txhash])} : GenTxidVariant{Txid::FromUint256(TXHASHES[txhash])};
|
||||
auto gtxid = ann2.m_is_wtxid ? GenTxid{Wtxid::FromUint256(TXHASHES[txhash])} : GenTxid{Txid::FromUint256(TXHASHES[txhash])};
|
||||
expected_expired.emplace_back(peer2, gtxid);
|
||||
ann2.m_state = State::COMPLETED;
|
||||
break;
|
||||
@ -272,7 +272,7 @@ public:
|
||||
std::sort(expected_expired.begin(), expected_expired.end());
|
||||
|
||||
// Compare with TxRequestTracker's implementation.
|
||||
std::vector<std::pair<NodeId, GenTxidVariant>> expired;
|
||||
std::vector<std::pair<NodeId, GenTxid>> expired;
|
||||
const auto actual = m_tracker.GetRequestable(peer, m_now, &expired);
|
||||
std::sort(expired.begin(), expired.end());
|
||||
assert(expired == expected_expired);
|
||||
|
||||
@ -61,7 +61,7 @@ struct Runner
|
||||
/** Which (peer, gtxid) combinations are known to be expired. These need to be accumulated here instead of
|
||||
* checked directly in the GetRequestable return value to avoid introducing a dependency between the various
|
||||
* parallel tests. */
|
||||
std::multiset<std::pair<NodeId, GenTxidVariant>> expired;
|
||||
std::multiset<std::pair<NodeId, GenTxid>> expired;
|
||||
};
|
||||
|
||||
std::chrono::microseconds TxRequestTest::RandomTime8s() { return std::chrono::microseconds{1 + m_rng.randbits(23)}; }
|
||||
@ -110,7 +110,7 @@ public:
|
||||
}
|
||||
|
||||
/** Schedule a ReceivedInv call at the Scheduler's current time. */
|
||||
void ReceivedInv(NodeId peer, const GenTxidVariant& gtxid, bool pref, std::chrono::microseconds reqtime)
|
||||
void ReceivedInv(NodeId peer, const GenTxid& gtxid, bool pref, std::chrono::microseconds reqtime)
|
||||
{
|
||||
auto& runner = m_runner;
|
||||
runner.actions.emplace_back(m_now, [=, &runner]() {
|
||||
@ -160,7 +160,7 @@ public:
|
||||
* @param offset Offset with the current time to use (must be <= 0). This allows simulations of time going
|
||||
* backwards (but note that the ordering of this event only follows the scenario's m_now.
|
||||
*/
|
||||
void Check(NodeId peer, const std::vector<GenTxidVariant>& expected, size_t candidates, size_t inflight,
|
||||
void Check(NodeId peer, const std::vector<GenTxid>& expected, size_t candidates, size_t inflight,
|
||||
size_t completed, const std::string& checkname,
|
||||
std::chrono::microseconds offset = std::chrono::microseconds{0})
|
||||
{
|
||||
@ -169,7 +169,7 @@ public:
|
||||
const auto now = m_now;
|
||||
assert(offset.count() <= 0);
|
||||
runner.actions.emplace_back(m_now, [=, &runner]() {
|
||||
std::vector<std::pair<NodeId, GenTxidVariant>> expired_now;
|
||||
std::vector<std::pair<NodeId, GenTxid>> expired_now;
|
||||
auto ret = runner.txrequest.GetRequestable(peer, now + offset, &expired_now);
|
||||
for (const auto& entry : expired_now) {
|
||||
runner.expired.insert(entry);
|
||||
@ -191,12 +191,12 @@ public:
|
||||
*
|
||||
* Every expected expiration should be accounted for through exactly one call to this function.
|
||||
*/
|
||||
void CheckExpired(NodeId peer, GenTxidVariant gtxid)
|
||||
void CheckExpired(NodeId peer, GenTxid gtxid)
|
||||
{
|
||||
const auto& testname = m_testname;
|
||||
auto& runner = m_runner;
|
||||
runner.actions.emplace_back(m_now, [=, &runner]() {
|
||||
auto it = runner.expired.find(std::pair<NodeId, GenTxidVariant>{peer, gtxid});
|
||||
auto it = runner.expired.find(std::pair<NodeId, GenTxid>{peer, gtxid});
|
||||
BOOST_CHECK_MESSAGE(it != runner.expired.end(), "[" + testname + "] missing expiration");
|
||||
if (it != runner.expired.end()) runner.expired.erase(it);
|
||||
});
|
||||
@ -236,10 +236,10 @@ public:
|
||||
}
|
||||
|
||||
/** Generate a random GenTxid; the txhash follows NewTxHash; the transaction identifier is random. */
|
||||
GenTxidVariant NewGTxid(const std::vector<std::vector<NodeId>>& orders = {})
|
||||
GenTxid NewGTxid(const std::vector<std::vector<NodeId>>& orders = {})
|
||||
{
|
||||
const uint256 txhash{NewTxHash(orders)};
|
||||
return m_rng.randbool() ? GenTxidVariant{Wtxid::FromUint256(txhash)} : GenTxidVariant{Txid::FromUint256(txhash)};
|
||||
return m_rng.randbool() ? GenTxid{Wtxid::FromUint256(txhash)} : GenTxid{Txid::FromUint256(txhash)};
|
||||
}
|
||||
|
||||
/** Generate a new random NodeId to use as peer. The same NodeId is never returned twice
|
||||
|
||||
@ -794,7 +794,7 @@ void CTxMemPool::check(const CCoinsViewCache& active_coins_tip, int64_t spendhei
|
||||
assert(innerUsage == cachedInnerUsage);
|
||||
}
|
||||
|
||||
bool CTxMemPool::CompareDepthAndScore(const GenTxidVariant& hasha, const GenTxidVariant& hashb) const
|
||||
bool CTxMemPool::CompareDepthAndScore(const GenTxid& hasha, const GenTxid& hashb) const
|
||||
{
|
||||
/* Return `true` if hasha should be considered sooner than hashb. Namely when:
|
||||
* a is not in the mempool, but b is
|
||||
|
||||
@ -472,7 +472,7 @@ public:
|
||||
void removeConflicts(const CTransaction& tx) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
void removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
|
||||
bool CompareDepthAndScore(const GenTxidVariant& hasha, const GenTxidVariant& hashb) const;
|
||||
bool CompareDepthAndScore(const GenTxid& hasha, const GenTxid& hashb) const;
|
||||
bool isSpent(const COutPoint& outpoint) const;
|
||||
unsigned int GetTransactionsUpdated() const;
|
||||
void AddTransactionsUpdated(unsigned int n);
|
||||
|
||||
@ -60,7 +60,7 @@ using SequenceNumber = uint64_t;
|
||||
/** An announcement. This is the data we track for each txid or wtxid that is announced to us by each peer. */
|
||||
struct Announcement {
|
||||
/** Txid or wtxid that was announced. */
|
||||
const GenTxidVariant m_gtxid;
|
||||
const GenTxid m_gtxid;
|
||||
/** For CANDIDATE_{DELAYED,BEST,READY} the reqtime; for REQUESTED the expiry. */
|
||||
std::chrono::microseconds m_time;
|
||||
/** What peer the request was from. */
|
||||
@ -93,7 +93,7 @@ struct Announcement {
|
||||
}
|
||||
|
||||
/** Construct a new announcement from scratch, initially in CANDIDATE_DELAYED state. */
|
||||
Announcement(const GenTxidVariant& gtxid, NodeId peer, bool preferred, std::chrono::microseconds reqtime,
|
||||
Announcement(const GenTxid& gtxid, NodeId peer, bool preferred, std::chrono::microseconds reqtime,
|
||||
SequenceNumber sequence)
|
||||
: m_gtxid(gtxid), m_time(reqtime), m_peer(peer), m_sequence(sequence), m_preferred(preferred) {}
|
||||
};
|
||||
@ -481,7 +481,7 @@ private:
|
||||
//! - REQUESTED announcements with expiry <= now are turned into COMPLETED.
|
||||
//! - CANDIDATE_DELAYED announcements with reqtime <= now are turned into CANDIDATE_{READY,BEST}.
|
||||
//! - CANDIDATE_{READY,BEST} announcements with reqtime > now are turned into CANDIDATE_DELAYED.
|
||||
void SetTimePoint(std::chrono::microseconds now, std::vector<std::pair<NodeId, GenTxidVariant>>* expired)
|
||||
void SetTimePoint(std::chrono::microseconds now, std::vector<std::pair<NodeId, GenTxid>>* expired)
|
||||
{
|
||||
if (expired) expired->clear();
|
||||
|
||||
@ -574,7 +574,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void ReceivedInv(NodeId peer, const GenTxidVariant& gtxid, bool preferred,
|
||||
void ReceivedInv(NodeId peer, const GenTxid& gtxid, bool preferred,
|
||||
std::chrono::microseconds reqtime)
|
||||
{
|
||||
// Bail out if we already have a CANDIDATE_BEST announcement for this (txhash, peer) combination. The case
|
||||
@ -594,8 +594,8 @@ public:
|
||||
}
|
||||
|
||||
//! Find the GenTxids to request now from peer.
|
||||
std::vector<GenTxidVariant> GetRequestable(NodeId peer, std::chrono::microseconds now,
|
||||
std::vector<std::pair<NodeId, GenTxidVariant>>* expired)
|
||||
std::vector<GenTxid> GetRequestable(NodeId peer, std::chrono::microseconds now,
|
||||
std::vector<std::pair<NodeId, GenTxid>>* expired)
|
||||
{
|
||||
// Move time.
|
||||
SetTimePoint(now, expired);
|
||||
@ -615,7 +615,7 @@ public:
|
||||
});
|
||||
|
||||
// Convert to GenTxid and return.
|
||||
std::vector<GenTxidVariant> ret;
|
||||
std::vector<GenTxid> ret;
|
||||
ret.reserve(selected.size());
|
||||
std::transform(selected.begin(), selected.end(), std::back_inserter(ret), [](const Announcement* ann) {
|
||||
return ann->m_gtxid;
|
||||
@ -729,7 +729,7 @@ void TxRequestTracker::PostGetRequestableSanityCheck(std::chrono::microseconds n
|
||||
m_impl->PostGetRequestableSanityCheck(now);
|
||||
}
|
||||
|
||||
void TxRequestTracker::ReceivedInv(NodeId peer, const GenTxidVariant& gtxid, bool preferred,
|
||||
void TxRequestTracker::ReceivedInv(NodeId peer, const GenTxid& gtxid, bool preferred,
|
||||
std::chrono::microseconds reqtime)
|
||||
{
|
||||
m_impl->ReceivedInv(peer, gtxid, preferred, reqtime);
|
||||
@ -745,8 +745,8 @@ void TxRequestTracker::ReceivedResponse(NodeId peer, const uint256& txhash)
|
||||
m_impl->ReceivedResponse(peer, txhash);
|
||||
}
|
||||
|
||||
std::vector<GenTxidVariant> TxRequestTracker::GetRequestable(NodeId peer, std::chrono::microseconds now,
|
||||
std::vector<std::pair<NodeId, GenTxidVariant>>* expired)
|
||||
std::vector<GenTxid> TxRequestTracker::GetRequestable(NodeId peer, std::chrono::microseconds now,
|
||||
std::vector<std::pair<NodeId, GenTxid>>* expired)
|
||||
{
|
||||
return m_impl->GetRequestable(peer, now, expired);
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ public:
|
||||
* fetched. The new announcement is given the specified preferred and reqtime values, and takes its is_wtxid
|
||||
* from the specified gtxid.
|
||||
*/
|
||||
void ReceivedInv(NodeId peer, const GenTxidVariant& gtxid, bool preferred,
|
||||
void ReceivedInv(NodeId peer, const GenTxid& gtxid, bool preferred,
|
||||
std::chrono::microseconds reqtime);
|
||||
|
||||
/** Deletes all announcements for a given peer.
|
||||
@ -163,8 +163,8 @@ public:
|
||||
* from dependent transactions being requested out of order: if multiple dependent transactions are announced
|
||||
* simultaneously by one peer, and end up being requested from them, the requests will happen in announcement order.
|
||||
*/
|
||||
std::vector<GenTxidVariant> GetRequestable(NodeId peer, std::chrono::microseconds now,
|
||||
std::vector<std::pair<NodeId, GenTxidVariant>>* expired = nullptr);
|
||||
std::vector<GenTxid> GetRequestable(NodeId peer, std::chrono::microseconds now,
|
||||
std::vector<std::pair<NodeId, GenTxid>>* expired = nullptr);
|
||||
|
||||
/** Marks a transaction as requested, with a specified expiry.
|
||||
*
|
||||
|
||||
@ -84,7 +84,7 @@ using Wtxid = transaction_identifier<true>;
|
||||
template <typename T>
|
||||
concept TxidOrWtxid = std::is_same_v<T, Txid> || std::is_same_v<T, Wtxid>;
|
||||
|
||||
class GenTxidVariant : public std::variant<Txid, Wtxid>
|
||||
class GenTxid : public std::variant<Txid, Wtxid>
|
||||
{
|
||||
public:
|
||||
using variant::variant;
|
||||
@ -96,7 +96,7 @@ public:
|
||||
return std::visit([](const auto& id) -> const uint256& { return id.ToUint256(); }, *this);
|
||||
}
|
||||
|
||||
friend auto operator<=>(const GenTxidVariant& a, const GenTxidVariant& b)
|
||||
friend auto operator<=>(const GenTxid& a, const GenTxid& b)
|
||||
{
|
||||
return std::tuple(a.IsWtxid(), a.ToUint256()) <=> std::tuple(b.IsWtxid(), b.ToUint256());
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user