MultiversX Tracker is Live!

Shouldn't CChain::Next check if the given block is the tip block or not?

Bitcoin Stack Exchange

Bitcoin News / Bitcoin Stack Exchange 156 Views

bitcoin core development - Shouldn't CChain::Next check if the given block is the tip block or not? - Bitcoin Stack Exchange

Bitcoin Stack Exchange is a question and answer site for Bitcoin crypto-currency enthusiasts. It only takes a minute to sign up.

Sign up to join this community

Anybody can ask a question

Anybody can answer

The best answers are voted up and rise to the top

Asked

Viewed 49 times

This function here gives a pointer to a block, and return the succesor block of that pointer.

 /** Find the successor of a block in this chain, or nullptr if the given index is not found or is the tip. */ CBlockIndex* Next(const CBlockIndex* pindex) const { if (Contains(pindex)) return (*this)[pindex->nHeight + 1]; else return nullptr; }

If the given block is containing in the chain, it attempt to return the successor. So if the Chain.Tip() is given, it tries to reach the successor while there is no successor of the tip block. Isn't it better to check if nHeight of the given block is less than the Chain.Tip().nHeight - 1 or not?


Get BONUS $200 for FREE!

You can get bonuses upto $100 FREE BONUS when you:
πŸ’° Install these recommended apps:
πŸ’² SocialGood - 100% Crypto Back on Everyday Shopping
πŸ’² xPortal - The DeFi For The Next Billion
πŸ’² CryptoTab Browser - Lightweight, fast, and ready to mine!
πŸ’° Register on these recommended exchanges:
🟑 Binance🟑 Bitfinex🟑 Bitmart🟑 Bittrex🟑 Bitget
🟑 CoinEx🟑 Crypto.com🟑 Gate.io🟑 Huobi🟑 Kucoin.



Comments