global: big snapshot

This commit is contained in:
nym21
2026-01-09 20:00:20 +01:00
parent cb0abc324e
commit 426d7797a3
442 changed files with 17952 additions and 20071 deletions

View File

@@ -15,11 +15,10 @@ impl Query {
let iter = DateIndexIter::new(computer, start, current_height.to_usize());
// KISS: dateindex.average.0 is now a concrete field
let mut fees = computer
.transactions
.fees
.indexes_to_fee
.fee
.sats
.dateindex
.average

View File

@@ -15,12 +15,10 @@ impl Query {
let iter = DateIndexIter::new(computer, start, current_height.to_usize());
// coinbase = subsidy + fees
// KISS: dateindex.distribution.average.0 is now a concrete field
let mut rewards = computer
.blocks
.rewards
.indexes_to_coinbase
.coinbase
.sats
.dateindex
.distribution

View File

@@ -18,7 +18,7 @@ impl Query {
let mut sizes_vec = computer
.blocks
.size
.indexes_to_block_size
.size
.dateindex
.distribution
.average
@@ -27,7 +27,7 @@ impl Query {
let mut weights_vec = computer
.blocks
.weight
.indexes_to_block_weight
.weight
.dateindex
.distribution
.average

View File

@@ -14,14 +14,14 @@ 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
.height
.dateindex
.read_once(Height::from(start_height))
.unwrap_or_default();
let end_di = computer
.indexes
.block
.height_to_dateindex
.height
.dateindex
.read_once(Height::from(end_height))
.unwrap_or_default();
@@ -46,14 +46,8 @@ impl<'a> DateIndexIter<'a> {
.to_usize()
.saturating_sub(self.start_di.to_usize())
+ 1;
let mut timestamps = self
.computer
.blocks
.time
.timeindexes_to_timestamp
.dateindex
.iter();
let mut heights = self.computer.indexes.time.dateindex_to_first_height.iter();
let mut timestamps = self.computer.blocks.time.timestamp.dateindex.iter();
let mut heights = self.computer.indexes.dateindex.first_height.iter();
let mut entries = Vec::with_capacity(total / self.step + 1);
let mut i = self.start_di.to_usize();

View File

@@ -22,16 +22,16 @@ impl Query {
// Get current epoch
let current_epoch = computer
.indexes
.block
.height_to_difficultyepoch
.height
.difficultyepoch
.read_once(current_height)?;
let current_epoch_usize: usize = current_epoch.into();
// Get epoch start height
let epoch_start_height = computer
.indexes
.block
.difficultyepoch_to_first_height
.difficultyepoch
.first_height
.read_once(current_epoch)?;
let epoch_start_u32: u32 = epoch_start_height.into();
@@ -45,12 +45,13 @@ impl Query {
let epoch_start_timestamp = computer
.blocks
.time
.difficultyepoch_to_timestamp
.timestamp
.difficultyepoch
.read_once(current_epoch)?;
let current_timestamp = indexer
.vecs
.block
.height_to_timestamp
.blocks
.timestamp
.read_once(current_height)?;
// Calculate average block time in current epoch
@@ -85,19 +86,19 @@ impl Query {
let prev_epoch = DifficultyEpoch::from(current_epoch_usize - 1);
let prev_epoch_start = computer
.indexes
.block
.difficultyepoch_to_first_height
.difficultyepoch
.first_height
.read_once(prev_epoch)?;
let prev_difficulty = indexer
.vecs
.block
.height_to_difficulty
.blocks
.difficulty
.read_once(prev_epoch_start)?;
let curr_difficulty = indexer
.vecs
.block
.height_to_difficulty
.blocks
.difficulty
.read_once(epoch_start_height)?;
if *prev_difficulty > 0.0 {

View File

@@ -10,29 +10,24 @@ pub fn iter_difficulty_epochs(
) -> Vec<DifficultyAdjustmentEntry> {
let start_epoch = computer
.indexes
.block
.height_to_difficultyepoch
.height
.difficultyepoch
.read_once(Height::from(start_height))
.unwrap_or_default();
let end_epoch = computer
.indexes
.block
.height_to_difficultyepoch
.height
.difficultyepoch
.read_once(Height::from(end_height))
.unwrap_or_default();
let mut epoch_to_height_iter = computer
.indexes
.block
.difficultyepoch_to_first_height
.iter();
let mut epoch_to_timestamp_iter = computer.blocks.time.difficultyepoch_to_timestamp.iter();
let mut epoch_to_difficulty_iter = computer
.blocks
.mining
.indexes_to_difficulty
.difficultyepoch
.first_height
.iter();
let mut epoch_to_timestamp_iter = computer.blocks.time.timestamp.difficultyepoch.iter();
let mut epoch_to_difficulty_iter = computer.blocks.mining.difficulty.difficultyepoch.iter();
let mut results = Vec::with_capacity(end_epoch.to_usize() - start_epoch.to_usize() + 1);
let mut prev_difficulty: Option<f64> = None;

View File

@@ -12,23 +12,19 @@ impl Query {
let current_height = self.height();
// Get current difficulty
let current_difficulty = *indexer
.vecs
.block
.height_to_difficulty
.read_once(current_height)?;
let current_difficulty = *indexer.vecs.blocks.difficulty.read_once(current_height)?;
// Get current hashrate
let current_dateindex = computer
.indexes
.block
.height_to_dateindex
.height
.dateindex
.read_once(current_height)?;
let current_hashrate = *computer
.blocks
.mining
.indexes_to_hash_rate
.hash_rate
.dateindex
.read_once(current_dateindex)? as u128;
@@ -42,8 +38,8 @@ impl Query {
// Get hashrate entries using iterators for efficiency
let start_dateindex = computer
.indexes
.block
.height_to_dateindex
.height
.dateindex
.read_once(Height::from(start))?;
let end_dateindex = current_dateindex;
@@ -55,19 +51,9 @@ impl Query {
let step = (total_days / 200).max(1); // Max ~200 data points
// Create iterators for the loop
let mut hashrate_iter = computer
.blocks
.mining
.indexes_to_hash_rate
.dateindex
.iter();
let mut hashrate_iter = computer.blocks.mining.hash_rate.dateindex.iter();
let mut timestamp_iter = computer
.blocks
.time
.timeindexes_to_timestamp
.dateindex
.iter();
let mut timestamp_iter = computer.blocks.time.timestamp.dateindex.iter();
let mut hashrates = Vec::with_capacity(total_days / step + 1);
let mut di = start_dateindex.to_usize();

View File

@@ -31,7 +31,7 @@ impl Query {
// For each pool, get cumulative count at end and start, subtract to get range count
for (pool_id, pool_vecs) in &computer.pools.vecs {
let mut cumulative = pool_vecs
.indexes_to_blocks_mined
.blocks_mined
.height_cumulative
.inner()
.iter();
@@ -101,7 +101,7 @@ impl Query {
.ok_or_else(|| Error::NotFound("Pool data not found".into()))?;
let mut cumulative = pool_vecs
.indexes_to_blocks_mined
.blocks_mined
.height_cumulative
.inner()
.iter();

View File

@@ -12,31 +12,19 @@ impl Query {
let end_block = current_height;
let start_block = Height::from(current_height.to_usize().saturating_sub(block_count - 1));
// KISS: height is now a concrete field (no Option)
let mut coinbase_iter = computer
.blocks
.rewards
.indexes_to_coinbase
.sats
.height
.iter();
// KISS: height.sum_cum.sum.0 is now a concrete field
let mut coinbase_iter = computer.blocks.rewards.coinbase.sats.height.iter();
let mut fee_iter = computer
.transactions
.fees
.indexes_to_fee
.fee
.sats
.height
.sum_cum
.sum
.0
.iter();
let mut tx_count_iter = computer
.transactions
.count
.indexes_to_tx_count
.height
.iter();
let mut tx_count_iter = computer.transactions.count.tx_count.height.iter();
let mut total_reward = Sats::ZERO;
let mut total_fee = Sats::ZERO;