Check whether the last unknown block a peer advertized is not yet known. */
| 339 | |
| 340 | /** Check whether the last unknown block a peer advertized is not yet known. */ |
| 341 | static void ProcessBlockAvailability(NodeStatePtr& state) { |
| 342 | AssertLockHeld(cs_main); |
| 343 | |
| 344 | if (!state->hashLastUnknownBlock.IsNull()) { |
| 345 | BlockMap::iterator itOld = mapBlockIndex.find(state->hashLastUnknownBlock); |
| 346 | if (itOld != mapBlockIndex.end() && itOld->second->nChainWork > 0) { |
| 347 | if (state->pindexBestKnownBlock == NULL || itOld->second->nChainWork >= state->pindexBestKnownBlock->nChainWork) |
| 348 | state->pindexBestKnownBlock = itOld->second; |
| 349 | state->hashLastUnknownBlock.SetNull(); |
| 350 | } |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | /** Find the last common ancestor two blocks have. |
| 355 | * Both pa and pb must be non-NULL. */ |
no test coverage detected