@@ -2618,54 +2618,6 @@ static bool IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned
26182618 return (nFound >= nRequired);
26192619}
26202620
2621- /* * Turn the lowest '1' bit in the binary representation of a number into a '0'. */
2622- int static inline InvertLowestOne (int n) { return n & (n - 1 ); }
2623-
2624- /* * Compute what height to jump back to with the CBlockIndex::pskip pointer. */
2625- int static inline GetSkipHeight (int height) {
2626- if (height < 2 )
2627- return 0 ;
2628-
2629- // Determine which height to jump back to. Any number strictly lower than height is acceptable,
2630- // but the following expression seems to perform well in simulations (max 110 steps to go back
2631- // up to 2**18 blocks).
2632- return (height & 1 ) ? InvertLowestOne (InvertLowestOne (height - 1 )) + 1 : InvertLowestOne (height);
2633- }
2634-
2635- CBlockIndex* CBlockIndex::GetAncestor (int height)
2636- {
2637- if (height > nHeight || height < 0 )
2638- return NULL ;
2639-
2640- CBlockIndex* pindexWalk = this ;
2641- int heightWalk = nHeight;
2642- while (heightWalk > height) {
2643- int heightSkip = GetSkipHeight (heightWalk);
2644- int heightSkipPrev = GetSkipHeight (heightWalk - 1 );
2645- if (heightSkip == height ||
2646- (heightSkip > height && !(heightSkipPrev < heightSkip - 2 &&
2647- heightSkipPrev >= height))) {
2648- // Only follow pskip if pprev->pskip isn't better than pskip->pprev.
2649- pindexWalk = pindexWalk->pskip ;
2650- heightWalk = heightSkip;
2651- } else {
2652- pindexWalk = pindexWalk->pprev ;
2653- heightWalk--;
2654- }
2655- }
2656- return pindexWalk;
2657- }
2658-
2659- const CBlockIndex* CBlockIndex::GetAncestor (int height) const
2660- {
2661- return const_cast <CBlockIndex*>(this )->GetAncestor (height);
2662- }
2663-
2664- void CBlockIndex::BuildSkip ()
2665- {
2666- if (pprev)
2667- pskip = pprev->GetAncestor (GetSkipHeight (nHeight));
2668- }
26692621
26702622bool ProcessNewBlock (CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBlockPos *dbp)
26712623{
0 commit comments