Hi. Is anyone here, who can explain what exactly is happening in the
priv_fastGetBlockHash__ functions in btcChain.se? I understand the idea of the indexing of block ancestors but I'm concerned about the exact details of the implementation.
Specifically, this code block in
with $i = 1: while $i < NUM_ANCESTOR_DEPTHS: with $depth = m_getAncDepth($i): if m_getHeight($blockHash) % $depth == 1: m_mwrite32(ref($ancWord) + 4*$i, $prevIbIndex) else: m_mwrite32(ref($ancWord) + 4*$i, m_getAncestor($hashPrevBlock, $i)) $i += 1
Also, could it be, that
priv_fastGetBlockHash__ fails if the requested block has more than 78125 confirmations? I may be wrong, but it seems to me that the following check will fail in this case:
blockHash = self.heaviestBlock anc_index = NUM_ANCESTOR_DEPTHS - 1 <-- this is equal to 7 while m_getHeight(blockHash) > blockHeight: while m_getHeight(blockHash) - blockHeight < m_getAncDepth(anc_index) && anc_index > 0: anc_index -= 1 blockHash = self.internalBlock[m_getAncestor(blockHash, anc_index)] return(blockHash)
m_getAncDepth(7) returns 78125