Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 1,454 Lines • ▼ Show 20 Lines | switch (inv.type) { | ||||
} | } | ||||
case MSG_BLOCK: | case MSG_BLOCK: | ||||
return LookupBlockIndex(BlockHash(inv.hash)) != nullptr; | return LookupBlockIndex(BlockHash(inv.hash)) != nullptr; | ||||
} | } | ||||
// Don't know what it is, just say we already got one | // Don't know what it is, just say we already got one | ||||
return true; | return true; | ||||
} | } | ||||
static void RelayTransaction(const CTransaction &tx, CConnman *connman) { | void RelayTransaction(const TxId &txid, const CConnman &connman) { | ||||
CInv inv(MSG_TX, tx.GetId()); | CInv inv(MSG_TX, txid); | ||||
connman->ForEachNode([&inv](CNode *pnode) { pnode->PushInventory(inv); }); | connman.ForEachNode([&inv](CNode *pnode) { pnode->PushInventory(inv); }); | ||||
} | } | ||||
static void RelayAddress(const CAddress &addr, bool fReachable, | static void RelayAddress(const CAddress &addr, bool fReachable, | ||||
CConnman *connman) { | CConnman *connman) { | ||||
// Limited relaying of addresses outside our network(s) | // Limited relaying of addresses outside our network(s) | ||||
unsigned int nRelayNodes = fReachable ? 2 : 1; | unsigned int nRelayNodes = fReachable ? 2 : 1; | ||||
// Relay to a limited number of other nodes. | // Relay to a limited number of other nodes. | ||||
▲ Show 20 Lines • Show All 610 Lines • ▼ Show 20 Lines | while (!done && !orphan_work_set.empty()) { | ||||
continue; | continue; | ||||
} | } | ||||
if (AcceptToMemoryPool(config, g_mempool, stateDummy, porphanTx, | if (AcceptToMemoryPool(config, g_mempool, stateDummy, porphanTx, | ||||
&fMissingInputs2, false /* bypass_limits */, | &fMissingInputs2, false /* bypass_limits */, | ||||
Amount::zero() /* nAbsurdFee */)) { | Amount::zero() /* nAbsurdFee */)) { | ||||
LogPrint(BCLog::MEMPOOL, " accepted orphan tx %s\n", | LogPrint(BCLog::MEMPOOL, " accepted orphan tx %s\n", | ||||
orphanTxId.ToString()); | orphanTxId.ToString()); | ||||
RelayTransaction(orphanTx, connman); | RelayTransaction(orphanTxId, *connman); | ||||
for (size_t i = 0; i < orphanTx.vout.size(); i++) { | for (size_t i = 0; i < orphanTx.vout.size(); i++) { | ||||
auto it_by_prev = | auto it_by_prev = | ||||
mapOrphanTransactionsByPrev.find(COutPoint(orphanTxId, i)); | mapOrphanTransactionsByPrev.find(COutPoint(orphanTxId, i)); | ||||
if (it_by_prev != mapOrphanTransactionsByPrev.end()) { | if (it_by_prev != mapOrphanTransactionsByPrev.end()) { | ||||
for (const auto &elem : it_by_prev->second) { | for (const auto &elem : it_by_prev->second) { | ||||
orphan_work_set.insert(elem->first); | orphan_work_set.insert(elem->first); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 776 Lines • ▼ Show 20 Lines | if (strCommand == NetMsgType::TX) { | ||||
nodestate->m_tx_download.m_tx_in_flight.erase(txid); | nodestate->m_tx_download.m_tx_in_flight.erase(txid); | ||||
EraseTxRequest(txid); | EraseTxRequest(txid); | ||||
if (!AlreadyHave(inv) && | if (!AlreadyHave(inv) && | ||||
AcceptToMemoryPool(config, g_mempool, state, ptx, &fMissingInputs, | AcceptToMemoryPool(config, g_mempool, state, ptx, &fMissingInputs, | ||||
false /* bypass_limits */, | false /* bypass_limits */, | ||||
Amount::zero() /* nAbsurdFee */)) { | Amount::zero() /* nAbsurdFee */)) { | ||||
g_mempool.check(pcoinsTip.get()); | g_mempool.check(pcoinsTip.get()); | ||||
RelayTransaction(tx, connman); | RelayTransaction(tx.GetId(), *connman); | ||||
for (size_t i = 0; i < tx.vout.size(); i++) { | for (size_t i = 0; i < tx.vout.size(); i++) { | ||||
auto it_by_prev = | auto it_by_prev = | ||||
mapOrphanTransactionsByPrev.find(COutPoint(txid, i)); | mapOrphanTransactionsByPrev.find(COutPoint(txid, i)); | ||||
if (it_by_prev != mapOrphanTransactionsByPrev.end()) { | if (it_by_prev != mapOrphanTransactionsByPrev.end()) { | ||||
for (const auto &elem : it_by_prev->second) { | for (const auto &elem : it_by_prev->second) { | ||||
pfrom->orphan_work_set.insert(elem->first); | pfrom->orphan_work_set.insert(elem->first); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | if (strCommand == NetMsgType::TX) { | ||||
// | // | ||||
// Never relay transactions that we would assign a non-zero DoS | // Never relay transactions that we would assign a non-zero DoS | ||||
// score for, as we expect peers to do the same with us in that | // score for, as we expect peers to do the same with us in that | ||||
// case. | // case. | ||||
int nDoS = 0; | int nDoS = 0; | ||||
if (!state.IsInvalid(nDoS) || nDoS == 0) { | if (!state.IsInvalid(nDoS) || nDoS == 0) { | ||||
LogPrintf("Force relaying tx %s from whitelisted peer=%d\n", | LogPrintf("Force relaying tx %s from whitelisted peer=%d\n", | ||||
tx.GetId().ToString(), pfrom->GetId()); | tx.GetId().ToString(), pfrom->GetId()); | ||||
RelayTransaction(tx, connman); | RelayTransaction(tx.GetId(), *connman); | ||||
} else { | } else { | ||||
LogPrintf("Not relaying invalid transaction %s from " | LogPrintf("Not relaying invalid transaction %s from " | ||||
"whitelisted peer=%d (%s)\n", | "whitelisted peer=%d (%s)\n", | ||||
tx.GetId().ToString(), pfrom->GetId(), | tx.GetId().ToString(), pfrom->GetId(), | ||||
FormatStateMessage(state)); | FormatStateMessage(state)); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,920 Lines • Show Last 20 Lines |