mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-25 23:29:58 -07:00
global: adding semester + making coarser intervals computed instead of eager
This commit is contained in:
@@ -18,7 +18,7 @@ use crate::{
|
||||
BlockState, SupplyState, Transacted,
|
||||
stores::Stores,
|
||||
vecs::{
|
||||
grouped::ComputedVecsFromHeight,
|
||||
grouped::{ComputedVecsFromHeight, Source},
|
||||
market,
|
||||
stateful::{
|
||||
addresstype_to_addresscount::AddressTypeToAddressCount,
|
||||
@@ -31,7 +31,7 @@ use crate::{
|
||||
|
||||
use super::{
|
||||
Indexes, fetched,
|
||||
grouped::{ComputedValueVecsFromHeight, StorableVecGeneatorOptions},
|
||||
grouped::{ComputedValueVecsFromHeight, EagerVecBuilderOptions},
|
||||
indexes, transactions,
|
||||
};
|
||||
|
||||
@@ -78,7 +78,7 @@ impl Vecs {
|
||||
pub fn forced_import(
|
||||
path: &Path,
|
||||
version: Version,
|
||||
_computation: Computation,
|
||||
computation: Computation,
|
||||
format: Format,
|
||||
fetched: Option<&fetched::Vecs>,
|
||||
) -> color_eyre::Result<Self> {
|
||||
@@ -106,10 +106,11 @@ impl Vecs {
|
||||
indexes_to_unspendable_supply: ComputedValueVecsFromHeight::forced_import(
|
||||
path,
|
||||
"unspendable_supply",
|
||||
false,
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
computation,
|
||||
EagerVecBuilderOptions::default().add_last(),
|
||||
compute_dollars,
|
||||
)?,
|
||||
height_to_opreturn_supply: EagerVec::forced_import(
|
||||
@@ -121,27 +122,30 @@ impl Vecs {
|
||||
indexes_to_opreturn_supply: ComputedValueVecsFromHeight::forced_import(
|
||||
path,
|
||||
"opreturn_supply",
|
||||
false,
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
computation,
|
||||
EagerVecBuilderOptions::default().add_last(),
|
||||
compute_dollars,
|
||||
)?,
|
||||
indexes_to_address_count: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
"address_count",
|
||||
true,
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
computation,
|
||||
EagerVecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
indexes_to_empty_address_count: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
"empty_address_count",
|
||||
true,
|
||||
Source::Compute,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
computation,
|
||||
EagerVecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
addresstype_to_height_to_address_count: AddressTypeToHeightToAddressCount::from(
|
||||
ByAddressType {
|
||||
@@ -252,66 +256,74 @@ impl Vecs {
|
||||
p2pk65: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
"p2pk65_address_count",
|
||||
false,
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
computation,
|
||||
EagerVecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
p2pk33: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
"p2pk33_address_count",
|
||||
false,
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
computation,
|
||||
EagerVecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
p2pkh: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
"p2pkh_address_count",
|
||||
false,
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
computation,
|
||||
EagerVecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
p2sh: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
"p2sh_address_count",
|
||||
false,
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
computation,
|
||||
EagerVecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
p2wpkh: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
"p2wpkh_address_count",
|
||||
false,
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
computation,
|
||||
EagerVecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
p2wsh: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
"p2wsh_address_count",
|
||||
false,
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
computation,
|
||||
EagerVecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
p2tr: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
"p2tr_address_count",
|
||||
false,
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
computation,
|
||||
EagerVecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
p2a: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
"p2a_address_count",
|
||||
false,
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
computation,
|
||||
EagerVecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
},
|
||||
),
|
||||
@@ -320,73 +332,81 @@ impl Vecs {
|
||||
p2pk65: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
"p2pk65_empty_address_count",
|
||||
false,
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
computation,
|
||||
EagerVecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
p2pk33: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
"p2pk33_empty_address_count",
|
||||
false,
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
computation,
|
||||
EagerVecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
p2pkh: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
"p2pkh_empty_address_count",
|
||||
false,
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
computation,
|
||||
EagerVecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
p2sh: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
"p2sh_empty_address_count",
|
||||
false,
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
computation,
|
||||
EagerVecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
p2wpkh: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
"p2wpkh_empty_address_count",
|
||||
false,
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
computation,
|
||||
EagerVecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
p2wsh: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
"p2wsh_empty_address_count",
|
||||
false,
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
computation,
|
||||
EagerVecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
p2tr: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
"p2tr_empty_address_count",
|
||||
false,
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
computation,
|
||||
EagerVecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
p2a: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
"p2a_empty_address_count",
|
||||
false,
|
||||
Source::None,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
computation,
|
||||
EagerVecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
},
|
||||
),
|
||||
utxo_vecs: utxo_cohorts::Vecs::forced_import(
|
||||
path,
|
||||
version,
|
||||
_computation,
|
||||
computation,
|
||||
format,
|
||||
fetched,
|
||||
&states_path,
|
||||
@@ -394,7 +414,7 @@ impl Vecs {
|
||||
address_vecs: address_cohorts::Vecs::forced_import(
|
||||
path,
|
||||
version,
|
||||
_computation,
|
||||
computation,
|
||||
format,
|
||||
fetched,
|
||||
&states_path,
|
||||
@@ -1302,34 +1322,37 @@ impl Vecs {
|
||||
|
||||
// Capped as external drives (even thunderbolt 4 SSDs) can be overwhelmed
|
||||
let chunk_size = (vecs.len() as f64 / 3.0).ceil() as usize;
|
||||
vecs.into_par_iter().chunks(chunk_size).try_for_each(|v| {
|
||||
v.into_iter().try_for_each(|either| match either {
|
||||
Either::Left(v) => v.compute_rest_part2(
|
||||
indexer,
|
||||
indexes,
|
||||
fetched,
|
||||
starting_indexes,
|
||||
market,
|
||||
&height_to_supply,
|
||||
dateindex_to_supply_ref,
|
||||
height_to_realized_cap_ref,
|
||||
dateindex_to_realized_cap_ref,
|
||||
exit,
|
||||
),
|
||||
Either::Right(v) => v.compute_rest_part2(
|
||||
indexer,
|
||||
indexes,
|
||||
fetched,
|
||||
starting_indexes,
|
||||
market,
|
||||
&height_to_supply,
|
||||
dateindex_to_supply_ref,
|
||||
height_to_realized_cap_ref,
|
||||
dateindex_to_realized_cap_ref,
|
||||
exit,
|
||||
),
|
||||
})
|
||||
})?;
|
||||
vecs.into_par_iter()
|
||||
// .into_iter()
|
||||
.chunks(chunk_size)
|
||||
.try_for_each(|v| {
|
||||
v.into_iter().try_for_each(|either| match either {
|
||||
Either::Left(v) => v.compute_rest_part2(
|
||||
indexer,
|
||||
indexes,
|
||||
fetched,
|
||||
starting_indexes,
|
||||
market,
|
||||
&height_to_supply,
|
||||
dateindex_to_supply_ref,
|
||||
height_to_realized_cap_ref,
|
||||
dateindex_to_realized_cap_ref,
|
||||
exit,
|
||||
),
|
||||
Either::Right(v) => v.compute_rest_part2(
|
||||
indexer,
|
||||
indexes,
|
||||
fetched,
|
||||
starting_indexes,
|
||||
market,
|
||||
&height_to_supply,
|
||||
dateindex_to_supply_ref,
|
||||
height_to_realized_cap_ref,
|
||||
dateindex_to_realized_cap_ref,
|
||||
exit,
|
||||
),
|
||||
})
|
||||
})?;
|
||||
|
||||
self.indexes_to_unspendable_supply.compute_rest(
|
||||
indexer,
|
||||
|
||||
Reference in New Issue
Block a user