Module bitcoin_chain::blockchain
source · Expand description
Bitcoin Blockchain
This module provides the structures and functions to maintain the blockchain.
Structs
An iterator over blocks in blockheight order
The blockchain
A link in the blockchain
An iterator over blocks in reverse blockheight order. Note that this
is essentially the same as if we’d implemented
DoubleEndedIterator
on BlockIter
— but we can’t do that since if BlockIter
is started
off the main chain, it will not reach the best tip, so the iterator
and its .rev()
would be iterators over different chains! To avoid
this suprising behaviour we simply use separate iterators.An iterator over blocks in reverse blockheight order, which yielding only
stale blocks (ending at the point where it would’ve returned a block on
the main chain). It does this by checking if the
next
pointer of the
next-to-by-yielded block matches the currently-yielded block. If not, scan
forward from next-to-be-yielded block. If we hit the best tip, set the
next-to-by-yielded block to None instead.