diff --git a/crates/brk_computer/src/chain.rs b/crates/brk_computer/src/chain.rs index cd94b4f70..a0f04f4c6 100644 --- a/crates/brk_computer/src/chain.rs +++ b/crates/brk_computer/src/chain.rs @@ -4,10 +4,10 @@ use allocative::Allocative; use brk_error::Result; use brk_indexer::Indexer; use brk_structs::{ - CheckedSub, Date, DateIndex, DecadeIndex, DifficultyEpoch, Dollars, FeeRate, HalvingEpoch, - Height, InputIndex, MonthIndex, OutputIndex, QuarterIndex, Sats, SemesterIndex, StoredBool, - StoredF32, StoredF64, StoredU32, StoredU64, Timestamp, TxIndex, TxVersion, Version, WeekIndex, - Weight, YearIndex, + CheckedSub, DateIndex, DecadeIndex, DifficultyEpoch, Dollars, FeeRate, HalvingEpoch, Height, + InputIndex, MonthIndex, OutputIndex, QuarterIndex, Sats, SemesterIndex, StoredBool, StoredF32, + StoredF64, StoredU32, StoredU64, Timestamp, TxIndex, TxVersion, Version, WeekIndex, Weight, + YearIndex, }; use vecdb::{ AnyCloneableIterableVec, AnyCollectableVec, AnyIterableVec, Database, EagerVec, Exit, @@ -49,6 +49,9 @@ pub struct Vecs { pub decadeindex_to_block_count_target: LazyVecFrom1, pub height_to_interval: EagerVec, + pub height_to_24h_block_count: EagerVec, + pub height_to_24h_coinbase_sum: EagerVec, + pub height_to_24h_coinbase_in_usd_sum: EagerVec, pub height_to_vbytes: EagerVec, pub difficultyepoch_to_timestamp: EagerVec, pub halvingepoch_to_timestamp: EagerVec, @@ -108,27 +111,28 @@ pub struct Vecs { pub dateindex_to_subsidy_dominance: EagerVec, pub indexes_to_subsidy_usd_1y_sma: Option>, pub indexes_to_puell_multiple: Option>, - pub indexes_to_hash_rate: ComputedVecsFromDateIndex, + pub indexes_to_hash_rate: ComputedVecsFromHeight, pub indexes_to_hash_rate_1w_sma: ComputedVecsFromDateIndex, pub indexes_to_hash_rate_1m_sma: ComputedVecsFromDateIndex, pub indexes_to_hash_rate_2m_sma: ComputedVecsFromDateIndex, pub indexes_to_hash_rate_1y_sma: ComputedVecsFromDateIndex, - pub indexes_to_hash_price_ths: ComputedVecsFromDateIndex, - pub indexes_to_hash_price_ths_min: ComputedVecsFromDateIndex, - pub indexes_to_hash_price_phs: ComputedVecsFromDateIndex, - pub indexes_to_hash_price_phs_min: ComputedVecsFromDateIndex, - pub indexes_to_hash_price_rebound: ComputedVecsFromDateIndex, - pub indexes_to_hash_value_ths: ComputedVecsFromDateIndex, - pub indexes_to_hash_value_ths_min: ComputedVecsFromDateIndex, - pub indexes_to_hash_value_phs: ComputedVecsFromDateIndex, - pub indexes_to_hash_value_phs_min: ComputedVecsFromDateIndex, - pub indexes_to_hash_value_rebound: ComputedVecsFromDateIndex, - pub indexes_to_difficulty_as_hash: ComputedVecsFromDateIndex, + pub indexes_to_hash_price_ths: ComputedVecsFromHeight, + pub indexes_to_hash_price_ths_min: ComputedVecsFromHeight, + pub indexes_to_hash_price_phs: ComputedVecsFromHeight, + pub indexes_to_hash_price_phs_min: ComputedVecsFromHeight, + pub indexes_to_hash_price_rebound: ComputedVecsFromHeight, + pub indexes_to_hash_value_ths: ComputedVecsFromHeight, + pub indexes_to_hash_value_ths_min: ComputedVecsFromHeight, + pub indexes_to_hash_value_phs: ComputedVecsFromHeight, + pub indexes_to_hash_value_phs_min: ComputedVecsFromHeight, + pub indexes_to_hash_value_rebound: ComputedVecsFromHeight, + pub indexes_to_difficulty_as_hash: ComputedVecsFromHeight, pub indexes_to_difficulty_adjustment: ComputedVecsFromHeight, pub indexes_to_blocks_before_next_difficulty_adjustment: ComputedVecsFromHeight, pub indexes_to_days_before_next_difficulty_adjustment: ComputedVecsFromHeight, pub indexes_to_blocks_before_next_halving: ComputedVecsFromHeight, pub indexes_to_days_before_next_halving: ComputedVecsFromHeight, + pub indexes_to_inflation_rate: ComputedVecsFromDateIndex, } impl Vecs { @@ -465,6 +469,21 @@ impl Vecs { "vbytes", version + VERSION + Version::ZERO, )?, + height_to_24h_block_count: EagerVec::forced_import_compressed( + &db, + "24h_block_count", + version + VERSION + Version::ZERO, + )?, + height_to_24h_coinbase_sum: EagerVec::forced_import_compressed( + &db, + "24h_coinbase_sum", + version + VERSION + Version::ZERO, + )?, + height_to_24h_coinbase_in_usd_sum: EagerVec::forced_import_compressed( + &db, + "24h_coinbase_in_usd_sum", + version + VERSION + Version::ZERO, + )?, indexes_to_block_vbytes: ComputedVecsFromHeight::forced_import( &db, "block_vbytes", @@ -856,11 +875,11 @@ impl Vecs { ) .unwrap() }), - indexes_to_hash_rate: ComputedVecsFromDateIndex::forced_import( + indexes_to_hash_rate: ComputedVecsFromHeight::forced_import( &db, "hash_rate", Source::Compute, - version + VERSION + Version::ONE, + version + VERSION + Version::new(5), indexes, VecBuilderOptions::default().add_last(), )?, @@ -896,7 +915,7 @@ impl Vecs { indexes, VecBuilderOptions::default().add_last(), )?, - indexes_to_difficulty_as_hash: ComputedVecsFromDateIndex::forced_import( + indexes_to_difficulty_as_hash: ComputedVecsFromHeight::forced_import( &db, "difficulty_as_hash", Source::Compute, @@ -946,82 +965,90 @@ impl Vecs { indexes, VecBuilderOptions::default().add_last(), )?, - indexes_to_hash_price_ths: ComputedVecsFromDateIndex::forced_import( + indexes_to_hash_price_ths: ComputedVecsFromHeight::forced_import( &db, "hash_price_ths", Source::Compute, - version + VERSION + Version::ZERO, + version + VERSION + Version::new(4), indexes, VecBuilderOptions::default().add_last(), )?, - indexes_to_hash_price_phs: ComputedVecsFromDateIndex::forced_import( + indexes_to_hash_price_phs: ComputedVecsFromHeight::forced_import( &db, "hash_price_phs", Source::Compute, - version + VERSION + Version::ZERO, + version + VERSION + Version::new(4), indexes, VecBuilderOptions::default().add_last(), )?, - indexes_to_hash_value_ths: ComputedVecsFromDateIndex::forced_import( + indexes_to_hash_value_ths: ComputedVecsFromHeight::forced_import( &db, "hash_value_ths", Source::Compute, - version + VERSION + Version::ZERO, + version + VERSION + Version::new(4), indexes, VecBuilderOptions::default().add_last(), )?, - indexes_to_hash_value_phs: ComputedVecsFromDateIndex::forced_import( + indexes_to_hash_value_phs: ComputedVecsFromHeight::forced_import( &db, "hash_value_phs", Source::Compute, - version + VERSION + Version::ZERO, + version + VERSION + Version::new(4), indexes, VecBuilderOptions::default().add_last(), )?, - indexes_to_hash_price_ths_min: ComputedVecsFromDateIndex::forced_import( + indexes_to_hash_price_ths_min: ComputedVecsFromHeight::forced_import( &db, "hash_price_ths_min", Source::Compute, - version + VERSION + Version::ZERO, + version + VERSION + Version::new(4), indexes, VecBuilderOptions::default().add_last(), )?, - indexes_to_hash_price_phs_min: ComputedVecsFromDateIndex::forced_import( + indexes_to_hash_price_phs_min: ComputedVecsFromHeight::forced_import( &db, "hash_price_phs_min", Source::Compute, - version + VERSION + Version::ZERO, + version + VERSION + Version::new(4), indexes, VecBuilderOptions::default().add_last(), )?, - indexes_to_hash_price_rebound: ComputedVecsFromDateIndex::forced_import( + indexes_to_hash_price_rebound: ComputedVecsFromHeight::forced_import( &db, "hash_price_rebound", Source::Compute, - version + VERSION + Version::ZERO, + version + VERSION + Version::new(4), indexes, VecBuilderOptions::default().add_last(), )?, - indexes_to_hash_value_ths_min: ComputedVecsFromDateIndex::forced_import( + indexes_to_hash_value_ths_min: ComputedVecsFromHeight::forced_import( &db, "hash_value_ths_min", Source::Compute, - version + VERSION + Version::ZERO, + version + VERSION + Version::new(4), indexes, VecBuilderOptions::default().add_last(), )?, - indexes_to_hash_value_phs_min: ComputedVecsFromDateIndex::forced_import( + indexes_to_hash_value_phs_min: ComputedVecsFromHeight::forced_import( &db, "hash_value_phs_min", Source::Compute, - version + VERSION + Version::ZERO, + version + VERSION + Version::new(4), indexes, VecBuilderOptions::default().add_last(), )?, - indexes_to_hash_value_rebound: ComputedVecsFromDateIndex::forced_import( + indexes_to_hash_value_rebound: ComputedVecsFromHeight::forced_import( &db, "hash_value_rebound", Source::Compute, + version + VERSION + Version::new(4), + indexes, + VecBuilderOptions::default().add_last(), + )?, + indexes_to_inflation_rate: ComputedVecsFromDateIndex::forced_import( + &db, + "inflation_rate", + Source::Compute, version + VERSION + Version::ZERO, indexes, VecBuilderOptions::default().add_last(), @@ -1082,6 +1109,26 @@ impl Vecs { Ok(()) })?; + let mut height_to_timestamp_fixed_iter = indexes.height_to_timestamp_fixed.into_iter(); + let mut prev = Height::ZERO; + self.height_to_24h_block_count.compute_transform( + starting_indexes.height, + &indexes.height_to_timestamp_fixed, + |(h, t, ..)| { + while t.difference_in_days_between( + height_to_timestamp_fixed_iter.unwrap_get_inner(prev), + ) > 0 + { + prev.increment(); + if prev > h { + unreachable!() + } + } + (h, StoredU32::from(*h + 1 - *prev)) + }, + exit, + )?; + self.indexes_to_block_count .compute_all(indexes, starting_indexes, exit, |v| { v.compute_range( @@ -1411,6 +1458,49 @@ impl Vecs { Ok(()) })?; + let mut height_to_coinbase_iter = self + .indexes_to_coinbase + .sats + .height + .as_ref() + .unwrap() + .into_iter(); + self.height_to_24h_coinbase_sum.compute_transform( + starting_indexes.height, + &self.height_to_24h_block_count, + |(h, count, ..)| { + let range = *h - (*count - 1)..=*h; + let sum = range + .map(Height::from) + .map(|h| height_to_coinbase_iter.unwrap_get_inner(h)) + .sum::(); + (h, sum) + }, + exit, + )?; + if let Some(mut height_to_coinbase_iter) = self + .indexes_to_coinbase + .dollars + .as_ref() + .map(|c| c.height.as_ref().unwrap().into_iter()) + { + self.height_to_24h_coinbase_in_usd_sum.compute_transform( + starting_indexes.height, + &self.height_to_24h_block_count, + |(h, count, ..)| { + let range = *h - (*count - 1)..=*h; + let sum = range + .map(Height::from) + .map(|h| height_to_coinbase_iter.unwrap_get_inner(h)) + .sum::(); + (h, sum) + }, + exit, + )?; + } + + drop(height_to_coinbase_iter); + self.indexes_to_subsidy .compute_all(indexes, price, starting_indexes, exit, |vec| { let mut indexes_to_fee_sum_iter = @@ -1448,6 +1538,24 @@ impl Vecs { }, )?; + self.indexes_to_inflation_rate + .compute_all(starting_indexes, exit, |v| { + v.compute_transform2( + starting_indexes.dateindex, + self.indexes_to_subsidy.sats.dateindex.unwrap_sum(), + self.indexes_to_subsidy.sats.dateindex.unwrap_cumulative(), + |(i, subsidy_1d_sum, subsidy_cumulative, ..)| { + ( + i, + (365.0 * *subsidy_1d_sum as f64 / *subsidy_cumulative as f64 * 100.0) + .into(), + ) + }, + exit, + )?; + Ok(()) + })?; + self.indexes_to_p2a_count .compute_all(indexes, starting_indexes, exit, |v| { v.compute_count_from_indexes( @@ -1654,40 +1762,28 @@ impl Vecs { )?; self.indexes_to_difficulty_as_hash - .compute_all(starting_indexes, exit, |v| { + .compute_all(indexes, starting_indexes, exit, |v| { let multiplier = 2.0_f64.powi(32) / 600.0; v.compute_transform( - starting_indexes.dateindex, - self.indexes_to_difficulty.dateindex.unwrap_last(), + starting_indexes.height, + &indexer.vecs.height_to_difficulty, |(i, v, ..)| (i, StoredF32::from(*v * multiplier)), exit, )?; Ok(()) })?; - let now = Timestamp::now(); - let today = Date::from(now); self.indexes_to_hash_rate - .compute_all(starting_indexes, exit, |v| { - v.compute_transform3( - starting_indexes.dateindex, - self.indexes_to_block_count.dateindex.unwrap_sum(), - self.indexes_to_difficulty_as_hash - .dateindex - .as_ref() - .unwrap(), - &indexes.dateindex_to_date, - |(i, block_count_sum, difficulty_as_hash, date, ..)| { - let target_multiplier = if date == today { - now.day_completion() - } else { - 1.0 - }; + .compute_all(indexes, starting_indexes, exit, |v| { + v.compute_transform2( + starting_indexes.height, + &self.height_to_24h_block_count, + self.indexes_to_difficulty_as_hash.height.as_ref().unwrap(), + |(i, block_count_sum, difficulty_as_hash, ..)| { ( i, StoredF64::from( - (f64::from(block_count_sum) - / (target_multiplier * TARGET_BLOCKS_PER_DAY_F64)) + (f64::from(block_count_sum) / TARGET_BLOCKS_PER_DAY_F64) * f64::from(difficulty_as_hash), ), ) @@ -1701,7 +1797,7 @@ impl Vecs { .compute_all(starting_indexes, exit, |v| { v.compute_sma( starting_indexes.dateindex, - self.indexes_to_hash_rate.dateindex.as_ref().unwrap(), + self.indexes_to_hash_rate.dateindex.unwrap_last(), 7, exit, )?; @@ -1712,7 +1808,7 @@ impl Vecs { .compute_all(starting_indexes, exit, |v| { v.compute_sma( starting_indexes.dateindex, - self.indexes_to_hash_rate.dateindex.as_ref().unwrap(), + self.indexes_to_hash_rate.dateindex.unwrap_last(), 30, exit, )?; @@ -1723,7 +1819,7 @@ impl Vecs { .compute_all(starting_indexes, exit, |v| { v.compute_sma( starting_indexes.dateindex, - self.indexes_to_hash_rate.dateindex.as_ref().unwrap(), + self.indexes_to_hash_rate.dateindex.unwrap_last(), 2 * 30, exit, )?; @@ -1734,7 +1830,7 @@ impl Vecs { .compute_all(starting_indexes, exit, |v| { v.compute_sma( starting_indexes.dateindex, - self.indexes_to_hash_rate.dateindex.as_ref().unwrap(), + self.indexes_to_hash_rate.dateindex.unwrap_last(), 365, exit, )?; @@ -1856,16 +1952,11 @@ impl Vecs { )?; self.indexes_to_hash_price_ths - .compute_all(starting_indexes, exit, |v| { + .compute_all(indexes, starting_indexes, exit, |v| { v.compute_transform2( - starting_indexes.dateindex, - self.indexes_to_coinbase - .dollars - .as_ref() - .unwrap() - .dateindex - .unwrap_sum(), - self.indexes_to_hash_rate.dateindex.as_ref().unwrap(), + starting_indexes.height, + &self.height_to_24h_coinbase_in_usd_sum, + self.indexes_to_hash_rate.height.as_ref().unwrap(), |(i, coinbase_sum, hashrate, ..)| { (i, (*coinbase_sum / (*hashrate / ONE_TERA_HASH)).into()) }, @@ -1875,10 +1966,10 @@ impl Vecs { })?; self.indexes_to_hash_price_phs - .compute_all(starting_indexes, exit, |v| { + .compute_all(indexes, starting_indexes, exit, |v| { v.compute_transform( - starting_indexes.dateindex, - self.indexes_to_hash_price_ths.dateindex.as_ref().unwrap(), + starting_indexes.height, + self.indexes_to_hash_price_ths.height.as_ref().unwrap(), |(i, price, ..)| (i, (*price * 1000.0).into()), exit, )?; @@ -1886,11 +1977,11 @@ impl Vecs { })?; self.indexes_to_hash_value_ths - .compute_all(starting_indexes, exit, |v| { + .compute_all(indexes, starting_indexes, exit, |v| { v.compute_transform2( - starting_indexes.dateindex, - self.indexes_to_coinbase.sats.dateindex.unwrap_sum(), - self.indexes_to_hash_rate.dateindex.as_ref().unwrap(), + starting_indexes.height, + &self.height_to_24h_coinbase_sum, + self.indexes_to_hash_rate.height.as_ref().unwrap(), |(i, coinbase_sum, hashrate, ..)| { ( i, @@ -1903,10 +1994,10 @@ impl Vecs { })?; self.indexes_to_hash_value_phs - .compute_all(starting_indexes, exit, |v| { + .compute_all(indexes, starting_indexes, exit, |v| { v.compute_transform( - starting_indexes.dateindex, - self.indexes_to_hash_value_ths.dateindex.as_ref().unwrap(), + starting_indexes.height, + self.indexes_to_hash_value_ths.height.as_ref().unwrap(), |(i, value, ..)| (i, (*value * 1000.0).into()), exit, )?; @@ -1914,10 +2005,10 @@ impl Vecs { })?; self.indexes_to_hash_price_ths_min - .compute_all(starting_indexes, exit, |v| { + .compute_all(indexes, starting_indexes, exit, |v| { v.compute_all_time_low_( - starting_indexes.dateindex, - self.indexes_to_hash_price_ths.dateindex.as_ref().unwrap(), + starting_indexes.height, + self.indexes_to_hash_price_ths.height.as_ref().unwrap(), exit, true, )?; @@ -1925,10 +2016,10 @@ impl Vecs { })?; self.indexes_to_hash_price_phs_min - .compute_all(starting_indexes, exit, |v| { + .compute_all(indexes, starting_indexes, exit, |v| { v.compute_all_time_low_( - starting_indexes.dateindex, - self.indexes_to_hash_price_phs.dateindex.as_ref().unwrap(), + starting_indexes.height, + self.indexes_to_hash_price_phs.height.as_ref().unwrap(), exit, true, )?; @@ -1936,10 +2027,10 @@ impl Vecs { })?; self.indexes_to_hash_value_ths_min - .compute_all(starting_indexes, exit, |v| { + .compute_all(indexes, starting_indexes, exit, |v| { v.compute_all_time_low_( - starting_indexes.dateindex, - self.indexes_to_hash_value_ths.dateindex.as_ref().unwrap(), + starting_indexes.height, + self.indexes_to_hash_value_ths.height.as_ref().unwrap(), exit, true, )?; @@ -1947,10 +2038,10 @@ impl Vecs { })?; self.indexes_to_hash_value_phs_min - .compute_all(starting_indexes, exit, |v| { + .compute_all(indexes, starting_indexes, exit, |v| { v.compute_all_time_low_( - starting_indexes.dateindex, - self.indexes_to_hash_value_phs.dateindex.as_ref().unwrap(), + starting_indexes.height, + self.indexes_to_hash_value_phs.height.as_ref().unwrap(), exit, true, )?; @@ -1958,28 +2049,22 @@ impl Vecs { })?; self.indexes_to_hash_price_rebound - .compute_all(starting_indexes, exit, |v| { + .compute_all(indexes, starting_indexes, exit, |v| { v.compute_percentage_difference( - starting_indexes.dateindex, - self.indexes_to_hash_price_phs.dateindex.as_ref().unwrap(), - self.indexes_to_hash_price_phs_min - .dateindex - .as_ref() - .unwrap(), + starting_indexes.height, + self.indexes_to_hash_price_phs.height.as_ref().unwrap(), + self.indexes_to_hash_price_phs_min.height.as_ref().unwrap(), exit, )?; Ok(()) })?; self.indexes_to_hash_value_rebound - .compute_all(starting_indexes, exit, |v| { + .compute_all(indexes, starting_indexes, exit, |v| { v.compute_percentage_difference( - starting_indexes.dateindex, - self.indexes_to_hash_value_phs.dateindex.as_ref().unwrap(), - self.indexes_to_hash_value_phs_min - .dateindex - .as_ref() - .unwrap(), + starting_indexes.height, + self.indexes_to_hash_value_phs.height.as_ref().unwrap(), + self.indexes_to_hash_value_phs_min.height.as_ref().unwrap(), exit, )?; Ok(()) @@ -2012,16 +2097,17 @@ impl Vecs { &self.semesterindex_to_block_count_target, &self.yearindex_to_block_count_target, &self.decadeindex_to_block_count_target, + &self.height_to_24h_block_count, + &self.height_to_24h_coinbase_sum, + &self.height_to_24h_coinbase_in_usd_sum, ] .into_iter(), ); - iter = Box::new(iter.chain(self.indexes_to_hash_rate.iter_any_collectable())); iter = Box::new(iter.chain(self.indexes_to_hash_rate_1w_sma.iter_any_collectable())); iter = Box::new(iter.chain(self.indexes_to_hash_rate_1m_sma.iter_any_collectable())); iter = Box::new(iter.chain(self.indexes_to_hash_rate_2m_sma.iter_any_collectable())); iter = Box::new(iter.chain(self.indexes_to_hash_rate_1y_sma.iter_any_collectable())); - iter = Box::new(iter.chain(self.timeindexes_to_timestamp.iter_any_collectable())); iter = Box::new(iter.chain(self.indexes_to_block_count.iter_any_collectable())); iter = Box::new(iter.chain(self.indexes_to_1w_block_count.iter_any_collectable())); @@ -2031,7 +2117,7 @@ impl Vecs { iter = Box::new(iter.chain(self.indexes_to_block_size.iter_any_collectable())); iter = Box::new(iter.chain(self.indexes_to_block_vbytes.iter_any_collectable())); iter = Box::new(iter.chain(self.indexes_to_block_weight.iter_any_collectable())); - + iter = Box::new(iter.chain(self.indexes_to_inflation_rate.iter_any_collectable())); iter = Box::new(iter.chain(self.indexes_to_difficulty.iter_any_collectable())); iter = Box::new(iter.chain(self.indexes_to_difficulty_adjustment.iter_any_collectable())); iter = Box::new(iter.chain(self.indexes_to_difficultyepoch.iter_any_collectable())); @@ -2071,7 +2157,6 @@ impl Vecs { iter = Box::new(iter.chain(self.indexes_to_hash_value_phs_min.iter_any_collectable())); iter = Box::new(iter.chain(self.indexes_to_hash_price_rebound.iter_any_collectable())); iter = Box::new(iter.chain(self.indexes_to_hash_value_rebound.iter_any_collectable())); - iter = Box::new(iter.chain(self.indexes_to_coinbase.iter_any_collectable())); iter = Box::new(iter.chain(self.indexes_to_fee.iter_any_collectable())); iter = Box::new(iter.chain(self.indexes_to_fee_rate.iter_any_collectable())); @@ -2081,7 +2166,6 @@ impl Vecs { iter = Box::new(iter.chain(self.indexes_to_tx_v3.iter_any_collectable())); iter = Box::new(iter.chain(self.indexes_to_tx_vsize.iter_any_collectable())); iter = Box::new(iter.chain(self.indexes_to_tx_weight.iter_any_collectable())); - iter = Box::new(iter.chain(self.indexes_to_emptyoutput_count.iter_any_collectable())); iter = Box::new(iter.chain(self.indexes_to_input_count.iter_any_collectable())); iter = Box::new(iter.chain(self.indexes_to_opreturn_count.iter_any_collectable())); @@ -2096,11 +2180,9 @@ impl Vecs { iter = Box::new(iter.chain(self.indexes_to_p2wpkh_count.iter_any_collectable())); iter = Box::new(iter.chain(self.indexes_to_p2wsh_count.iter_any_collectable())); iter = Box::new(iter.chain(self.indexes_to_unknownoutput_count.iter_any_collectable())); - iter = Box::new(iter.chain(self.indexes_to_subsidy.iter_any_collectable())); iter = Box::new(iter.chain(self.indexes_to_exact_utxo_count.iter_any_collectable())); iter = Box::new(iter.chain(self.indexes_to_unclaimed_rewards.iter_any_collectable())); - iter = Box::new( iter.chain( self.indexes_to_subsidy_usd_1y_sma diff --git a/crates/brk_structs/src/structs/dollars.rs b/crates/brk_structs/src/structs/dollars.rs index db7f7b447..3cedd1c92 100644 --- a/crates/brk_structs/src/structs/dollars.rs +++ b/crates/brk_structs/src/structs/dollars.rs @@ -1,6 +1,7 @@ use std::{ cmp::Ordering, f64, + iter::Sum, ops::{Add, AddAssign, Div, Mul}, }; @@ -378,3 +379,10 @@ impl Ord for Dollars { } } } + +impl Sum for Dollars { + fn sum>(iter: I) -> Self { + let dollars: f64 = iter.map(|dollars| dollars.0).sum(); + Self::from(dollars) + } +} diff --git a/websites/bitview/packages/lightweight-charts/wrapper.js b/websites/bitview/packages/lightweight-charts/wrapper.js index b094002e3..b8eee5282 100644 --- a/websites/bitview/packages/lightweight-charts/wrapper.js +++ b/websites/bitview/packages/lightweight-charts/wrapper.js @@ -143,9 +143,9 @@ function createChartElement({ }), ); - ichart.priceScale("right").applyOptions({ - minimumWidth: 80, - }); + // ichart.priceScale("right").applyOptions({ + // minimumWidth: 80, + // }); ichart.panes().at(0)?.setStretchFactor(1); @@ -693,7 +693,7 @@ function createChartElement({ color: color(), // lineVisible: false, // pointMarkersVisible: true, - // pointMarkersRadius: 1.375, + // pointMarkersRadius: 1, ...options, }, paneIndex, diff --git a/websites/bitview/scripts/main.js b/websites/bitview/scripts/main.js index 0cd257e6a..7f5ee6ac9 100644 --- a/websites/bitview/scripts/main.js +++ b/websites/bitview/scripts/main.js @@ -842,6 +842,7 @@ function createUtils() { (!unit || thoroughUnitCheck) && (id === "price_drawdown" || id === "difficulty_adjustment" || + id.startsWith("inflation_rate") || id.endsWith("_oscillator") || id.endsWith("_dominance") || id.endsWith("_returns") || diff --git a/websites/bitview/scripts/options.js b/websites/bitview/scripts/options.js index 8c43b42cd..3d6d878d8 100644 --- a/websites/bitview/scripts/options.js +++ b/websites/bitview/scripts/options.js @@ -3525,16 +3525,13 @@ function createPartialOptions({ env, colors, vecIdToIndexes, pools }) { bottom: [ createAverageSeries({ concat: "tx_weight", - title: "Weight", }), ...createMinMaxPercentilesSeries({ concat: "tx_weight", - title: "Weight", }), - createAverageSeries({ concat: "tx_vsize", title: "VSize" }), + createAverageSeries({ concat: "tx_vsize" }), ...createMinMaxPercentilesSeries({ concat: "tx_vsize", - title: "VSize", }), ], }, @@ -3730,6 +3727,16 @@ function createPartialOptions({ env, colors, vecIdToIndexes, pools }) { }), ], }, + { + name: "Inflation", + title: "Inflation Rate", + bottom: [ + createBaseSeries({ + key: "inflation_rate", + name: "Inflation", + }), + ], + }, { name: "Puell multiple", title: "Puell multiple",