Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 5,381 Lines • ▼ Show 20 Lines | if (!vInv.empty()) { | ||||
if (State(staller)->nStallingSince == 0) { | if (State(staller)->nStallingSince == 0) { | ||||
State(staller)->nStallingSince = | State(staller)->nStallingSince = | ||||
count_microseconds(current_time); | count_microseconds(current_time); | ||||
LogPrint(BCLog::NET, "Stall started peer=%d\n", staller); | LogPrint(BCLog::NET, "Stall started peer=%d\n", staller); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
auto addGetDataAndMaybeFlush = [&](uint32_t type, const uint256 &hash) { | |||||
CInv inv(type, hash); | |||||
LogPrint(BCLog::NET, "Requesting %s from peer=%d\n", inv.ToString(), | |||||
pto->GetId()); | |||||
vGetData.push_back(std::move(inv)); | |||||
if (vGetData.size() >= MAX_GETDATA_SZ) { | |||||
m_connman.PushMessage(pto, msgMaker.Make(NetMsgType::GETDATA, | |||||
std::move(vGetData))); | |||||
vGetData.clear(); | |||||
} | |||||
}; | |||||
// | // | ||||
// Message: getdata (transactions) | // Message: getdata (transactions) | ||||
// | // | ||||
std::vector<std::pair<NodeId, TxId>> expired; | std::vector<std::pair<NodeId, TxId>> expired; | ||||
auto requestable = | auto requestable = | ||||
m_txrequest.GetRequestable(pto->GetId(), current_time, &expired); | m_txrequest.GetRequestable(pto->GetId(), current_time, &expired); | ||||
for (const auto &entry : expired) { | for (const auto &entry : expired) { | ||||
LogPrint(BCLog::NET, "timeout of inflight tx %s from peer=%d\n", | LogPrint(BCLog::NET, "timeout of inflight tx %s from peer=%d\n", | ||||
entry.second.ToString(), entry.first); | entry.second.ToString(), entry.first); | ||||
} | } | ||||
for (const TxId &txid : requestable) { | for (const TxId &txid : requestable) { | ||||
if (!AlreadyHaveTx(txid, m_mempool)) { | if (!AlreadyHaveTx(txid, m_mempool)) { | ||||
LogPrint(BCLog::NET, "Requesting tx %s peer=%d\n", | addGetDataAndMaybeFlush(MSG_TX, txid); | ||||
txid.ToString(), pto->GetId()); | |||||
vGetData.emplace_back(MSG_TX, txid); | |||||
if (vGetData.size() >= MAX_GETDATA_SZ) { | |||||
m_connman.PushMessage( | |||||
pto, msgMaker.Make(NetMsgType::GETDATA, vGetData)); | |||||
vGetData.clear(); | |||||
} | |||||
m_txrequest.RequestedTx(pto->GetId(), txid, | m_txrequest.RequestedTx(pto->GetId(), txid, | ||||
current_time + GETDATA_TX_INTERVAL); | current_time + GETDATA_TX_INTERVAL); | ||||
} else { | } else { | ||||
// We have already seen this transaction, no need to download. | // We have already seen this transaction, no need to download. | ||||
// This is just a belt-and-suspenders, as this should already be | // This is just a belt-and-suspenders, as this should already be | ||||
// called whenever a transaction becomes AlreadyHaveTx(). | // called whenever a transaction becomes AlreadyHaveTx(). | ||||
m_txrequest.ForgetTxId(txid); | m_txrequest.ForgetTxId(txid); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines |