Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 3,110 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::INV) { | ||||
std::optional<BlockHash> best_block; | std::optional<BlockHash> best_block; | ||||
for (CInv &inv : vInv) { | for (CInv &inv : vInv) { | ||||
if (interruptMsgProc) { | if (interruptMsgProc) { | ||||
return; | return; | ||||
} | } | ||||
if (inv.IsMsgBlk()) { | if (inv.IsMsgBlk()) { | ||||
bool fAlreadyHave = AlreadyHaveBlock(BlockHash(inv.hash)); | const bool fAlreadyHave = AlreadyHaveBlock(BlockHash(inv.hash)); | ||||
LogPrint(BCLog::NET, "got inv: %s %s peer=%d\n", | LogPrint(BCLog::NET, "got inv: %s %s peer=%d\n", | ||||
inv.ToString(), fAlreadyHave ? "have" : "new", | inv.ToString(), fAlreadyHave ? "have" : "new", | ||||
pfrom.GetId()); | pfrom.GetId()); | ||||
const BlockHash hash{inv.hash}; | const BlockHash hash{inv.hash}; | ||||
UpdateBlockAvailability(pfrom.GetId(), hash); | UpdateBlockAvailability(pfrom.GetId(), hash); | ||||
if (!fAlreadyHave && !fImporting && !fReindex && | if (!fAlreadyHave && !fImporting && !fReindex && | ||||
!mapBlocksInFlight.count(hash)) { | !mapBlocksInFlight.count(hash)) { | ||||
// Headers-first is the primary method of announcement on | // Headers-first is the primary method of announcement on | ||||
// the network. If a node fell back to sending blocks by | // the network. If a node fell back to sending blocks by | ||||
// inv, it's probably for a re-org. The final block hash | // inv, it's probably for a re-org. The final block hash | ||||
// provided should be the highest, so send a getheaders and | // provided should be the highest, so send a getheaders and | ||||
// then fetch the blocks we need to catch up. | // then fetch the blocks we need to catch up. | ||||
best_block = std::move(hash); | best_block = std::move(hash); | ||||
} | } | ||||
} else { | } else { | ||||
const TxId txid(inv.hash); | const TxId txid(inv.hash); | ||||
bool fAlreadyHave = AlreadyHaveTx(txid, m_mempool); | const bool fAlreadyHave = AlreadyHaveTx(txid, m_mempool); | ||||
LogPrint(BCLog::NET, "got inv: %s %s peer=%d\n", | LogPrint(BCLog::NET, "got inv: %s %s peer=%d\n", | ||||
inv.ToString(), fAlreadyHave ? "have" : "new", | inv.ToString(), fAlreadyHave ? "have" : "new", | ||||
pfrom.GetId()); | pfrom.GetId()); | ||||
pfrom.AddKnownTx(txid); | pfrom.AddKnownTx(txid); | ||||
if (fBlocksOnly) { | if (fBlocksOnly) { | ||||
LogPrint(BCLog::NET, | LogPrint(BCLog::NET, | ||||
"transaction (%s) inv sent in violation of " | "transaction (%s) inv sent in violation of " | ||||
▲ Show 20 Lines • Show All 2,474 Lines • Show Last 20 Lines |