MCPcopy Create free account
hub / github.com/ElementsProject/elements / RemoveBlockRequest

Method RemoveBlockRequest

src/net_processing.cpp:856–887  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

854}
855
856void PeerManagerImpl::RemoveBlockRequest(const uint256& hash, std::optional<NodeId> from_peer)
857{
858 auto it = mapBlocksInFlight.find(hash);
859 if (it == mapBlocksInFlight.end()) {
860 // Block was not requested
861 return;
862 }
863
864 auto [node_id, list_it] = it->second;
865
866 if (from_peer && node_id != *from_peer) {
867 // Block was requested by another peer
868 return;
869 }
870
871 CNodeState *state = State(node_id);
872 assert(state != nullptr);
873
874 if (state->vBlocksInFlight.begin() == list_it) {
875 // First block on the queue was received, update the start download time for the next one
876 state->m_downloading_since = std::max(state->m_downloading_since, GetTime<std::chrono::microseconds>());
877 }
878 state->vBlocksInFlight.erase(list_it);
879
880 state->nBlocksInFlight--;
881 if (state->nBlocksInFlight == 0) {
882 // Last validated block on the queue was received.
883 m_peers_downloading_from--;
884 }
885 state->m_stalling_since = 0us;
886 mapBlocksInFlight.erase(it);
887}
888
889bool PeerManagerImpl::BlockRequested(NodeId nodeid, const CBlockIndex& block, std::list<QueuedBlock>::iterator** pit)
890{

Callers

nothing calls this directly

Calls 5

findMethod · 0.80
StateEnum · 0.70
endMethod · 0.45
beginMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected