The chainActive variable stores the best known block chain. But this is essentially just the chain of block headers, not the actual blocks themselves. To load the actual block from disk, use the ReadBlockFromDisk() function. But, be aware that this is an expensive function to use, it does not return immediately.
chainActive[0]
or chainActive.Genesis()
[1]
Gives the genesis block header.
chainActive[chainActive.Height()]
or chainActive.Tip()
[2]
Gives the header for the most recent block in the active chain.
chainActive[chainActive.Height()-10]
Gives the block header for the block with 10 blocks built on top of it.
Use any of these CBlockIndex pointers as below to get the block.
CBlock block;
if (ReadBlockFromDisk(block, pindex)) { // do something
}
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