mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-24 17:38:09 -07:00
websites: snapshot + todo: init
This commit is contained in:
@@ -24,6 +24,7 @@ where
|
||||
pub difficultyepoch: ComputedVecBuilder<DifficultyEpoch, T>,
|
||||
pub monthindex: ComputedVecBuilder<MonthIndex, T>,
|
||||
pub quarterindex: ComputedVecBuilder<QuarterIndex, T>,
|
||||
// 6 months
|
||||
pub yearindex: ComputedVecBuilder<YearIndex, T>,
|
||||
// TODO: pub halvingepoch: StorableVecGeneator<Halvingepoch, T>,
|
||||
pub decadeindex: ComputedVecBuilder<DecadeIndex, T>,
|
||||
@@ -144,9 +145,9 @@ where
|
||||
indexes: &indexes::Vecs,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
height: Option<&impl AnyIterableVec<Height, T>>,
|
||||
height_vec: Option<&impl AnyIterableVec<Height, T>>,
|
||||
) -> color_eyre::Result<()> {
|
||||
if let Some(height) = height {
|
||||
if let Some(height) = height_vec {
|
||||
self.height_extra
|
||||
.extend(starting_indexes.height, height, exit)?;
|
||||
|
||||
|
||||
@@ -10,7 +10,9 @@ use brk_vec::{
|
||||
use crate::{
|
||||
states::AddressCohortState,
|
||||
vecs::{
|
||||
Indexes, fetched, indexes, market,
|
||||
Indexes, fetched,
|
||||
grouped::{ComputedVecsFromHeight, StorableVecGeneatorOptions},
|
||||
indexes, market,
|
||||
stateful::{
|
||||
common,
|
||||
r#trait::{CohortVecs, DynCohortVecs},
|
||||
@@ -26,9 +28,10 @@ pub struct Vecs {
|
||||
|
||||
pub state: AddressCohortState,
|
||||
|
||||
pub height_to_address_count: EagerVec<Height, StoredUsize>,
|
||||
|
||||
pub inner: common::Vecs,
|
||||
|
||||
pub height_to_address_count: EagerVec<Height, StoredUsize>,
|
||||
pub indexes_to_address_count: ComputedVecsFromHeight<StoredUsize>,
|
||||
}
|
||||
|
||||
impl Vecs {
|
||||
@@ -60,6 +63,14 @@ impl Vecs {
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
indexes_to_address_count: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
&suffix("address_count"),
|
||||
false,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
)?,
|
||||
inner: common::Vecs::forced_import(
|
||||
path,
|
||||
cohort_name,
|
||||
@@ -160,12 +171,24 @@ impl DynCohortVecs for Vecs {
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
) -> color_eyre::Result<()> {
|
||||
self.indexes_to_address_count.compute_rest(
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
Some(&self.height_to_address_count),
|
||||
)?;
|
||||
|
||||
self.inner
|
||||
.compute_rest_part1(indexer, indexes, fetched, starting_indexes, exit)
|
||||
}
|
||||
|
||||
fn vecs(&self) -> Vec<&dyn AnyCollectableVec> {
|
||||
[self.inner.vecs(), vec![&self.height_to_address_count]].concat()
|
||||
[
|
||||
self.inner.vecs(),
|
||||
self.indexes_to_address_count.vecs(),
|
||||
vec![&self.height_to_address_count],
|
||||
]
|
||||
.concat()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::{cmp::Ordering, collections::BTreeMap, mem, path::Path, thread};
|
||||
|
||||
use brk_core::{
|
||||
AddressData, CheckedSub, DateIndex, Dollars, EmptyAddressData, GroupedByAddressType, Height,
|
||||
InputIndex, OutputIndex, OutputType, Result, Sats, TypeIndex, Version,
|
||||
InputIndex, OutputIndex, OutputType, Result, Sats, StoredUsize, TypeIndex, Version,
|
||||
};
|
||||
use brk_exit::Exit;
|
||||
use brk_indexer::Indexer;
|
||||
@@ -17,6 +17,7 @@ use crate::{
|
||||
BlockState, SupplyState, Transacted,
|
||||
stores::Stores,
|
||||
vecs::{
|
||||
grouped::ComputedVecsFromHeight,
|
||||
market,
|
||||
stateful::{
|
||||
addresstype_to_addresscount::AddressTypeToAddressCount,
|
||||
@@ -52,18 +53,19 @@ const VERSION: Version = Version::new(11);
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Vecs {
|
||||
chain_state: StoredVec<Height, SupplyState>,
|
||||
pub chain_state: StoredVec<Height, SupplyState>,
|
||||
|
||||
pub height_to_unspendable_supply: EagerVec<Height, Sats>,
|
||||
pub indexes_to_unspendable_supply: ComputedValueVecsFromHeight,
|
||||
pub height_to_opreturn_supply: EagerVec<Height, Sats>,
|
||||
pub indexes_to_opreturn_supply: ComputedValueVecsFromHeight,
|
||||
// pub height_to_address_count: EagerVec<Height, StoredUsize>,
|
||||
// pub height_to_empty_address_count: EagerVec<Height, StoredUsize>,
|
||||
pub addresstype_to_height_to_address_count: AddressTypeToAddressCountVec,
|
||||
pub addresstype_to_height_to_empty_address_count: AddressTypeToAddressCountVec,
|
||||
pub utxo_vecs: utxo_cohorts::Vecs,
|
||||
pub address_vecs: address_cohorts::Vecs,
|
||||
|
||||
pub indexes_to_address_count: ComputedVecsFromHeight<StoredUsize>,
|
||||
pub indexes_to_empty_address_count: ComputedVecsFromHeight<StoredUsize>,
|
||||
}
|
||||
|
||||
impl Vecs {
|
||||
@@ -119,18 +121,22 @@ impl Vecs {
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
compute_dollars,
|
||||
)?,
|
||||
// height_to_address_count: EagerVec::forced_import(
|
||||
// path,
|
||||
// "address_count",
|
||||
// version + VERSION + Version::ZERO,
|
||||
// format,
|
||||
// )?,
|
||||
// height_to_empty_address_count: EagerVec::forced_import(
|
||||
// path,
|
||||
// "empty_address_count",
|
||||
// version + VERSION + Version::ZERO,
|
||||
// format,
|
||||
// )?,
|
||||
indexes_to_address_count: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
"address_count",
|
||||
true,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
)?,
|
||||
indexes_to_empty_address_count: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
"empty_address_count",
|
||||
true,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
)?,
|
||||
addresstype_to_height_to_address_count: AddressTypeToAddressCountVec::from(
|
||||
GroupedByAddressType {
|
||||
p2pk65: EagerVec::forced_import(
|
||||
@@ -976,6 +982,7 @@ impl Vecs {
|
||||
.as_mut()
|
||||
.map(|v| is_date_last_height.then(|| *v.unwrap_get_inner(dateindex)));
|
||||
|
||||
let dateindex = is_date_last_height.then_some(dateindex);
|
||||
separate_utxo_vecs
|
||||
.into_par_iter()
|
||||
.map(|(_, v)| v as &mut dyn DynCohortVecs).chain(
|
||||
@@ -987,7 +994,7 @@ impl Vecs {
|
||||
v.compute_then_force_push_unrealized_states(
|
||||
height,
|
||||
price,
|
||||
is_date_last_height.then_some(dateindex),
|
||||
dateindex,
|
||||
date_price,
|
||||
exit,
|
||||
)
|
||||
@@ -1039,6 +1046,44 @@ impl Vecs {
|
||||
|
||||
info!("Computing rest part 1...");
|
||||
|
||||
self.indexes_to_address_count.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_sum_of_others(
|
||||
starting_indexes.height,
|
||||
&self
|
||||
.addresstype_to_height_to_address_count
|
||||
.as_typed_vec()
|
||||
.into_iter()
|
||||
.map(|(_, v)| v)
|
||||
.collect::<Vec<_>>(),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
)?;
|
||||
|
||||
self.indexes_to_empty_address_count.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_sum_of_others(
|
||||
starting_indexes.height,
|
||||
&self
|
||||
.addresstype_to_height_to_empty_address_count
|
||||
.as_typed_vec()
|
||||
.into_iter()
|
||||
.map(|(_, v)| v)
|
||||
.collect::<Vec<_>>(),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
)?;
|
||||
|
||||
thread::scope(|scope| {
|
||||
scope.spawn(|| {
|
||||
self.utxo_vecs
|
||||
@@ -1194,6 +1239,8 @@ impl Vecs {
|
||||
.collect::<Vec<_>>(),
|
||||
self.indexes_to_unspendable_supply.vecs(),
|
||||
self.indexes_to_opreturn_supply.vecs(),
|
||||
self.indexes_to_address_count.vecs(),
|
||||
self.indexes_to_empty_address_count.vecs(),
|
||||
self.addresstype_to_height_to_address_count
|
||||
.as_typed_vec()
|
||||
.into_iter()
|
||||
@@ -1207,8 +1254,6 @@ impl Vecs {
|
||||
vec![
|
||||
&self.height_to_unspendable_supply,
|
||||
&self.height_to_opreturn_supply,
|
||||
// &self.height_to_address_count,
|
||||
// &self.height_to_empty_address_count,
|
||||
],
|
||||
]
|
||||
.into_iter()
|
||||
|
||||
Reference in New Issue
Block a user