global: MASSIVE snapshot

This commit is contained in:
nym21
2026-02-23 17:22:12 +01:00
parent be0d749f9c
commit 3b7aa8242a
703 changed files with 29130 additions and 30779 deletions

View File

@@ -1,20 +1,19 @@
use brk_error::Result;
use brk_indexer::Indexer;
use brk_types::StoredU64;
use vecdb::{Exit, TypedVecIterator};
use vecdb::Exit;
use super::Vecs;
use crate::{ComputeIndexes, indexes};
use crate::ComputeIndexes;
impl Vecs {
pub fn compute(
pub(crate) fn compute(
&mut self,
indexer: &Indexer,
indexes: &indexes::Vecs,
starting_indexes: &ComputeIndexes,
exit: &Exit,
) -> Result<()> {
self.p2a.compute_all(indexes, starting_indexes, exit, |v| {
self.p2a.compute(starting_indexes, exit,|v| {
v.compute_count_from_indexes(
starting_indexes.height,
&indexer.vecs.addresses.first_p2aaddressindex,
@@ -25,7 +24,7 @@ impl Vecs {
})?;
self.p2ms
.compute_all(indexes, starting_indexes, exit, |v| {
.compute(starting_indexes, exit,|v| {
v.compute_count_from_indexes(
starting_indexes.height,
&indexer.vecs.scripts.first_p2msoutputindex,
@@ -36,7 +35,7 @@ impl Vecs {
})?;
self.p2pk33
.compute_all(indexes, starting_indexes, exit, |v| {
.compute(starting_indexes, exit,|v| {
v.compute_count_from_indexes(
starting_indexes.height,
&indexer.vecs.addresses.first_p2pk33addressindex,
@@ -47,7 +46,7 @@ impl Vecs {
})?;
self.p2pk65
.compute_all(indexes, starting_indexes, exit, |v| {
.compute(starting_indexes, exit,|v| {
v.compute_count_from_indexes(
starting_indexes.height,
&indexer.vecs.addresses.first_p2pk65addressindex,
@@ -58,7 +57,7 @@ impl Vecs {
})?;
self.p2pkh
.compute_all(indexes, starting_indexes, exit, |v| {
.compute(starting_indexes, exit,|v| {
v.compute_count_from_indexes(
starting_indexes.height,
&indexer.vecs.addresses.first_p2pkhaddressindex,
@@ -69,7 +68,7 @@ impl Vecs {
})?;
self.p2sh
.compute_all(indexes, starting_indexes, exit, |v| {
.compute(starting_indexes, exit,|v| {
v.compute_count_from_indexes(
starting_indexes.height,
&indexer.vecs.addresses.first_p2shaddressindex,
@@ -80,7 +79,7 @@ impl Vecs {
})?;
self.p2tr
.compute_all(indexes, starting_indexes, exit, |v| {
.compute(starting_indexes, exit,|v| {
v.compute_count_from_indexes(
starting_indexes.height,
&indexer.vecs.addresses.first_p2traddressindex,
@@ -91,7 +90,7 @@ impl Vecs {
})?;
self.p2wpkh
.compute_all(indexes, starting_indexes, exit, |v| {
.compute(starting_indexes, exit,|v| {
v.compute_count_from_indexes(
starting_indexes.height,
&indexer.vecs.addresses.first_p2wpkhaddressindex,
@@ -102,7 +101,7 @@ impl Vecs {
})?;
self.p2wsh
.compute_all(indexes, starting_indexes, exit, |v| {
.compute(starting_indexes, exit,|v| {
v.compute_count_from_indexes(
starting_indexes.height,
&indexer.vecs.addresses.first_p2wshaddressindex,
@@ -113,7 +112,7 @@ impl Vecs {
})?;
self.opreturn
.compute_all(indexes, starting_indexes, exit, |v| {
.compute(starting_indexes, exit,|v| {
v.compute_count_from_indexes(
starting_indexes.height,
&indexer.vecs.scripts.first_opreturnindex,
@@ -124,7 +123,7 @@ impl Vecs {
})?;
self.unknownoutput
.compute_all(indexes, starting_indexes, exit, |v| {
.compute(starting_indexes, exit,|v| {
v.compute_count_from_indexes(
starting_indexes.height,
&indexer.vecs.scripts.first_unknownoutputindex,
@@ -135,7 +134,7 @@ impl Vecs {
})?;
self.emptyoutput
.compute_all(indexes, starting_indexes, exit, |v| {
.compute(starting_indexes, exit,|v| {
v.compute_count_from_indexes(
starting_indexes.height,
&indexer.vecs.scripts.first_emptyoutputindex,
@@ -146,17 +145,15 @@ impl Vecs {
})?;
// Compute segwit = p2wpkh + p2wsh + p2tr
let mut p2wsh_iter = self.p2wsh.height.into_iter();
let mut p2tr_iter = self.p2tr.height.into_iter();
self.segwit
.compute_all(indexes, starting_indexes, exit, |v| {
v.compute_transform(
.compute(starting_indexes, exit,|v| {
v.compute_transform3(
starting_indexes.height,
&self.p2wpkh.height,
|(h, p2wpkh, ..)| {
let sum = *p2wpkh + *p2wsh_iter.get_unwrap(h) + *p2tr_iter.get_unwrap(h);
(h, StoredU64::from(sum))
&self.p2wsh.height,
&self.p2tr.height,
|(h, p2wpkh, p2wsh, p2tr, ..)| {
(h, StoredU64::from(*p2wpkh + *p2wsh + *p2tr))
},
exit,
)?;

View File

@@ -1,6 +1,6 @@
use brk_error::Result;
use brk_types::Version;
use vecdb::{Database, IterableCloneableVec};
use vecdb::{Database, ReadableCloneableVec};
use super::Vecs;
use crate::{
@@ -10,7 +10,7 @@ use crate::{
};
impl Vecs {
pub fn forced_import(
pub(crate) fn forced_import(
db: &Database,
version: Version,
indexes: &indexes::Vecs,
@@ -31,20 +31,20 @@ impl Vecs {
// Adoption ratios (lazy)
// Uses outputs.count.count as denominator (total output count)
// At height level: per-block ratio; at dateindex level: sum-based ratio (% of new outputs)
// At height level: per-block ratio; at day1 level: sum-based ratio (% of new outputs)
let taproot_adoption = LazyBinaryFromHeightFull::from_height_and_txindex::<PercentageU64F32>(
"taproot_adoption",
version,
p2tr.height.boxed_clone(),
outputs.count.total_count.height.sum_cum.sum.0.boxed_clone(),
p2tr.height.read_only_boxed_clone(),
outputs.count.total_count.height.sum_cum.sum.0.read_only_boxed_clone(),
&p2tr,
&outputs.count.total_count,
);
let segwit_adoption = LazyBinaryFromHeightFull::from_height_and_txindex::<PercentageU64F32>(
"segwit_adoption",
version,
segwit.height.boxed_clone(),
outputs.count.total_count.height.sum_cum.sum.0.boxed_clone(),
segwit.height.read_only_boxed_clone(),
outputs.count.total_count.height.sum_cum.sum.0.read_only_boxed_clone(),
&segwit,
&outputs.count.total_count,
);

View File

@@ -1,27 +1,28 @@
use brk_traversable::Traversable;
use brk_types::{StoredF32, StoredU64};
use vecdb::{Rw, StorageMode};
use crate::internal::{ComputedFromHeightFull, LazyBinaryFromHeightFull};
#[derive(Clone, Traversable)]
pub struct Vecs {
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
// Per-type output counts
pub p2a: ComputedFromHeightFull<StoredU64>,
pub p2ms: ComputedFromHeightFull<StoredU64>,
pub p2pk33: ComputedFromHeightFull<StoredU64>,
pub p2pk65: ComputedFromHeightFull<StoredU64>,
pub p2pkh: ComputedFromHeightFull<StoredU64>,
pub p2sh: ComputedFromHeightFull<StoredU64>,
pub p2tr: ComputedFromHeightFull<StoredU64>,
pub p2wpkh: ComputedFromHeightFull<StoredU64>,
pub p2wsh: ComputedFromHeightFull<StoredU64>,
pub opreturn: ComputedFromHeightFull<StoredU64>,
pub emptyoutput: ComputedFromHeightFull<StoredU64>,
pub unknownoutput: ComputedFromHeightFull<StoredU64>,
pub p2a: ComputedFromHeightFull<StoredU64, M>,
pub p2ms: ComputedFromHeightFull<StoredU64, M>,
pub p2pk33: ComputedFromHeightFull<StoredU64, M>,
pub p2pk65: ComputedFromHeightFull<StoredU64, M>,
pub p2pkh: ComputedFromHeightFull<StoredU64, M>,
pub p2sh: ComputedFromHeightFull<StoredU64, M>,
pub p2tr: ComputedFromHeightFull<StoredU64, M>,
pub p2wpkh: ComputedFromHeightFull<StoredU64, M>,
pub p2wsh: ComputedFromHeightFull<StoredU64, M>,
pub opreturn: ComputedFromHeightFull<StoredU64, M>,
pub emptyoutput: ComputedFromHeightFull<StoredU64, M>,
pub unknownoutput: ComputedFromHeightFull<StoredU64, M>,
// Aggregate counts
/// SegWit output count (p2wpkh + p2wsh + p2tr)
pub segwit: ComputedFromHeightFull<StoredU64>,
pub segwit: ComputedFromHeightFull<StoredU64, M>,
// Adoption ratios
pub taproot_adoption: LazyBinaryFromHeightFull<StoredF32, StoredU64, StoredU64>,