mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-25 07:09:59 -07:00
crates: snapshot
This commit is contained in:
@@ -17,6 +17,7 @@ impl Query {
|
||||
|
||||
let mut fees = computer
|
||||
.chain
|
||||
.transaction
|
||||
.indexes_to_fee
|
||||
.sats
|
||||
.dateindex
|
||||
|
||||
@@ -18,6 +18,7 @@ impl Query {
|
||||
// coinbase = subsidy + fees
|
||||
let mut rewards = computer
|
||||
.chain
|
||||
.coinbase
|
||||
.indexes_to_coinbase
|
||||
.sats
|
||||
.dateindex
|
||||
|
||||
@@ -17,12 +17,14 @@ impl Query {
|
||||
|
||||
let mut sizes_vec = computer
|
||||
.chain
|
||||
.block
|
||||
.indexes_to_block_size
|
||||
.dateindex
|
||||
.unwrap_average()
|
||||
.iter();
|
||||
let mut weights_vec = computer
|
||||
.chain
|
||||
.block
|
||||
.indexes_to_block_weight
|
||||
.dateindex
|
||||
.unwrap_average()
|
||||
|
||||
@@ -14,11 +14,13 @@ impl<'a> DateIndexIter<'a> {
|
||||
pub fn new(computer: &'a Computer, start_height: usize, end_height: usize) -> Self {
|
||||
let start_di = computer
|
||||
.indexes
|
||||
.block
|
||||
.height_to_dateindex
|
||||
.read_once(Height::from(start_height))
|
||||
.unwrap_or_default();
|
||||
let end_di = computer
|
||||
.indexes
|
||||
.block
|
||||
.height_to_dateindex
|
||||
.read_once(Height::from(end_height))
|
||||
.unwrap_or_default();
|
||||
@@ -47,12 +49,13 @@ impl<'a> DateIndexIter<'a> {
|
||||
let mut timestamps = self
|
||||
.computer
|
||||
.chain
|
||||
.epoch
|
||||
.timeindexes_to_timestamp
|
||||
.dateindex
|
||||
.as_ref()
|
||||
.expect("timeindexes_to_timestamp.dateindex should exist")
|
||||
.iter();
|
||||
let mut heights = self.computer.indexes.dateindex_to_first_height.iter();
|
||||
let mut heights = self.computer.indexes.time.dateindex_to_first_height.iter();
|
||||
|
||||
let mut entries = Vec::with_capacity(total / self.step + 1);
|
||||
let mut i = self.start_di.to_usize();
|
||||
|
||||
@@ -22,6 +22,7 @@ impl Query {
|
||||
// Get current epoch
|
||||
let current_epoch = computer
|
||||
.indexes
|
||||
.block
|
||||
.height_to_difficultyepoch
|
||||
.read_once(current_height)?;
|
||||
let current_epoch_usize: usize = current_epoch.into();
|
||||
@@ -29,6 +30,7 @@ impl Query {
|
||||
// Get epoch start height
|
||||
let epoch_start_height = computer
|
||||
.indexes
|
||||
.block
|
||||
.difficultyepoch_to_first_height
|
||||
.read_once(current_epoch)?;
|
||||
let epoch_start_u32: u32 = epoch_start_height.into();
|
||||
@@ -42,6 +44,7 @@ impl Query {
|
||||
// Get timestamps using difficultyepoch_to_timestamp for epoch start
|
||||
let epoch_start_timestamp = computer
|
||||
.chain
|
||||
.epoch
|
||||
.difficultyepoch_to_timestamp
|
||||
.read_once(current_epoch)?;
|
||||
let current_timestamp = indexer
|
||||
@@ -82,6 +85,7 @@ impl Query {
|
||||
let prev_epoch = DifficultyEpoch::from(current_epoch_usize - 1);
|
||||
let prev_epoch_start = computer
|
||||
.indexes
|
||||
.block
|
||||
.difficultyepoch_to_first_height
|
||||
.read_once(prev_epoch)?;
|
||||
|
||||
|
||||
@@ -10,19 +10,22 @@ pub fn iter_difficulty_epochs(
|
||||
) -> Vec<DifficultyAdjustmentEntry> {
|
||||
let start_epoch = computer
|
||||
.indexes
|
||||
.block
|
||||
.height_to_difficultyepoch
|
||||
.read_once(Height::from(start_height))
|
||||
.unwrap_or_default();
|
||||
let end_epoch = computer
|
||||
.indexes
|
||||
.block
|
||||
.height_to_difficultyepoch
|
||||
.read_once(Height::from(end_height))
|
||||
.unwrap_or_default();
|
||||
|
||||
let mut epoch_to_height_iter = computer.indexes.difficultyepoch_to_first_height.iter();
|
||||
let mut epoch_to_timestamp_iter = computer.chain.difficultyepoch_to_timestamp.iter();
|
||||
let mut epoch_to_height_iter = computer.indexes.block.difficultyepoch_to_first_height.iter();
|
||||
let mut epoch_to_timestamp_iter = computer.chain.epoch.difficultyepoch_to_timestamp.iter();
|
||||
let mut epoch_to_difficulty_iter = computer
|
||||
.chain
|
||||
.mining
|
||||
.indexes_to_difficulty
|
||||
.difficultyepoch
|
||||
.unwrap_last()
|
||||
|
||||
@@ -21,11 +21,13 @@ impl Query {
|
||||
// Get current hashrate
|
||||
let current_dateindex = computer
|
||||
.indexes
|
||||
.block
|
||||
.height_to_dateindex
|
||||
.read_once(current_height)?;
|
||||
|
||||
let current_hashrate = *computer
|
||||
.chain
|
||||
.mining
|
||||
.indexes_to_hash_rate
|
||||
.dateindex
|
||||
.unwrap_last()
|
||||
@@ -41,6 +43,7 @@ impl Query {
|
||||
// Get hashrate entries using iterators for efficiency
|
||||
let start_dateindex = computer
|
||||
.indexes
|
||||
.block
|
||||
.height_to_dateindex
|
||||
.read_once(Height::from(start))?;
|
||||
let end_dateindex = current_dateindex;
|
||||
@@ -55,6 +58,7 @@ impl Query {
|
||||
// Create iterators for the loop
|
||||
let mut hashrate_iter = computer
|
||||
.chain
|
||||
.mining
|
||||
.indexes_to_hash_rate
|
||||
.dateindex
|
||||
.unwrap_last()
|
||||
@@ -62,6 +66,7 @@ impl Query {
|
||||
|
||||
let mut timestamp_iter = computer
|
||||
.chain
|
||||
.epoch
|
||||
.timeindexes_to_timestamp
|
||||
.dateindex
|
||||
.as_ref()
|
||||
|
||||
@@ -14,6 +14,7 @@ impl Query {
|
||||
|
||||
let mut coinbase_iter = computer
|
||||
.chain
|
||||
.coinbase
|
||||
.indexes_to_coinbase
|
||||
.sats
|
||||
.height
|
||||
@@ -22,6 +23,7 @@ impl Query {
|
||||
.iter();
|
||||
let mut fee_iter = computer
|
||||
.chain
|
||||
.transaction
|
||||
.indexes_to_fee
|
||||
.sats
|
||||
.height
|
||||
@@ -29,6 +31,7 @@ impl Query {
|
||||
.iter();
|
||||
let mut tx_count_iter = computer
|
||||
.chain
|
||||
.transaction
|
||||
.indexes_to_tx_count
|
||||
.height
|
||||
.as_ref()
|
||||
|
||||
Reference in New Issue
Block a user