mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-25 07:09:59 -07:00
global: MASSIVE snapshot
This commit is contained in:
@@ -6,11 +6,9 @@ use super::Vecs;
|
||||
use crate::{
|
||||
indexes,
|
||||
internal::{
|
||||
ComputedVecsFromHeight, LazyVecsFrom2FromHeight, PercentageU64F32, Source,
|
||||
VecBuilderOptions,
|
||||
ComputedBlockFull, BinaryBlockFull, PercentageU64F32,
|
||||
},
|
||||
outputs,
|
||||
utils::OptionExt,
|
||||
};
|
||||
|
||||
impl Vecs {
|
||||
@@ -20,116 +18,87 @@ impl Vecs {
|
||||
indexes: &indexes::Vecs,
|
||||
outputs: &outputs::Vecs,
|
||||
) -> Result<Self> {
|
||||
let full_stats = || {
|
||||
VecBuilderOptions::default()
|
||||
.add_average()
|
||||
.add_minmax()
|
||||
.add_percentiles()
|
||||
.add_sum()
|
||||
.add_cumulative()
|
||||
};
|
||||
|
||||
let indexes_to_p2a_count = ComputedVecsFromHeight::forced_import(
|
||||
let indexes_to_p2a_count = ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"p2a_count",
|
||||
Source::Compute,
|
||||
version,
|
||||
indexes,
|
||||
full_stats(),
|
||||
)?;
|
||||
let indexes_to_p2ms_count = ComputedVecsFromHeight::forced_import(
|
||||
let indexes_to_p2ms_count = ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"p2ms_count",
|
||||
Source::Compute,
|
||||
version,
|
||||
indexes,
|
||||
full_stats(),
|
||||
)?;
|
||||
let indexes_to_p2pk33_count = ComputedVecsFromHeight::forced_import(
|
||||
let indexes_to_p2pk33_count = ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"p2pk33_count",
|
||||
Source::Compute,
|
||||
version,
|
||||
indexes,
|
||||
full_stats(),
|
||||
)?;
|
||||
let indexes_to_p2pk65_count = ComputedVecsFromHeight::forced_import(
|
||||
let indexes_to_p2pk65_count = ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"p2pk65_count",
|
||||
Source::Compute,
|
||||
version,
|
||||
indexes,
|
||||
full_stats(),
|
||||
)?;
|
||||
let indexes_to_p2pkh_count = ComputedVecsFromHeight::forced_import(
|
||||
let indexes_to_p2pkh_count = ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"p2pkh_count",
|
||||
Source::Compute,
|
||||
version,
|
||||
indexes,
|
||||
full_stats(),
|
||||
)?;
|
||||
let indexes_to_p2sh_count = ComputedVecsFromHeight::forced_import(
|
||||
let indexes_to_p2sh_count = ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"p2sh_count",
|
||||
Source::Compute,
|
||||
version,
|
||||
indexes,
|
||||
full_stats(),
|
||||
)?;
|
||||
let indexes_to_p2tr_count = ComputedVecsFromHeight::forced_import(
|
||||
let indexes_to_p2tr_count = ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"p2tr_count",
|
||||
Source::Compute,
|
||||
version,
|
||||
indexes,
|
||||
full_stats(),
|
||||
)?;
|
||||
let indexes_to_p2wpkh_count = ComputedVecsFromHeight::forced_import(
|
||||
let indexes_to_p2wpkh_count = ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"p2wpkh_count",
|
||||
Source::Compute,
|
||||
version,
|
||||
indexes,
|
||||
full_stats(),
|
||||
)?;
|
||||
let indexes_to_p2wsh_count = ComputedVecsFromHeight::forced_import(
|
||||
let indexes_to_p2wsh_count = ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"p2wsh_count",
|
||||
Source::Compute,
|
||||
version,
|
||||
indexes,
|
||||
full_stats(),
|
||||
)?;
|
||||
|
||||
// Aggregate counts (computed from per-type counts)
|
||||
let indexes_to_segwit_count = ComputedVecsFromHeight::forced_import(
|
||||
let indexes_to_segwit_count = ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"segwit_count",
|
||||
Source::Compute,
|
||||
version,
|
||||
indexes,
|
||||
full_stats(),
|
||||
)?;
|
||||
|
||||
// Adoption ratios (lazy)
|
||||
// Uses outputs.count.indexes_to_count as denominator (total output count)
|
||||
// At height level: per-block ratio; at dateindex level: sum-based ratio (% of new outputs)
|
||||
let indexes_to_taproot_adoption =
|
||||
LazyVecsFrom2FromHeight::from_height_and_txindex::<PercentageU64F32>(
|
||||
BinaryBlockFull::from_height_and_txindex::<PercentageU64F32>(
|
||||
"taproot_adoption",
|
||||
version,
|
||||
indexes_to_p2tr_count.height.u().boxed_clone(),
|
||||
outputs.count.indexes_to_count.height.sum.u().boxed_clone(),
|
||||
indexes_to_p2tr_count.height.boxed_clone(),
|
||||
outputs.count.indexes_to_count.height.sum_cum.sum.0.boxed_clone(),
|
||||
&indexes_to_p2tr_count,
|
||||
&outputs.count.indexes_to_count,
|
||||
);
|
||||
let indexes_to_segwit_adoption =
|
||||
LazyVecsFrom2FromHeight::from_height_and_txindex::<PercentageU64F32>(
|
||||
BinaryBlockFull::from_height_and_txindex::<PercentageU64F32>(
|
||||
"segwit_adoption",
|
||||
version,
|
||||
indexes_to_segwit_count.height.u().boxed_clone(),
|
||||
outputs.count.indexes_to_count.height.sum.u().boxed_clone(),
|
||||
indexes_to_segwit_count.height.boxed_clone(),
|
||||
outputs.count.indexes_to_count.height.sum_cum.sum.0.boxed_clone(),
|
||||
&indexes_to_segwit_count,
|
||||
&outputs.count.indexes_to_count,
|
||||
);
|
||||
@@ -144,29 +113,23 @@ impl Vecs {
|
||||
indexes_to_p2tr_count,
|
||||
indexes_to_p2wpkh_count,
|
||||
indexes_to_p2wsh_count,
|
||||
indexes_to_opreturn_count: ComputedVecsFromHeight::forced_import(
|
||||
indexes_to_opreturn_count: ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"opreturn_count",
|
||||
Source::Compute,
|
||||
version,
|
||||
indexes,
|
||||
full_stats(),
|
||||
)?,
|
||||
indexes_to_emptyoutput_count: ComputedVecsFromHeight::forced_import(
|
||||
indexes_to_emptyoutput_count: ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"emptyoutput_count",
|
||||
Source::Compute,
|
||||
version,
|
||||
indexes,
|
||||
full_stats(),
|
||||
)?,
|
||||
indexes_to_unknownoutput_count: ComputedVecsFromHeight::forced_import(
|
||||
indexes_to_unknownoutput_count: ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"unknownoutput_count",
|
||||
Source::Compute,
|
||||
version,
|
||||
indexes,
|
||||
full_stats(),
|
||||
)?,
|
||||
indexes_to_segwit_count,
|
||||
indexes_to_taproot_adoption,
|
||||
|
||||
Reference in New Issue
Block a user