Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 3,651 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::TX) { | ||||
// about any requests for it. | // about any requests for it. | ||||
m_txrequest.ForgetInvId(tx.GetId()); | m_txrequest.ForgetInvId(tx.GetId()); | ||||
RelayTransaction(tx.GetId(), m_connman); | RelayTransaction(tx.GetId(), m_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.m_orphan_work_set.insert(elem->first); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
pfrom.nLastTXTime = GetTime(); | pfrom.nLastTXTime = GetTime(); | ||||
LogPrint(BCLog::MEMPOOL, | LogPrint(BCLog::MEMPOOL, | ||||
"AcceptToMemoryPool: peer=%d: accepted %s " | "AcceptToMemoryPool: peer=%d: accepted %s " | ||||
"(poolsz %u txn, %u kB)\n", | "(poolsz %u txn, %u kB)\n", | ||||
pfrom.GetId(), tx.GetId().ToString(), m_mempool.size(), | pfrom.GetId(), tx.GetId().ToString(), m_mempool.size(), | ||||
m_mempool.DynamicMemoryUsage() / 1000); | m_mempool.DynamicMemoryUsage() / 1000); | ||||
// Recursively process any orphan transactions that depended on this | // Recursively process any orphan transactions that depended on this | ||||
// one | // one | ||||
ProcessOrphanTx(config, pfrom.orphan_work_set); | ProcessOrphanTx(config, pfrom.m_orphan_work_set); | ||||
} else if (state.GetResult() == TxValidationResult::TX_MISSING_INPUTS) { | } else if (state.GetResult() == TxValidationResult::TX_MISSING_INPUTS) { | ||||
// It may be the case that the orphans parents have all been | // It may be the case that the orphans parents have all been | ||||
// rejected. | // rejected. | ||||
bool fRejectedParents = false; | bool fRejectedParents = false; | ||||
// Deduplicate parent txids, so that we don't have to loop over | // Deduplicate parent txids, so that we don't have to loop over | ||||
// the same parent txid more than once down below. | // the same parent txid more than once down below. | ||||
std::vector<TxId> unique_parents; | std::vector<TxId> unique_parents; | ||||
▲ Show 20 Lines • Show All 1,155 Lines • ▼ Show 20 Lines | bool PeerManager::ProcessMessages(const Config &config, CNode *pfrom, | ||||
// (x) data | // (x) data | ||||
// | // | ||||
bool fMoreWork = false; | bool fMoreWork = false; | ||||
if (!pfrom->vRecvGetData.empty()) { | if (!pfrom->vRecvGetData.empty()) { | ||||
ProcessGetData(config, *pfrom, m_connman, m_mempool, interruptMsgProc); | ProcessGetData(config, *pfrom, m_connman, m_mempool, interruptMsgProc); | ||||
} | } | ||||
if (!pfrom->orphan_work_set.empty()) { | if (!pfrom->m_orphan_work_set.empty()) { | ||||
LOCK2(cs_main, g_cs_orphans); | LOCK2(cs_main, g_cs_orphans); | ||||
ProcessOrphanTx(config, pfrom->orphan_work_set); | ProcessOrphanTx(config, pfrom->m_orphan_work_set); | ||||
} | } | ||||
if (pfrom->fDisconnect) { | if (pfrom->fDisconnect) { | ||||
return false; | return false; | ||||
} | } | ||||
// this maintains the order of responses and prevents vRecvGetData from | // this maintains the order of responses and prevents vRecvGetData from | ||||
// growing unbounded | // growing unbounded | ||||
if (!pfrom->vRecvGetData.empty()) { | if (!pfrom->vRecvGetData.empty()) { | ||||
return true; | return true; | ||||
} | } | ||||
if (!pfrom->orphan_work_set.empty()) { | if (!pfrom->m_orphan_work_set.empty()) { | ||||
return true; | return true; | ||||
} | } | ||||
// Don't bother if send buffer is too full to respond anyway | // Don't bother if send buffer is too full to respond anyway | ||||
if (pfrom->fPauseSend) { | if (pfrom->fPauseSend) { | ||||
return false; | return false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,109 Lines • Show Last 20 Lines |