Crate blocks_iterator
source ·Expand description
Blocks Iterator
Read bitcoin blocks directory containing blocks*.dat
files, and produce a ordered stream
of BlockExtra
Blocks could be consumed in 2 different ways:
- Through the
iter()
method. - Via unix pipeline using the
PipeIterator
Re-exports
Structs
- The bitcoin block and additional metadata returned by the crate::iter() method
- Configuration parameters, most important the bitcoin blocks directory
- Before reorder we keep only the position of the block in the file system and data relative to the block hash, the previous hash and the following hash (populated during reorder phase) We will need to read the block from disk again, but by doing so we will avoid using too much memory in the
OutOfOrderBlocks
map. - Contains counter and instants to provide per period stats over transaction and blocks processed
- Utility used to return true after
period
- Iterator to use un Unix-style pipe composition when receiving BlockExtra from stdin and optionally propogating those to stdout
Functions
- Return an Iterator of
BlockExtra
read fromblocks*.dat
contained in theconfig.blocks_dir
Blocks returned are iterated in order, starting from the genesis to the highest block (minusconfig.max_reorg
) in the directory, unlessconfig.stop_at_height
is specified. - par_iterDeprecated
par_iter
is used when the task to be performed on the blockchain is more costly than iterating the blocks. For example verifying the spending conditions in the blockchain. like [crate::iter
] accepts configuration parameters via theConfig
struct. APREPROC
closure has to be provided, this process a single block and produce a Vec of user defined structDATA
. ATASK
closure accepts theDATA
struct and a sharedSTATE
and it is executed in a concurrent way. TheTASK
closure returns a bool which indicates if the execution should be terminated. Note that access toSTATE
inTASK
should be done carefully otherwise the contention would reduce the speed of execution. - periodic_log_levelDeprecatedUtility method usually returning log::Level::Debug but when
i
is divisible byevery
returns log::Level::Info