Find the last common ancestor two blocks have. * Both pa and pb must be non-NULL. */
| 460 | /** Find the last common ancestor two blocks have. |
| 461 | * Both pa and pb must be non-NULL. */ |
| 462 | CBlockIndex* LastCommonAncestor(CBlockIndex* pa, CBlockIndex* pb) |
| 463 | { |
| 464 | if (pa->nHeight > pb->nHeight) { |
| 465 | pa = pa->GetAncestor(pb->nHeight); |
| 466 | } else if (pb->nHeight > pa->nHeight) { |
| 467 | pb = pb->GetAncestor(pa->nHeight); |
| 468 | } |
| 469 | |
| 470 | while (pa != pb && pa && pb) { |
| 471 | pa = pa->pprev; |
| 472 | pb = pb->pprev; |
| 473 | } |
| 474 | |
| 475 | // Eventually all chain branches meet at the genesis block. |
| 476 | assert(pa == pb); |
| 477 | return pa; |
| 478 | } |
| 479 | |
| 480 | /** Update pindexLastCommonBlock and add not-in-flight missing successors to vBlocks, until it has |
| 481 | * at most count entries. */ |
no test coverage detected