MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / UpdateBlockAvailability

Function UpdateBlockAvailability

src/main.cpp:463–479  ·  view source on GitHub ↗

Update tracking information about which blocks a peer is assumed to have. */

Source from the content-addressed store, hash-verified

461
462/** Update tracking information about which blocks a peer is assumed to have. */
463void 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
481void OnBlockFinished::operator()(const CBlock& block, const std::vector<NodeId>& ids) {
482 AssertLockHeld(cs_main);

Callers 3

operator()Method · 0.85
requestConnectHeadersMethod · 0.85

Calls 4

ProcessBlockAvailabilityFunction · 0.85
findMethod · 0.80
IsNullMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected