Skip to content

Commit 072a198

Browse files
committed
Convert remaining instances of GenTxid to GenTxidVariant
1 parent 1b52839 commit 072a198

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/net_processing.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ class PeerManagerImpl final : public PeerManager
856856
std::shared_ptr<const CBlock> m_most_recent_block GUARDED_BY(m_most_recent_block_mutex);
857857
std::shared_ptr<const CBlockHeaderAndShortTxIDs> m_most_recent_compact_block GUARDED_BY(m_most_recent_block_mutex);
858858
uint256 m_most_recent_block_hash GUARDED_BY(m_most_recent_block_mutex);
859-
std::unique_ptr<const std::map<uint256, CTransactionRef>> m_most_recent_block_txs GUARDED_BY(m_most_recent_block_mutex);
859+
std::unique_ptr<const std::map<GenTxidVariant, CTransactionRef>> m_most_recent_block_txs GUARDED_BY(m_most_recent_block_mutex);
860860

861861
// Data about the low-work headers synchronization, aggregated from all peers' HeadersSyncStates.
862862
/** Mutex guarding the other m_headers_presync_* variables. */
@@ -2027,7 +2027,7 @@ void PeerManagerImpl::NewPoWValidBlock(const CBlockIndex *pindex, const std::sha
20272027
std::async(std::launch::deferred, [&] { return NetMsg::Make(NetMsgType::CMPCTBLOCK, *pcmpctblock); })};
20282028

20292029
{
2030-
auto most_recent_block_txs = std::make_unique<std::map<uint256, CTransactionRef>>();
2030+
auto most_recent_block_txs = std::make_unique<std::map<GenTxidVariant, CTransactionRef>>();
20312031
for (const auto& tx : pblock->vtx) {
20322032
most_recent_block_txs->emplace(tx->GetHash(), tx);
20332033
most_recent_block_txs->emplace(tx->GetWitnessHash(), tx);
@@ -2393,7 +2393,7 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
23932393

23942394
CTransactionRef PeerManagerImpl::FindTxForGetData(const Peer::TxRelay& tx_relay, const CInv& inv)
23952395
{
2396-
auto gtxid{ToGenTxid(inv).ToVariant()};
2396+
auto gtxid{ToGenTxid(inv)};
23972397
// If a tx was in the mempool prior to the last INV for this peer, permit the request.
23982398
auto txinfo{std::visit(
23992399
[&](const auto& id) EXCLUSIVE_LOCKS_REQUIRED(NetEventsInterface::g_msgproc_mutex) {
@@ -2408,7 +2408,7 @@ CTransactionRef PeerManagerImpl::FindTxForGetData(const Peer::TxRelay& tx_relay,
24082408
{
24092409
LOCK(m_most_recent_block_mutex);
24102410
if (m_most_recent_block_txs != nullptr) {
2411-
auto it = m_most_recent_block_txs->find(gtxid.ToUint256());
2411+
auto it = m_most_recent_block_txs->find(gtxid);
24122412
if (it != m_most_recent_block_txs->end()) return it->second;
24132413
}
24142414
}
@@ -4011,11 +4011,11 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
40114011
pfrom.fDisconnect = true;
40124012
return;
40134013
}
4014-
const GenTxid gtxid = ToGenTxid(inv);
4014+
const GenTxidVariant gtxid = ToGenTxid(inv);
40154015
AddKnownTx(*peer, inv.hash);
40164016

40174017
if (!m_chainman.IsInitialBlockDownload()) {
4018-
const bool fAlreadyHave{m_txdownloadman.AddTxAnnouncement(pfrom.GetId(), gtxid.ToVariant(), current_time)};
4018+
const bool fAlreadyHave{m_txdownloadman.AddTxAnnouncement(pfrom.GetId(), gtxid, current_time)};
40194019
LogDebug(BCLog::NET, "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom.GetId());
40204020
}
40214021
} else {
@@ -4946,7 +4946,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
49464946
if (vInv.size() <= node::MAX_PEER_TX_ANNOUNCEMENTS + MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
49474947
for (CInv &inv : vInv) {
49484948
if (inv.IsGenTxMsg()) {
4949-
tx_invs.emplace_back(ToGenTxid(inv).ToVariant());
4949+
tx_invs.emplace_back(ToGenTxid(inv));
49504950
}
49514951
}
49524952
}
@@ -5772,7 +5772,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
57725772
txinfo.tx->GetWitnessHash().ToUint256() :
57735773
txinfo.tx->GetHash().ToUint256(),
57745774
};
5775-
tx_relay->m_tx_inventory_to_send.erase(ToGenTxid(inv).ToVariant());
5775+
tx_relay->m_tx_inventory_to_send.erase(ToGenTxid(inv));
57765776

57775777
// Don't send transactions that peers will not put into their mempool
57785778
if (txinfo.fee < filterrate.GetFee(txinfo.vsize)) {

src/protocol.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ std::vector<std::string> serviceFlagsToStr(uint64_t flags)
118118
return str_flags;
119119
}
120120

121-
GenTxid ToGenTxid(const CInv& inv)
121+
GenTxidVariant ToGenTxid(const CInv& inv)
122122
{
123123
assert(inv.IsGenTxMsg());
124-
return inv.IsMsgWtx() ? GenTxid::Wtxid(inv.hash) : GenTxid::Txid(inv.hash);
124+
return inv.IsMsgWtx() ? GenTxidVariant{Wtxid::FromUint256(inv.hash)} : GenTxidVariant{Txid::FromUint256(inv.hash)};
125125
}

src/protocol.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,6 @@ class CInv
526526
};
527527

528528
/** Convert a TX/WITNESS_TX/WTX CInv to a GenTxid. */
529-
GenTxid ToGenTxid(const CInv& inv);
529+
GenTxidVariant ToGenTxid(const CInv& inv);
530530

531531
#endif // BITCOIN_PROTOCOL_H

0 commit comments

Comments
 (0)