mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-25 07:09:59 -07:00
computer: simplified a bunch of things
This commit is contained in:
@@ -130,9 +130,9 @@ impl Vecs {
|
||||
self.segwit.compute(starting_indexes.height, &window_starts, exit, |v| {
|
||||
Ok(v.compute_transform3(
|
||||
starting_indexes.height,
|
||||
&self.p2wpkh.last.height,
|
||||
&self.p2wsh.last.height,
|
||||
&self.p2tr.last.height,
|
||||
&self.p2wpkh.height,
|
||||
&self.p2wsh.height,
|
||||
&self.p2tr.height,
|
||||
|(h, p2wpkh, p2wsh, p2tr, ..)| {
|
||||
(h, StoredU64::from(*p2wpkh + *p2wsh + *p2tr))
|
||||
},
|
||||
@@ -143,8 +143,8 @@ impl Vecs {
|
||||
// Adoption ratios: per-block ratio of script type / total outputs
|
||||
self.taproot_adoption.height.compute_transform2(
|
||||
starting_indexes.height,
|
||||
&self.p2tr.last.height,
|
||||
&outputs_count.total_count.sum_cum.sum.0,
|
||||
&self.p2tr.height,
|
||||
&outputs_count.total_count.sum_cumulative.sum.0,
|
||||
|(h, p2tr, total, ..)| {
|
||||
let ratio = if *total > 0 {
|
||||
StoredF32::from(*p2tr as f64 / *total as f64)
|
||||
@@ -158,8 +158,8 @@ impl Vecs {
|
||||
|
||||
self.segwit_adoption.height.compute_transform2(
|
||||
starting_indexes.height,
|
||||
&self.segwit.last.height,
|
||||
&outputs_count.total_count.sum_cum.sum.0,
|
||||
&self.segwit.height,
|
||||
&outputs_count.total_count.sum_cumulative.sum.0,
|
||||
|(h, segwit, total, ..)| {
|
||||
let ratio = if *total > 0 {
|
||||
StoredF32::from(*segwit as f64 / *total as f64)
|
||||
|
||||
@@ -5,7 +5,7 @@ use vecdb::Database;
|
||||
use super::Vecs;
|
||||
use crate::{
|
||||
indexes,
|
||||
internal::{ComputedFromHeightCumSum, ComputedFromHeightLast},
|
||||
internal::{ComputedFromHeightCumulativeSum, ComputedFromHeightLast},
|
||||
};
|
||||
|
||||
impl Vecs {
|
||||
@@ -14,20 +14,20 @@ impl Vecs {
|
||||
version: Version,
|
||||
indexes: &indexes::Vecs,
|
||||
) -> Result<Self> {
|
||||
let p2a = ComputedFromHeightCumSum::forced_import(db, "p2a_count", version, indexes)?;
|
||||
let p2ms = ComputedFromHeightCumSum::forced_import(db, "p2ms_count", version, indexes)?;
|
||||
let p2a = ComputedFromHeightCumulativeSum::forced_import(db, "p2a_count", version, indexes)?;
|
||||
let p2ms = ComputedFromHeightCumulativeSum::forced_import(db, "p2ms_count", version, indexes)?;
|
||||
let p2pk33 =
|
||||
ComputedFromHeightCumSum::forced_import(db, "p2pk33_count", version, indexes)?;
|
||||
ComputedFromHeightCumulativeSum::forced_import(db, "p2pk33_count", version, indexes)?;
|
||||
let p2pk65 =
|
||||
ComputedFromHeightCumSum::forced_import(db, "p2pk65_count", version, indexes)?;
|
||||
let p2pkh = ComputedFromHeightCumSum::forced_import(db, "p2pkh_count", version, indexes)?;
|
||||
let p2sh = ComputedFromHeightCumSum::forced_import(db, "p2sh_count", version, indexes)?;
|
||||
let p2tr = ComputedFromHeightCumSum::forced_import(db, "p2tr_count", version, indexes)?;
|
||||
ComputedFromHeightCumulativeSum::forced_import(db, "p2pk65_count", version, indexes)?;
|
||||
let p2pkh = ComputedFromHeightCumulativeSum::forced_import(db, "p2pkh_count", version, indexes)?;
|
||||
let p2sh = ComputedFromHeightCumulativeSum::forced_import(db, "p2sh_count", version, indexes)?;
|
||||
let p2tr = ComputedFromHeightCumulativeSum::forced_import(db, "p2tr_count", version, indexes)?;
|
||||
let p2wpkh =
|
||||
ComputedFromHeightCumSum::forced_import(db, "p2wpkh_count", version, indexes)?;
|
||||
let p2wsh = ComputedFromHeightCumSum::forced_import(db, "p2wsh_count", version, indexes)?;
|
||||
ComputedFromHeightCumulativeSum::forced_import(db, "p2wpkh_count", version, indexes)?;
|
||||
let p2wsh = ComputedFromHeightCumulativeSum::forced_import(db, "p2wsh_count", version, indexes)?;
|
||||
let segwit =
|
||||
ComputedFromHeightCumSum::forced_import(db, "segwit_count", version, indexes)?;
|
||||
ComputedFromHeightCumulativeSum::forced_import(db, "segwit_count", version, indexes)?;
|
||||
|
||||
Ok(Self {
|
||||
p2a,
|
||||
@@ -39,19 +39,19 @@ impl Vecs {
|
||||
p2tr,
|
||||
p2wpkh,
|
||||
p2wsh,
|
||||
opreturn: ComputedFromHeightCumSum::forced_import(
|
||||
opreturn: ComputedFromHeightCumulativeSum::forced_import(
|
||||
db,
|
||||
"opreturn_count",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
emptyoutput: ComputedFromHeightCumSum::forced_import(
|
||||
emptyoutput: ComputedFromHeightCumulativeSum::forced_import(
|
||||
db,
|
||||
"emptyoutput_count",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
unknownoutput: ComputedFromHeightCumSum::forced_import(
|
||||
unknownoutput: ComputedFromHeightCumulativeSum::forced_import(
|
||||
db,
|
||||
"unknownoutput_count",
|
||||
version,
|
||||
|
||||
@@ -2,27 +2,27 @@ use brk_traversable::Traversable;
|
||||
use brk_types::{StoredF32, StoredU64};
|
||||
use vecdb::{Rw, StorageMode};
|
||||
|
||||
use crate::internal::{ComputedFromHeightCumSum, ComputedFromHeightLast};
|
||||
use crate::internal::{ComputedFromHeightCumulativeSum, ComputedFromHeightLast};
|
||||
|
||||
#[derive(Traversable)]
|
||||
pub struct Vecs<M: StorageMode = Rw> {
|
||||
// Per-type output counts
|
||||
pub p2a: ComputedFromHeightCumSum<StoredU64, M>,
|
||||
pub p2ms: ComputedFromHeightCumSum<StoredU64, M>,
|
||||
pub p2pk33: ComputedFromHeightCumSum<StoredU64, M>,
|
||||
pub p2pk65: ComputedFromHeightCumSum<StoredU64, M>,
|
||||
pub p2pkh: ComputedFromHeightCumSum<StoredU64, M>,
|
||||
pub p2sh: ComputedFromHeightCumSum<StoredU64, M>,
|
||||
pub p2tr: ComputedFromHeightCumSum<StoredU64, M>,
|
||||
pub p2wpkh: ComputedFromHeightCumSum<StoredU64, M>,
|
||||
pub p2wsh: ComputedFromHeightCumSum<StoredU64, M>,
|
||||
pub opreturn: ComputedFromHeightCumSum<StoredU64, M>,
|
||||
pub emptyoutput: ComputedFromHeightCumSum<StoredU64, M>,
|
||||
pub unknownoutput: ComputedFromHeightCumSum<StoredU64, M>,
|
||||
pub p2a: ComputedFromHeightCumulativeSum<StoredU64, M>,
|
||||
pub p2ms: ComputedFromHeightCumulativeSum<StoredU64, M>,
|
||||
pub p2pk33: ComputedFromHeightCumulativeSum<StoredU64, M>,
|
||||
pub p2pk65: ComputedFromHeightCumulativeSum<StoredU64, M>,
|
||||
pub p2pkh: ComputedFromHeightCumulativeSum<StoredU64, M>,
|
||||
pub p2sh: ComputedFromHeightCumulativeSum<StoredU64, M>,
|
||||
pub p2tr: ComputedFromHeightCumulativeSum<StoredU64, M>,
|
||||
pub p2wpkh: ComputedFromHeightCumulativeSum<StoredU64, M>,
|
||||
pub p2wsh: ComputedFromHeightCumulativeSum<StoredU64, M>,
|
||||
pub opreturn: ComputedFromHeightCumulativeSum<StoredU64, M>,
|
||||
pub emptyoutput: ComputedFromHeightCumulativeSum<StoredU64, M>,
|
||||
pub unknownoutput: ComputedFromHeightCumulativeSum<StoredU64, M>,
|
||||
|
||||
// Aggregate counts
|
||||
/// SegWit output count (p2wpkh + p2wsh + p2tr)
|
||||
pub segwit: ComputedFromHeightCumSum<StoredU64, M>,
|
||||
pub segwit: ComputedFromHeightCumulativeSum<StoredU64, M>,
|
||||
|
||||
// Adoption ratios (stored per-block, lazy period views)
|
||||
pub taproot_adoption: ComputedFromHeightLast<StoredF32, M>,
|
||||
|
||||
Reference in New Issue
Block a user