global: fmt

This commit is contained in:
nym21
2026-03-28 11:56:51 +01:00
parent b6e56c4e9f
commit 24d2b7b142
213 changed files with 6888 additions and 2527 deletions

View File

@@ -3,8 +3,8 @@ use brk_types::Version;
use vecdb::{Database, ReadableCloneableVec};
use super::{
vecs::{HashPriceValueVecs, HashRateSmaVecs, RateVecs},
Vecs,
vecs::{HashPriceValueVecs, HashRateSmaVecs, RateVecs},
};
use crate::{
indexes,
@@ -21,21 +21,35 @@ impl Vecs {
let v5 = Version::new(5);
let price_ths = PerBlock::forced_import(db, "hash_price_ths", version + v4, indexes)?;
let price_ths_min = PerBlock::forced_import(db, "hash_price_ths_min", version + v4, indexes)?;
let price_ths_min =
PerBlock::forced_import(db, "hash_price_ths_min", version + v4, indexes)?;
let price_phs = LazyPerBlock::from_computed::<ThsToPhsF32>(
"hash_price_phs", version + v4, price_ths.height.read_only_boxed_clone(), &price_ths,
"hash_price_phs",
version + v4,
price_ths.height.read_only_boxed_clone(),
&price_ths,
);
let price_phs_min = LazyPerBlock::from_computed::<ThsToPhsF32>(
"hash_price_phs_min", version + v4, price_ths_min.height.read_only_boxed_clone(), &price_ths_min,
"hash_price_phs_min",
version + v4,
price_ths_min.height.read_only_boxed_clone(),
&price_ths_min,
);
let value_ths = PerBlock::forced_import(db, "hash_value_ths", version + v4, indexes)?;
let value_ths_min = PerBlock::forced_import(db, "hash_value_ths_min", version + v4, indexes)?;
let value_ths_min =
PerBlock::forced_import(db, "hash_value_ths_min", version + v4, indexes)?;
let value_phs = LazyPerBlock::from_computed::<ThsToPhsF32>(
"hash_value_phs", version + v4, value_ths.height.read_only_boxed_clone(), &value_ths,
"hash_value_phs",
version + v4,
value_ths.height.read_only_boxed_clone(),
&value_ths,
);
let value_phs_min = LazyPerBlock::from_computed::<ThsToPhsF32>(
"hash_value_phs_min", version + v4, value_ths_min.height.read_only_boxed_clone(), &value_ths_min,
"hash_value_phs_min",
version + v4,
value_ths_min.height.read_only_boxed_clone(),
&value_ths_min,
);
Ok(Self {
@@ -48,21 +62,36 @@ impl Vecs {
_1y: PerBlock::forced_import(db, "hash_rate_sma_1y", version, indexes)?,
},
ath: PerBlock::forced_import(db, "hash_rate_ath", version, indexes)?,
drawdown: PercentPerBlock::forced_import(db, "hash_rate_drawdown", version, indexes)?,
drawdown: PercentPerBlock::forced_import(
db,
"hash_rate_drawdown",
version,
indexes,
)?,
},
price: HashPriceValueVecs {
ths: price_ths,
ths_min: price_ths_min,
phs: price_phs,
phs_min: price_phs_min,
rebound: PercentPerBlock::forced_import(db, "hash_price_rebound", version + v4, indexes)?,
rebound: PercentPerBlock::forced_import(
db,
"hash_price_rebound",
version + v4,
indexes,
)?,
},
value: HashPriceValueVecs {
ths: value_ths,
ths_min: value_ths_min,
phs: value_phs,
phs_min: value_phs_min,
rebound: PercentPerBlock::forced_import(db, "hash_value_rebound", version + v4, indexes)?,
rebound: PercentPerBlock::forced_import(
db,
"hash_value_rebound",
version + v4,
indexes,
)?,
},
})
}

View File

@@ -5,7 +5,10 @@ use brk_types::Version;
use crate::{
indexes,
internal::{CachedWindowStarts, db_utils::{finalize_db, open_db}},
internal::{
CachedWindowStarts,
db_utils::{finalize_db, open_db},
},
};
use super::{HashrateVecs, RewardsVecs, Vecs};

View File

@@ -4,7 +4,11 @@ use brk_types::{CheckedSub, Dollars, Halving, Indexes, Sats};
use vecdb::{Exit, ReadableVec, VecIndex};
use super::Vecs;
use crate::{blocks, indexes, internal::{RatioDollarsBp32, RatioSatsBp16}, prices, transactions};
use crate::{
blocks, indexes,
internal::{RatioDollarsBp32, RatioSatsBp16},
prices, transactions,
};
impl Vecs {
#[allow(clippy::too_many_arguments)]
@@ -22,13 +26,9 @@ impl Vecs {
let window_starts = lookback.window_starts();
let (r_coinbase, r_fees) = rayon::join(
|| {
self.coinbase.compute(
starting_indexes.height,
prices,
exit,
|vec| {
let mut txout_cursor =
indexer.vecs.transactions.first_txout_index.cursor();
self.coinbase
.compute(starting_indexes.height, prices, exit, |vec| {
let mut txout_cursor = indexer.vecs.transactions.first_txout_index.cursor();
let mut count_cursor = indexes.tx_index.output_count.cursor();
vec.compute_transform(
@@ -38,12 +38,10 @@ impl Vecs {
let ti = tx_index.to_usize();
txout_cursor.advance(ti - txout_cursor.position());
let first_txout_index =
txout_cursor.next().unwrap().to_usize();
let first_txout_index = txout_cursor.next().unwrap().to_usize();
count_cursor.advance(ti - count_cursor.position());
let output_count: usize =
count_cursor.next().unwrap().into();
let output_count: usize = count_cursor.next().unwrap().into();
let sats = indexer.vecs.outputs.value.fold_range_at(
first_txout_index,
@@ -56,8 +54,7 @@ impl Vecs {
exit,
)?;
Ok(())
},
)
})
},
|| {
self.fees.compute(
@@ -95,7 +92,8 @@ impl Vecs {
},
exit,
)?;
self.subsidy.compute_rest(starting_indexes.height, prices, exit)?;
self.subsidy
.compute_rest(starting_indexes.height, prices, exit)?;
self.unclaimed.block.sats.compute_transform(
starting_indexes.height,
@@ -107,7 +105,8 @@ impl Vecs {
},
exit,
)?;
self.unclaimed.compute(prices, starting_indexes.height, exit)?;
self.unclaimed
.compute(prices, starting_indexes.height, exit)?;
self.fee_dominance
.compute_binary::<Sats, Sats, RatioSatsBp16>(

View File

@@ -7,8 +7,8 @@ use crate::{
indexes,
internal::{
AmountPerBlockCumulative, AmountPerBlockCumulativeRolling, AmountPerBlockFull,
CachedWindowStarts, LazyPercentRollingWindows, OneMinusBp16,
PercentPerBlock, PercentRollingWindows, RatioRollingWindows,
CachedWindowStarts, LazyPercentRollingWindows, OneMinusBp16, PercentPerBlock,
PercentRollingWindows, RatioRollingWindows,
},
};
@@ -19,12 +19,8 @@ impl Vecs {
indexes: &indexes::Vecs,
cached_starts: &CachedWindowStarts,
) -> Result<Self> {
let fee_dominance_rolling = PercentRollingWindows::forced_import(
db,
"fee_dominance",
version,
indexes,
)?;
let fee_dominance_rolling =
PercentRollingWindows::forced_import(db, "fee_dominance", version, indexes)?;
let subsidy_dominance_rolling = LazyPercentRollingWindows::from_rolling::<OneMinusBp16>(
"subsidy_dominance",
@@ -34,10 +30,18 @@ impl Vecs {
Ok(Self {
coinbase: AmountPerBlockCumulativeRolling::forced_import(
db, "coinbase", version, indexes, cached_starts,
db,
"coinbase",
version,
indexes,
cached_starts,
)?,
subsidy: AmountPerBlockCumulativeRolling::forced_import(
db, "subsidy", version, indexes, cached_starts,
db,
"subsidy",
version,
indexes,
cached_starts,
)?,
fees: AmountPerBlockFull::forced_import(db, "fees", version, indexes, cached_starts)?,
unclaimed: AmountPerBlockCumulative::forced_import(