Skip to content

Commit 60f0acd

Browse files
committed
Just pass a hash to AddInventoryKnown
Since it's only used for transactions, there's no need to pass in an inv type.
1 parent c7eb6b4 commit 60f0acd

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/net.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -965,11 +965,11 @@ class CNode
965965
}
966966

967967

968-
void AddInventoryKnown(const CInv& inv)
968+
void AddInventoryKnown(const uint256& hash)
969969
{
970970
if (m_tx_relay != nullptr) {
971971
LOCK(m_tx_relay->cs_tx_inventory);
972-
m_tx_relay->filterInventoryKnown.insert(inv.hash);
972+
m_tx_relay->filterInventoryKnown.insert(hash);
973973
}
974974
}
975975

src/net_processing.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2593,7 +2593,7 @@ void ProcessMessage(
25932593
best_block = &inv.hash;
25942594
}
25952595
} else {
2596-
pfrom.AddInventoryKnown(inv);
2596+
pfrom.AddInventoryKnown(inv.hash);
25972597
if (fBlocksOnly) {
25982598
LogPrint(BCLog::NET, "transaction (%s) inv sent in violation of protocol, disconnecting peer=%d\n", inv.hash.ToString(), pfrom.GetId());
25992599
pfrom.fDisconnect = true;
@@ -2832,26 +2832,26 @@ void ProcessMessage(
28322832
vRecv >> ptx;
28332833
const CTransaction& tx = *ptx;
28342834

2835-
CInv inv(MSG_TX, tx.GetHash());
2836-
pfrom.AddInventoryKnown(inv);
2835+
const uint256& txid = ptx->GetHash();
2836+
pfrom.AddInventoryKnown(txid);
28372837

28382838
LOCK2(cs_main, g_cs_orphans);
28392839

28402840
TxValidationState state;
28412841

28422842
CNodeState* nodestate = State(pfrom.GetId());
2843-
nodestate->m_tx_download.m_tx_announced.erase(inv.hash);
2844-
nodestate->m_tx_download.m_tx_in_flight.erase(inv.hash);
2845-
EraseTxRequest(inv.hash);
2843+
nodestate->m_tx_download.m_tx_announced.erase(txid);
2844+
nodestate->m_tx_download.m_tx_in_flight.erase(txid);
2845+
EraseTxRequest(txid);
28462846

28472847
std::list<CTransactionRef> lRemovedTxn;
28482848

2849-
if (!AlreadyHave(inv, mempool) &&
2849+
if (!AlreadyHave(CInv(MSG_TX, txid), mempool) &&
28502850
AcceptToMemoryPool(mempool, state, ptx, &lRemovedTxn, false /* bypass_limits */, 0 /* nAbsurdFee */)) {
28512851
mempool.check(&::ChainstateActive().CoinsTip());
28522852
RelayTransaction(tx.GetHash(), connman);
28532853
for (unsigned int i = 0; i < tx.vout.size(); i++) {
2854-
auto it_by_prev = mapOrphanTransactionsByPrev.find(COutPoint(inv.hash, i));
2854+
auto it_by_prev = mapOrphanTransactionsByPrev.find(COutPoint(txid, i));
28552855
if (it_by_prev != mapOrphanTransactionsByPrev.end()) {
28562856
for (const auto& elem : it_by_prev->second) {
28572857
pfrom.orphan_work_set.insert(elem->first);
@@ -2884,7 +2884,7 @@ void ProcessMessage(
28842884

28852885
for (const CTxIn& txin : tx.vin) {
28862886
CInv _inv(MSG_TX | nFetchFlags, txin.prevout.hash);
2887-
pfrom.AddInventoryKnown(_inv);
2887+
pfrom.AddInventoryKnown(txin.prevout.hash);
28882888
if (!AlreadyHave(_inv, mempool)) RequestTx(State(pfrom.GetId()), _inv.hash, current_time);
28892889
}
28902890
AddOrphanTx(ptx, pfrom.GetId());

0 commit comments

Comments
 (0)