mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-25 15:19:58 -07:00
global: big snapshot
This commit is contained in:
@@ -5,9 +5,7 @@ use vecdb::{Database, IterableCloneableVec};
|
||||
use super::Vecs;
|
||||
use crate::{
|
||||
indexes,
|
||||
internal::{
|
||||
ComputedBlockFull, BinaryBlockFull, PercentageU64F32,
|
||||
},
|
||||
internal::{BinaryBlockFull, ComputedBlockFull, PercentageU64F32},
|
||||
outputs,
|
||||
};
|
||||
|
||||
@@ -18,122 +16,65 @@ impl Vecs {
|
||||
indexes: &indexes::Vecs,
|
||||
outputs: &outputs::Vecs,
|
||||
) -> Result<Self> {
|
||||
let indexes_to_p2a_count = ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"p2a_count",
|
||||
version,
|
||||
indexes,
|
||||
)?;
|
||||
let indexes_to_p2ms_count = ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"p2ms_count",
|
||||
version,
|
||||
indexes,
|
||||
)?;
|
||||
let indexes_to_p2pk33_count = ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"p2pk33_count",
|
||||
version,
|
||||
indexes,
|
||||
)?;
|
||||
let indexes_to_p2pk65_count = ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"p2pk65_count",
|
||||
version,
|
||||
indexes,
|
||||
)?;
|
||||
let indexes_to_p2pkh_count = ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"p2pkh_count",
|
||||
version,
|
||||
indexes,
|
||||
)?;
|
||||
let indexes_to_p2sh_count = ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"p2sh_count",
|
||||
version,
|
||||
indexes,
|
||||
)?;
|
||||
let indexes_to_p2tr_count = ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"p2tr_count",
|
||||
version,
|
||||
indexes,
|
||||
)?;
|
||||
let indexes_to_p2wpkh_count = ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"p2wpkh_count",
|
||||
version,
|
||||
indexes,
|
||||
)?;
|
||||
let indexes_to_p2wsh_count = ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"p2wsh_count",
|
||||
version,
|
||||
indexes,
|
||||
)?;
|
||||
let p2a = ComputedBlockFull::forced_import(db, "p2a_count", version, indexes)?;
|
||||
let p2ms = ComputedBlockFull::forced_import(db, "p2ms_count", version, indexes)?;
|
||||
let p2pk33 = ComputedBlockFull::forced_import(db, "p2pk33_count", version, indexes)?;
|
||||
let p2pk65 = ComputedBlockFull::forced_import(db, "p2pk65_count", version, indexes)?;
|
||||
let p2pkh = ComputedBlockFull::forced_import(db, "p2pkh_count", version, indexes)?;
|
||||
let p2sh = ComputedBlockFull::forced_import(db, "p2sh_count", version, indexes)?;
|
||||
let p2tr = ComputedBlockFull::forced_import(db, "p2tr_count", version, indexes)?;
|
||||
let p2wpkh = ComputedBlockFull::forced_import(db, "p2wpkh_count", version, indexes)?;
|
||||
let p2wsh = ComputedBlockFull::forced_import(db, "p2wsh_count", version, indexes)?;
|
||||
|
||||
// Aggregate counts (computed from per-type counts)
|
||||
let indexes_to_segwit_count = ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"segwit_count",
|
||||
version,
|
||||
indexes,
|
||||
)?;
|
||||
let segwit = ComputedBlockFull::forced_import(db, "segwit_count", version, indexes)?;
|
||||
|
||||
// Adoption ratios (lazy)
|
||||
// Uses outputs.count.indexes_to_count as denominator (total output count)
|
||||
// Uses outputs.count.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 =
|
||||
BinaryBlockFull::from_height_and_txindex::<PercentageU64F32>(
|
||||
"taproot_adoption",
|
||||
version,
|
||||
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 =
|
||||
BinaryBlockFull::from_height_and_txindex::<PercentageU64F32>(
|
||||
"segwit_adoption",
|
||||
version,
|
||||
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,
|
||||
);
|
||||
let taproot_adoption = BinaryBlockFull::from_height_and_txindex::<PercentageU64F32>(
|
||||
"taproot_adoption",
|
||||
version,
|
||||
p2tr.height.boxed_clone(),
|
||||
outputs.count.total_count.height.sum_cum.sum.0.boxed_clone(),
|
||||
&p2tr,
|
||||
&outputs.count.total_count,
|
||||
);
|
||||
let segwit_adoption = BinaryBlockFull::from_height_and_txindex::<PercentageU64F32>(
|
||||
"segwit_adoption",
|
||||
version,
|
||||
segwit.height.boxed_clone(),
|
||||
outputs.count.total_count.height.sum_cum.sum.0.boxed_clone(),
|
||||
&segwit,
|
||||
&outputs.count.total_count,
|
||||
);
|
||||
|
||||
Ok(Self {
|
||||
indexes_to_p2a_count,
|
||||
indexes_to_p2ms_count,
|
||||
indexes_to_p2pk33_count,
|
||||
indexes_to_p2pk65_count,
|
||||
indexes_to_p2pkh_count,
|
||||
indexes_to_p2sh_count,
|
||||
indexes_to_p2tr_count,
|
||||
indexes_to_p2wpkh_count,
|
||||
indexes_to_p2wsh_count,
|
||||
indexes_to_opreturn_count: ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"opreturn_count",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
indexes_to_emptyoutput_count: ComputedBlockFull::forced_import(
|
||||
p2a,
|
||||
p2ms,
|
||||
p2pk33,
|
||||
p2pk65,
|
||||
p2pkh,
|
||||
p2sh,
|
||||
p2tr,
|
||||
p2wpkh,
|
||||
p2wsh,
|
||||
opreturn: ComputedBlockFull::forced_import(db, "opreturn_count", version, indexes)?,
|
||||
emptyoutput: ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"emptyoutput_count",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
indexes_to_unknownoutput_count: ComputedBlockFull::forced_import(
|
||||
unknownoutput: ComputedBlockFull::forced_import(
|
||||
db,
|
||||
"unknownoutput_count",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
indexes_to_segwit_count,
|
||||
indexes_to_taproot_adoption,
|
||||
indexes_to_segwit_adoption,
|
||||
segwit,
|
||||
taproot_adoption,
|
||||
segwit_adoption,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user