| 1385 | } |
| 1386 | |
| 1387 | void PeerManagerImpl::UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) { |
| 1388 | CNodeState *state = State(nodeid); |
| 1389 | assert(state != nullptr); |
| 1390 | |
| 1391 | ProcessBlockAvailability(nodeid); |
| 1392 | |
| 1393 | const CBlockIndex* pindex = m_chainman.m_blockman.LookupBlockIndex(hash); |
| 1394 | if (pindex && pindex->nChainWork > 0) { |
| 1395 | // An actually better block was announced. |
| 1396 | if (state->pindexBestKnownBlock == nullptr || pindex->nChainWork >= state->pindexBestKnownBlock->nChainWork) { |
| 1397 | state->pindexBestKnownBlock = pindex; |
| 1398 | } |
| 1399 | } else { |
| 1400 | // An unknown block was announced; just assume that the latest one is the best one. |
| 1401 | state->hashLastUnknownBlock = hash; |
| 1402 | } |
| 1403 | } |
| 1404 | |
| 1405 | // Logic for calculating which blocks to download from a given peer, given our current tip. |
| 1406 | void PeerManagerImpl::FindNextBlocksToDownload(const Peer& peer, unsigned int count, std::vector<const CBlockIndex*>& vBlocks, NodeId& nodeStaller) |
nothing calls this directly
no test coverage detected