Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 3,126 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::INV) { | ||||
!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 if (inv.IsMsgTx()) { | ||||
const TxId txid(inv.hash); | const TxId txid(inv.hash); | ||||
const 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 " | ||||
"protocol, disconnecting peer=%d\n", | "protocol, disconnecting peer=%d\n", | ||||
txid.ToString(), pfrom.GetId()); | txid.ToString(), pfrom.GetId()); | ||||
pfrom.fDisconnect = true; | pfrom.fDisconnect = true; | ||||
return; | return; | ||||
} else if (!fAlreadyHave && !m_chainman.ActiveChainstate() | } else if (!fAlreadyHave && !m_chainman.ActiveChainstate() | ||||
.IsInitialBlockDownload()) { | .IsInitialBlockDownload()) { | ||||
RequestTx(State(pfrom.GetId()), txid, current_time); | RequestTx(State(pfrom.GetId()), txid, current_time); | ||||
} | } | ||||
} else { | |||||
LogPrint(BCLog::NET, | |||||
"Unknown inv type \"%s\" received from peer=%d\n", | |||||
inv.ToString(), pfrom.GetId()); | |||||
} | } | ||||
} | } | ||||
if (best_block) { | if (best_block) { | ||||
m_connman.PushMessage( | m_connman.PushMessage( | ||||
&pfrom, | &pfrom, | ||||
msgMaker.Make(NetMsgType::GETHEADERS, | msgMaker.Make(NetMsgType::GETHEADERS, | ||||
::ChainActive().GetLocator(pindexBestHeader), | ::ChainActive().GetLocator(pindexBestHeader), | ||||
▲ Show 20 Lines • Show All 2,458 Lines • Show Last 20 Lines |