Crates.io | melblkidx |
lib.rs | melblkidx |
version | 0.7.4 |
source | src |
created_at | 2022-07-10 22:47:49.577161 |
updated_at | 2023-03-28 01:35:48.656859 |
description | Block indexer for Themelio |
homepage | |
repository | https://github.com/themeliolabs/melblkidx |
max_upload_size | |
id | 623444 |
size | 106,346 |
The block indexer pulls blocks from the network one by one using a Client
and indexes them.
coins
tableThe main data structure is a SQLite table that tracks the state of all coins seen with the following columns:
create_txhash
: hash of the creating transactioncreate_index
: index at the creating transaction (e.g. which output was it)create_height
: height of the creating transactionspend_txhash
: hash of the spending transactionspend_index
: index at the spending transaction (e.g. which input was it)spend_height
: height of the spending transactionvalue
: value being spent (big-endian blob)denom
: denomination (blob)covhash
: address (string)additional_data
: (blob)The spending information is denormalized into this table to improve the performance of e.g. balance queries ("which coins were created")
"Tricky" cases (Melswap transactions, mostly) are handled by actually asking for more information from the network, rather than by reimplementating all the nuances of the state transition function. This is a big reason why we use a pull-based rather than an I/O-free, push-based API.
headvars
tableheight
blkhash
fee_pool
fee_multiplier
dosc_speed
stakes
tablestores all stakedocs ever, which is all we really need
txhash
pubkey
e_start
e_post_end
staked
txvars
tabletxhash
kind
fee
covenants
(JSON)data
sigs
(JSON)// iterator over all coins with value above 100 µMEL
let i: impl Iterator<Item = CoinInfo> =
indexer.query_coins()
.value_range(CoinValue(100)..)
.denom(Denom::Mel)
.iter()
pub struct CoinInfo {
pub create_txhash: TxHash,
pub create_index: u8,
pub create_height: BlockHeight,
pub coin_data: CoinData,
pub spend_info: Option<CoinSpendInfo>
}
pub struct CoinSpendInfo {
pub spend_txhash: TxHash,
pub spend_index: u8,
pub spend_height: BlockHeight
}