MCPcopy Create free account
hub / github.com/LUX-Core/lux / UpdateBlockAvailability

Function UpdateBlockAvailability

src/main.cpp:442–458  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

440
441/** Update tracking information about which blocks a peer is assumed to have. */
442void UpdateBlockAvailability(NodeId nodeid, const uint256& hash)
443{
444 CNodeState* state = State(nodeid);
445 assert(state != NULL);
446
447 ProcessBlockAvailability(nodeid);
448
449 CBlockIndex* pindex = LookupBlockIndex(hash);
450 if (pindex && pindex->nChainWork > 0) {
451 // An actually better block was announced.
452 if (state->pindexBestKnownBlock == NULL || pindex->nChainWork >= state->pindexBestKnownBlock->nChainWork)
453 state->pindexBestKnownBlock = pindex;
454 } else {
455 // An unknown block was announced; just assume that the latest one is the best one.
456 state->hashLastUnknownBlock = hash;
457 }
458}
459
460/** Find the last common ancestor two blocks have.
461 * Both pa and pb must be non-NULL. */

Callers 1

ProcessMessageFunction · 0.85

Calls 3

ProcessBlockAvailabilityFunction · 0.85
LookupBlockIndexFunction · 0.85
StateFunction · 0.70

Tested by

no test coverage detected