MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / RemoveBlockRequest

Method RemoveBlockRequest

src/net_processing.cpp:1211–1246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1209}
1210
1211void PeerManagerImpl::RemoveBlockRequest(const uint256& hash, std::optional<NodeId> from_peer)
1212{
1213 auto range = mapBlocksInFlight.equal_range(hash);
1214 if (range.first == range.second) {
1215 // Block was not requested from any peer
1216 return;
1217 }
1218
1219 // We should not have requested too many of this block
1220 Assume(mapBlocksInFlight.count(hash) <= MAX_CMPCTBLOCKS_INFLIGHT_PER_BLOCK);
1221
1222 while (range.first != range.second) {
1223 const auto& [node_id, list_it]{range.first->second};
1224
1225 if (from_peer && *from_peer != node_id) {
1226 range.first++;
1227 continue;
1228 }
1229
1230 CNodeState& state = *Assert(State(node_id));
1231
1232 if (state.vBlocksInFlight.begin() == list_it) {
1233 // First block on the queue was received, update the start download time for the next one
1234 state.m_downloading_since = std::max(state.m_downloading_since, GetTime<std::chrono::microseconds>());
1235 }
1236 state.vBlocksInFlight.erase(list_it);
1237
1238 if (state.vBlocksInFlight.empty()) {
1239 // Last validated block on the queue for this peer was received.
1240 m_peers_downloading_from--;
1241 }
1242 state.m_stalling_since = 0us;
1243
1244 range.first = mapBlocksInFlight.erase(range.first);
1245 }
1246}
1247
1248bool PeerManagerImpl::BlockRequested(NodeId nodeid, const CBlockIndex& block, std::list<QueuedBlock>::iterator** pit)
1249{

Callers

nothing calls this directly

Calls 5

countMethod · 0.80
StateEnum · 0.70
beginMethod · 0.45
eraseMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected