Update tracking information about which blocks a peer is assumed to have. */
| 461 | |
| 462 | /** Update tracking information about which blocks a peer is assumed to have. */ |
| 463 | void UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) { |
| 464 | AssertLockHeld(cs_main); |
| 465 | NodeStatePtr state(nodeid); |
| 466 | assert(!state.IsNull()); |
| 467 | |
| 468 | ProcessBlockAvailability(state); |
| 469 | |
| 470 | BlockMap::iterator it = mapBlockIndex.find(hash); |
| 471 | if (it != mapBlockIndex.end() && it->second->nChainWork > 0) { |
| 472 | // An actually better block was announced. |
| 473 | if (state->pindexBestKnownBlock == NULL || it->second->nChainWork >= state->pindexBestKnownBlock->nChainWork) |
| 474 | state->pindexBestKnownBlock = it->second; |
| 475 | } else { |
| 476 | // An unknown block was announced; just assume that the latest one is the best one. |
| 477 | state->hashLastUnknownBlock = hash; |
| 478 | } |
| 479 | } |
| 480 | |
| 481 | void OnBlockFinished::operator()(const CBlock& block, const std::vector<NodeId>& ids) { |
| 482 | AssertLockHeld(cs_main); |
no test coverage detected