Expand description
Β§Bitcoin Syncer
This module provides common utilities to fetch Bitcoin state. Other modules
can use this module to operate over Bitcoin. Every block starting from
paramset.start_height is fetched and stored in the database.
StructsΒ§
- Bitcoin
Syncer - Bitcoin
Syncer Task - A task that syncs Bitcoin blocks from the Bitcoin node to the local database.
- Block
Info π - Represents basic information of a Bitcoin block.
- Finalized
Block Fetcher Task
EnumsΒ§
- Bitcoin
Syncer Event - Events emitted by the Bitcoin syncer. It emits the block_id of the block in the db that was saved.
ConstantsΒ§
TraitsΒ§
- Block
Handler - Trait for handling new blocks as they are finalized
FunctionsΒ§
- _get_
block_ πinfo_ from_ hash - _get_
transaction_ πspent_ utxos - fetch_
block_ πinfo_ from_ height - Fetches the
BlockInfofor a given height from Bitcoin. - fetch_
new_ πblocks - Fetches the next block from Bitcoin, if it exists. Will also fetch previous blocks if the parent is missing, and give an error if the number of reorged blocks is greater than the finality depth.
- handle_
reorg_ πevents - Marks blocks above the common ancestor as non-canonical and emits reorg events.
- process_
new_ πblocks - Processes and inserts new blocks into the database, emitting a new block event for each.
- save_
block π - Saves a Bitcoin blockβs metadata and itβs transactions into the database.
- save_
transaction_ πspent_ utxos - Saves a Bitcoin transaction and its spent UTXOs to the database.
- set_
initial_ block_ info_ if_ not_ exists - If no block info exists in the DB, fetches the current block from the RPC and initializes the DB.