mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-05-01 18:09:59 -07:00
global: BIG snapshot
This commit is contained in:
@@ -5,12 +5,12 @@ use brk_cohort::{
|
||||
};
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Bitcoin, DateIndex, Dollars, Height, Version};
|
||||
use brk_types::{DateIndex, Dollars, Height, Version};
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use rayon::prelude::*;
|
||||
use vecdb::{AnyStoredVec, Database, Exit, IterableVec};
|
||||
|
||||
use crate::{ComputeIndexes, indexes, price, distribution::DynCohortVecs};
|
||||
use crate::{ComputeIndexes, distribution::DynCohortVecs, indexes, price};
|
||||
|
||||
use crate::distribution::metrics::SupplyMetrics;
|
||||
|
||||
@@ -35,7 +35,7 @@ impl AddressCohorts {
|
||||
states_path: &Path,
|
||||
all_supply: Option<&SupplyMetrics>,
|
||||
) -> Result<Self> {
|
||||
let v = version + VERSION + Version::ZERO;
|
||||
let v = version + VERSION;
|
||||
|
||||
// Helper to create a cohort - only amount_range cohorts have state
|
||||
let create = |filter: Filter,
|
||||
@@ -119,18 +119,16 @@ impl AddressCohorts {
|
||||
|
||||
/// Second phase of post-processing: compute relative metrics.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn compute_rest_part2<S, HM, DM>(
|
||||
pub fn compute_rest_part2<HM, DM>(
|
||||
&mut self,
|
||||
indexes: &indexes::Vecs,
|
||||
price: Option<&price::Vecs>,
|
||||
starting_indexes: &ComputeIndexes,
|
||||
height_to_supply: &S,
|
||||
height_to_market_cap: Option<&HM>,
|
||||
dateindex_to_market_cap: Option<&DM>,
|
||||
exit: &Exit,
|
||||
) -> Result<()>
|
||||
where
|
||||
S: IterableVec<Height, Bitcoin> + Sync,
|
||||
HM: IterableVec<Height, Dollars> + Sync,
|
||||
DM: IterableVec<DateIndex, Dollars> + Sync,
|
||||
{
|
||||
@@ -139,7 +137,6 @@ impl AddressCohorts {
|
||||
indexes,
|
||||
price,
|
||||
starting_indexes,
|
||||
height_to_supply,
|
||||
height_to_market_cap,
|
||||
dateindex_to_market_cap,
|
||||
exit,
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::path::Path;
|
||||
use brk_cohort::{CohortContext, Filter, Filtered};
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Bitcoin, DateIndex, Dollars, Height, StoredU64, Version};
|
||||
use brk_types::{DateIndex, Dollars, Height, StoredU64, Version};
|
||||
use rayon::prelude::*;
|
||||
use vecdb::{
|
||||
AnyStoredVec, AnyVec, Database, EagerVec, Exit, GenericStoredVec, ImportableVec,
|
||||
@@ -12,9 +12,10 @@ use vecdb::{
|
||||
|
||||
use crate::{
|
||||
ComputeIndexes,
|
||||
internal::{ComputedVecsFromHeight, Source, VecBuilderOptions},
|
||||
indexes, price,
|
||||
distribution::state::AddressCohortState,
|
||||
indexes,
|
||||
internal::{ComputedVecsFromHeight, Source, VecBuilderOptions},
|
||||
price,
|
||||
};
|
||||
|
||||
use crate::distribution::metrics::{CohortMetrics, ImportConfig, SupplyMetrics};
|
||||
@@ -73,11 +74,8 @@ impl AddressCohortVecs {
|
||||
price,
|
||||
};
|
||||
|
||||
let height_to_addr_count = EagerVec::forced_import(
|
||||
db,
|
||||
&cfg.name("addr_count"),
|
||||
version + VERSION + Version::ZERO,
|
||||
)?;
|
||||
let height_to_addr_count =
|
||||
EagerVec::forced_import(db, &cfg.name("addr_count"), version + VERSION)?;
|
||||
|
||||
Ok(Self {
|
||||
starting_height: None,
|
||||
@@ -91,7 +89,7 @@ impl AddressCohortVecs {
|
||||
db,
|
||||
&cfg.name("addr_count"),
|
||||
Source::Vec(height_to_addr_count.boxed_clone()),
|
||||
version + VERSION + Version::ZERO,
|
||||
version + VERSION,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -290,7 +288,6 @@ impl CohortVecs for AddressCohortVecs {
|
||||
indexes: &indexes::Vecs,
|
||||
price: Option<&price::Vecs>,
|
||||
starting_indexes: &ComputeIndexes,
|
||||
height_to_supply: &impl IterableVec<Height, Bitcoin>,
|
||||
height_to_market_cap: Option<&impl IterableVec<Height, Dollars>>,
|
||||
dateindex_to_market_cap: Option<&impl IterableVec<DateIndex, Dollars>>,
|
||||
exit: &Exit,
|
||||
@@ -299,7 +296,6 @@ impl CohortVecs for AddressCohortVecs {
|
||||
indexes,
|
||||
price,
|
||||
starting_indexes,
|
||||
height_to_supply,
|
||||
height_to_market_cap,
|
||||
dateindex_to_market_cap,
|
||||
exit,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use brk_error::Result;
|
||||
use brk_types::{Bitcoin, DateIndex, Dollars, Height, Version};
|
||||
use brk_types::{DateIndex, Dollars, Height, Version};
|
||||
use vecdb::{Exit, IterableVec};
|
||||
|
||||
use crate::{ComputeIndexes, indexes, price};
|
||||
@@ -63,7 +63,6 @@ pub trait CohortVecs: DynCohortVecs {
|
||||
indexes: &indexes::Vecs,
|
||||
price: Option<&price::Vecs>,
|
||||
starting_indexes: &ComputeIndexes,
|
||||
height_to_supply: &impl IterableVec<Height, Bitcoin>,
|
||||
height_to_market_cap: Option<&impl IterableVec<Height, Dollars>>,
|
||||
dateindex_to_market_cap: Option<&impl IterableVec<DateIndex, Dollars>>,
|
||||
exit: &Exit,
|
||||
|
||||
@@ -6,16 +6,17 @@ use brk_cohort::{
|
||||
};
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Bitcoin, DateIndex, Dollars, Height, Sats, Version};
|
||||
use brk_types::{DateIndex, Dollars, Height, Sats, Version};
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use rayon::prelude::*;
|
||||
use vecdb::{AnyStoredVec, Database, Exit, IterableVec};
|
||||
|
||||
use crate::{
|
||||
ComputeIndexes,
|
||||
internal::{PERCENTILES, PERCENTILES_LEN},
|
||||
indexes, price,
|
||||
distribution::DynCohortVecs,
|
||||
indexes,
|
||||
internal::{PERCENTILES, PERCENTILES_LEN},
|
||||
price,
|
||||
};
|
||||
|
||||
use super::{super::traits::CohortVecs, vecs::UTXOCohortVecs};
|
||||
@@ -35,7 +36,7 @@ impl UTXOCohorts {
|
||||
price: Option<&price::Vecs>,
|
||||
states_path: &Path,
|
||||
) -> Result<Self> {
|
||||
let v = version + VERSION + Version::ZERO;
|
||||
let v = version + VERSION;
|
||||
|
||||
// Create "all" cohort first - it doesn't need global sources (it IS the global source)
|
||||
let all = UTXOCohortVecs::forced_import(
|
||||
@@ -202,18 +203,16 @@ impl UTXOCohorts {
|
||||
|
||||
/// Second phase of post-processing: compute relative metrics.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn compute_rest_part2<S, HM, DM>(
|
||||
pub fn compute_rest_part2<HM, DM>(
|
||||
&mut self,
|
||||
indexes: &indexes::Vecs,
|
||||
price: Option<&price::Vecs>,
|
||||
starting_indexes: &ComputeIndexes,
|
||||
height_to_supply: &S,
|
||||
height_to_market_cap: Option<&HM>,
|
||||
dateindex_to_market_cap: Option<&DM>,
|
||||
exit: &Exit,
|
||||
) -> Result<()>
|
||||
where
|
||||
S: IterableVec<Height, Bitcoin> + Sync,
|
||||
HM: IterableVec<Height, Dollars> + Sync,
|
||||
DM: IterableVec<DateIndex, Dollars> + Sync,
|
||||
{
|
||||
@@ -222,7 +221,6 @@ impl UTXOCohorts {
|
||||
indexes,
|
||||
price,
|
||||
starting_indexes,
|
||||
height_to_supply,
|
||||
height_to_market_cap,
|
||||
dateindex_to_market_cap,
|
||||
exit,
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::path::Path;
|
||||
use brk_cohort::{CohortContext, Filter, Filtered, StateLevel};
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Bitcoin, DateIndex, Dollars, Height, Version};
|
||||
use brk_types::{DateIndex, Dollars, Height, Version};
|
||||
use rayon::prelude::*;
|
||||
use vecdb::{AnyStoredVec, Database, Exit, IterableVec};
|
||||
|
||||
@@ -242,7 +242,6 @@ impl CohortVecs for UTXOCohortVecs {
|
||||
indexes: &indexes::Vecs,
|
||||
price: Option<&price::Vecs>,
|
||||
starting_indexes: &ComputeIndexes,
|
||||
height_to_supply: &impl IterableVec<Height, Bitcoin>,
|
||||
height_to_market_cap: Option<&impl IterableVec<Height, Dollars>>,
|
||||
dateindex_to_market_cap: Option<&impl IterableVec<DateIndex, Dollars>>,
|
||||
exit: &Exit,
|
||||
@@ -251,7 +250,6 @@ impl CohortVecs for UTXOCohortVecs {
|
||||
indexes,
|
||||
price,
|
||||
starting_indexes,
|
||||
height_to_supply,
|
||||
height_to_market_cap,
|
||||
dateindex_to_market_cap,
|
||||
exit,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use brk_error::Result;
|
||||
use brk_types::{Bitcoin, DateIndex, Dollars, Height};
|
||||
use brk_types::{DateIndex, Dollars, Height};
|
||||
use log::info;
|
||||
use vecdb::{Exit, IterableVec};
|
||||
|
||||
@@ -49,19 +49,17 @@ pub fn compute_rest_part1(
|
||||
///
|
||||
/// Computes supply ratios, market cap ratios, etc. using total references.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn compute_rest_part2<S, HM, DM>(
|
||||
pub fn compute_rest_part2<HM, DM>(
|
||||
utxo_cohorts: &mut UTXOCohorts,
|
||||
address_cohorts: &mut AddressCohorts,
|
||||
indexes: &indexes::Vecs,
|
||||
price: Option<&price::Vecs>,
|
||||
starting_indexes: &ComputeIndexes,
|
||||
height_to_supply: &S,
|
||||
height_to_market_cap: Option<&HM>,
|
||||
dateindex_to_market_cap: Option<&DM>,
|
||||
exit: &Exit,
|
||||
) -> Result<()>
|
||||
where
|
||||
S: IterableVec<Height, Bitcoin> + Sync,
|
||||
HM: IterableVec<Height, Dollars> + Sync,
|
||||
DM: IterableVec<DateIndex, Dollars> + Sync,
|
||||
{
|
||||
@@ -71,7 +69,6 @@ where
|
||||
indexes,
|
||||
price,
|
||||
starting_indexes,
|
||||
height_to_supply,
|
||||
height_to_market_cap,
|
||||
dateindex_to_market_cap,
|
||||
exit,
|
||||
@@ -81,7 +78,6 @@ where
|
||||
indexes,
|
||||
price,
|
||||
starting_indexes,
|
||||
height_to_supply,
|
||||
height_to_market_cap,
|
||||
dateindex_to_market_cap,
|
||||
exit,
|
||||
|
||||
@@ -8,9 +8,9 @@ use vecdb::{
|
||||
};
|
||||
|
||||
use crate::{
|
||||
ComputeIndexes,
|
||||
ComputeIndexes, indexes,
|
||||
internal::{ComputedValueVecsFromHeight, ComputedVecsFromHeight, Source, VecBuilderOptions},
|
||||
indexes, price,
|
||||
price,
|
||||
};
|
||||
|
||||
use super::ImportConfig;
|
||||
@@ -40,17 +40,16 @@ pub struct ActivityMetrics {
|
||||
impl ActivityMetrics {
|
||||
/// Import activity metrics from database.
|
||||
pub fn forced_import(cfg: &ImportConfig) -> Result<Self> {
|
||||
let v0 = Version::ZERO;
|
||||
let compute_dollars = cfg.compute_dollars();
|
||||
let sum_cum = VecBuilderOptions::default().add_sum().add_cumulative();
|
||||
|
||||
let height_to_sent: EagerVec<PcoVec<Height, Sats>> =
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("sent"), cfg.version + v0)?;
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("sent"), cfg.version)?;
|
||||
let indexes_to_sent = ComputedValueVecsFromHeight::forced_import(
|
||||
cfg.db,
|
||||
&cfg.name("sent"),
|
||||
Source::Vec(height_to_sent.boxed_clone()),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
sum_cum,
|
||||
compute_dollars,
|
||||
cfg.indexes,
|
||||
@@ -63,20 +62,20 @@ impl ActivityMetrics {
|
||||
height_to_satblocks_destroyed: EagerVec::forced_import(
|
||||
cfg.db,
|
||||
&cfg.name("satblocks_destroyed"),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
)?,
|
||||
|
||||
height_to_satdays_destroyed: EagerVec::forced_import(
|
||||
cfg.db,
|
||||
&cfg.name("satdays_destroyed"),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
)?,
|
||||
|
||||
indexes_to_coinblocks_destroyed: ComputedVecsFromHeight::forced_import(
|
||||
cfg.db,
|
||||
&cfg.name("coinblocks_destroyed"),
|
||||
Source::Compute,
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
cfg.indexes,
|
||||
sum_cum,
|
||||
)?,
|
||||
@@ -85,7 +84,7 @@ impl ActivityMetrics {
|
||||
cfg.db,
|
||||
&cfg.name("coindays_destroyed"),
|
||||
Source::Compute,
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
cfg.indexes,
|
||||
sum_cum,
|
||||
)?,
|
||||
|
||||
@@ -33,22 +33,21 @@ pub struct CostBasisMetrics {
|
||||
impl CostBasisMetrics {
|
||||
/// Import cost basis metrics from database.
|
||||
pub fn forced_import(cfg: &ImportConfig) -> Result<Self> {
|
||||
let v0 = Version::ZERO;
|
||||
let extended = cfg.extended();
|
||||
let last = VecBuilderOptions::default().add_last();
|
||||
|
||||
let height_to_min_cost_basis =
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("min_cost_basis"), cfg.version + v0)?;
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("min_cost_basis"), cfg.version)?;
|
||||
|
||||
let height_to_max_cost_basis =
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("max_cost_basis"), cfg.version + v0)?;
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("max_cost_basis"), cfg.version)?;
|
||||
|
||||
Ok(Self {
|
||||
indexes_to_min_cost_basis: ComputedVecsFromHeight::forced_import(
|
||||
cfg.db,
|
||||
&cfg.name("min_cost_basis"),
|
||||
Source::Vec(height_to_min_cost_basis.boxed_clone()),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
cfg.indexes,
|
||||
last,
|
||||
)?,
|
||||
@@ -56,7 +55,7 @@ impl CostBasisMetrics {
|
||||
cfg.db,
|
||||
&cfg.name("max_cost_basis"),
|
||||
Source::Vec(height_to_max_cost_basis.boxed_clone()),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
cfg.indexes,
|
||||
last,
|
||||
)?,
|
||||
@@ -67,7 +66,7 @@ impl CostBasisMetrics {
|
||||
CostBasisPercentiles::forced_import(
|
||||
cfg.db,
|
||||
&cfg.name(""),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
cfg.indexes,
|
||||
true,
|
||||
)
|
||||
|
||||
@@ -17,7 +17,7 @@ pub use unrealized::*;
|
||||
use brk_cohort::Filter;
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Bitcoin, DateIndex, Dollars, Height, Version};
|
||||
use brk_types::{DateIndex, Dollars, Height, Version};
|
||||
use rayon::prelude::*;
|
||||
use vecdb::{AnyStoredVec, Exit, IterableVec};
|
||||
|
||||
@@ -319,7 +319,6 @@ impl CohortMetrics {
|
||||
indexes: &indexes::Vecs,
|
||||
price: Option<&price_vecs::Vecs>,
|
||||
starting_indexes: &ComputeIndexes,
|
||||
height_to_supply: &impl IterableVec<Height, Bitcoin>,
|
||||
height_to_market_cap: Option<&impl IterableVec<Height, Dollars>>,
|
||||
dateindex_to_market_cap: Option<&impl IterableVec<DateIndex, Dollars>>,
|
||||
exit: &Exit,
|
||||
@@ -329,7 +328,7 @@ impl CohortMetrics {
|
||||
indexes,
|
||||
price,
|
||||
starting_indexes,
|
||||
height_to_supply,
|
||||
&self.supply.height_to_supply_value.bitcoin,
|
||||
height_to_market_cap,
|
||||
dateindex_to_market_cap,
|
||||
exit,
|
||||
|
||||
@@ -9,13 +9,14 @@ use vecdb::{
|
||||
|
||||
use crate::{
|
||||
ComputeIndexes,
|
||||
distribution::state::RealizedState,
|
||||
indexes,
|
||||
internal::{
|
||||
ComputedRatioVecsFromDateIndex, ComputedVecsFromDateIndex, ComputedVecsFromHeight,
|
||||
LazyVecsFrom2FromHeight, LazyVecsFromDateIndex, LazyVecsFromHeight, PercentageDollarsF32,
|
||||
Source, StoredF32Identity, VecBuilderOptions,
|
||||
},
|
||||
indexes, price,
|
||||
distribution::state::RealizedState,
|
||||
price,
|
||||
utils::OptionExt,
|
||||
};
|
||||
|
||||
@@ -93,7 +94,6 @@ pub struct RealizedMetrics {
|
||||
impl RealizedMetrics {
|
||||
/// Import realized metrics from database.
|
||||
pub fn forced_import(cfg: &ImportConfig) -> Result<Self> {
|
||||
let v0 = Version::ZERO;
|
||||
let v1 = Version::ONE;
|
||||
let v3 = Version::new(3);
|
||||
let extended = cfg.extended();
|
||||
@@ -103,13 +103,13 @@ impl RealizedMetrics {
|
||||
let sum_cum = VecBuilderOptions::default().add_sum().add_cumulative();
|
||||
|
||||
let height_to_realized_loss: EagerVec<PcoVec<Height, Dollars>> =
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("realized_loss"), cfg.version + v0)?;
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("realized_loss"), cfg.version)?;
|
||||
|
||||
let indexes_to_realized_loss = ComputedVecsFromHeight::forced_import(
|
||||
cfg.db,
|
||||
&cfg.name("realized_loss"),
|
||||
Source::Vec(height_to_realized_loss.boxed_clone()),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
cfg.indexes,
|
||||
sum_cum,
|
||||
)?;
|
||||
@@ -126,7 +126,7 @@ impl RealizedMetrics {
|
||||
cfg.db,
|
||||
&cfg.name("realized_value"),
|
||||
Source::Compute,
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
cfg.indexes,
|
||||
sum,
|
||||
)?;
|
||||
@@ -145,25 +145,25 @@ impl RealizedMetrics {
|
||||
|
||||
// Extract vecs needed for lazy ratio construction
|
||||
let height_to_realized_cap: EagerVec<PcoVec<Height, Dollars>> =
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("realized_cap"), cfg.version + v0)?;
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("realized_cap"), cfg.version)?;
|
||||
|
||||
let indexes_to_realized_cap = ComputedVecsFromHeight::forced_import(
|
||||
cfg.db,
|
||||
&cfg.name("realized_cap"),
|
||||
Source::Vec(height_to_realized_cap.boxed_clone()),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
cfg.indexes,
|
||||
last,
|
||||
)?;
|
||||
|
||||
let height_to_realized_profit: EagerVec<PcoVec<Height, Dollars>> =
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("realized_profit"), cfg.version + v0)?;
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("realized_profit"), cfg.version)?;
|
||||
|
||||
let indexes_to_realized_profit = ComputedVecsFromHeight::forced_import(
|
||||
cfg.db,
|
||||
&cfg.name("realized_profit"),
|
||||
Source::Vec(height_to_realized_profit.boxed_clone()),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
cfg.indexes,
|
||||
sum_cum,
|
||||
)?;
|
||||
@@ -172,7 +172,7 @@ impl RealizedMetrics {
|
||||
cfg.db,
|
||||
&cfg.name("net_realized_pnl"),
|
||||
Source::Compute,
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
cfg.indexes,
|
||||
sum_cum,
|
||||
)?;
|
||||
@@ -216,32 +216,24 @@ impl RealizedMetrics {
|
||||
cfg.db,
|
||||
&cfg.name("realized_price"),
|
||||
Source::Compute,
|
||||
cfg.version + v0,
|
||||
cfg.version + v1,
|
||||
cfg.indexes,
|
||||
last,
|
||||
)?;
|
||||
|
||||
let height_to_value_created =
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("value_created"), cfg.version + v0)?;
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("value_created"), cfg.version)?;
|
||||
let height_to_value_destroyed =
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("value_destroyed"), cfg.version + v0)?;
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("value_destroyed"), cfg.version)?;
|
||||
|
||||
let height_to_adjusted_value_created = compute_adjusted
|
||||
.then(|| {
|
||||
EagerVec::forced_import(
|
||||
cfg.db,
|
||||
&cfg.name("adjusted_value_created"),
|
||||
cfg.version + v0,
|
||||
)
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("adjusted_value_created"), cfg.version)
|
||||
})
|
||||
.transpose()?;
|
||||
let height_to_adjusted_value_destroyed = compute_adjusted
|
||||
.then(|| {
|
||||
EagerVec::forced_import(
|
||||
cfg.db,
|
||||
&cfg.name("adjusted_value_destroyed"),
|
||||
cfg.version + v0,
|
||||
)
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("adjusted_value_destroyed"), cfg.version)
|
||||
})
|
||||
.transpose()?;
|
||||
|
||||
@@ -250,7 +242,7 @@ impl RealizedMetrics {
|
||||
cfg.db,
|
||||
&cfg.name("realized_price"),
|
||||
Some(&indexes_to_realized_price),
|
||||
cfg.version + v0,
|
||||
cfg.version + v1,
|
||||
cfg.indexes,
|
||||
extended,
|
||||
cfg.price,
|
||||
@@ -260,7 +252,7 @@ impl RealizedMetrics {
|
||||
// ratio = close / realized_price = market_cap / realized_cap = MVRV
|
||||
let indexes_to_mvrv = LazyVecsFromDateIndex::from_computed::<StoredF32Identity>(
|
||||
&cfg.name("mvrv"),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
indexes_to_realized_price_extra
|
||||
.ratio
|
||||
.dateindex
|
||||
@@ -283,7 +275,7 @@ impl RealizedMetrics {
|
||||
cfg.db,
|
||||
&cfg.name("realized_cap_rel_to_own_market_cap"),
|
||||
Source::Compute,
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
cfg.indexes,
|
||||
last,
|
||||
)
|
||||
@@ -293,7 +285,7 @@ impl RealizedMetrics {
|
||||
cfg.db,
|
||||
&cfg.name("realized_cap_30d_delta"),
|
||||
Source::Compute,
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
cfg.indexes,
|
||||
last,
|
||||
)?,
|
||||
@@ -329,7 +321,7 @@ impl RealizedMetrics {
|
||||
cfg.db,
|
||||
&cfg.name("value_created"),
|
||||
Source::Vec(height_to_value_created.boxed_clone()),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
cfg.indexes,
|
||||
sum,
|
||||
)?,
|
||||
@@ -337,7 +329,7 @@ impl RealizedMetrics {
|
||||
cfg.db,
|
||||
&cfg.name("value_destroyed"),
|
||||
Source::Vec(height_to_value_destroyed.boxed_clone()),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
cfg.indexes,
|
||||
sum,
|
||||
)?,
|
||||
@@ -356,7 +348,7 @@ impl RealizedMetrics {
|
||||
.unwrap()
|
||||
.boxed_clone(),
|
||||
),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
cfg.indexes,
|
||||
sum,
|
||||
)
|
||||
@@ -373,7 +365,7 @@ impl RealizedMetrics {
|
||||
.unwrap()
|
||||
.boxed_clone(),
|
||||
),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
cfg.indexes,
|
||||
sum,
|
||||
)
|
||||
|
||||
@@ -108,7 +108,6 @@ impl RelativeMetrics {
|
||||
supply: &SupplyMetrics,
|
||||
all_supply: Option<&SupplyMetrics>,
|
||||
) -> Result<Self> {
|
||||
let v0 = Version::ZERO;
|
||||
let v1 = Version::ONE;
|
||||
let v2 = Version::new(2);
|
||||
let extended = cfg.extended();
|
||||
@@ -227,7 +226,7 @@ impl RelativeMetrics {
|
||||
height_to_unrealized_profit_rel_to_market_cap: global_market_cap_height.map(|mc| {
|
||||
LazyVecFrom2::transformed::<PercentageDollarsF32>(
|
||||
&cfg.name("unrealized_profit_rel_to_market_cap"),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
unrealized.height_to_unrealized_profit.boxed_clone(),
|
||||
mc.boxed_clone(),
|
||||
)
|
||||
@@ -235,7 +234,7 @@ impl RelativeMetrics {
|
||||
height_to_unrealized_loss_rel_to_market_cap: global_market_cap_height.map(|mc| {
|
||||
LazyVecFrom2::transformed::<PercentageDollarsF32>(
|
||||
&cfg.name("unrealized_loss_rel_to_market_cap"),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
unrealized.height_to_unrealized_loss.boxed_clone(),
|
||||
mc.boxed_clone(),
|
||||
)
|
||||
@@ -243,7 +242,7 @@ impl RelativeMetrics {
|
||||
height_to_neg_unrealized_loss_rel_to_market_cap: global_market_cap_height.map(|mc| {
|
||||
LazyVecFrom2::transformed::<NegPercentageDollarsF32>(
|
||||
&cfg.name("neg_unrealized_loss_rel_to_market_cap"),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
unrealized.height_to_unrealized_loss.boxed_clone(),
|
||||
mc.boxed_clone(),
|
||||
)
|
||||
@@ -401,7 +400,7 @@ impl RelativeMetrics {
|
||||
height_to_unrealized_profit_rel_to_own_total_unrealized_pnl: extended.then(|| {
|
||||
LazyVecFrom2::transformed::<Ratio32>(
|
||||
&cfg.name("unrealized_profit_rel_to_own_total_unrealized_pnl"),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
unrealized.height_to_unrealized_profit.boxed_clone(),
|
||||
unrealized.height_to_total_unrealized_pnl.boxed_clone(),
|
||||
)
|
||||
@@ -409,7 +408,7 @@ impl RelativeMetrics {
|
||||
height_to_unrealized_loss_rel_to_own_total_unrealized_pnl: extended.then(|| {
|
||||
LazyVecFrom2::transformed::<Ratio32>(
|
||||
&cfg.name("unrealized_loss_rel_to_own_total_unrealized_pnl"),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
unrealized.height_to_unrealized_loss.boxed_clone(),
|
||||
unrealized.height_to_total_unrealized_pnl.boxed_clone(),
|
||||
)
|
||||
@@ -417,7 +416,7 @@ impl RelativeMetrics {
|
||||
height_to_neg_unrealized_loss_rel_to_own_total_unrealized_pnl: extended.then(|| {
|
||||
LazyVecFrom2::transformed::<NegRatio32>(
|
||||
&cfg.name("neg_unrealized_loss_rel_to_own_total_unrealized_pnl"),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
unrealized.height_to_unrealized_loss.boxed_clone(),
|
||||
unrealized.height_to_total_unrealized_pnl.boxed_clone(),
|
||||
)
|
||||
|
||||
@@ -8,13 +8,13 @@ use vecdb::{
|
||||
};
|
||||
|
||||
use crate::{
|
||||
ComputeIndexes,
|
||||
ComputeIndexes, indexes,
|
||||
internal::{
|
||||
ComputedHeightValueVecs, ComputedValueVecsFromDateIndex, ComputedVecsFromHeight,
|
||||
HalfClosePriceTimesSats, HalveDollars, HalveSats, HalveSatsToBitcoin, LazyHeightValueVecs,
|
||||
LazyValueVecsFromDateIndex, Source, VecBuilderOptions,
|
||||
},
|
||||
indexes, price,
|
||||
price,
|
||||
};
|
||||
|
||||
use super::ImportConfig;
|
||||
@@ -47,13 +47,12 @@ pub struct SupplyMetrics {
|
||||
impl SupplyMetrics {
|
||||
/// Import supply metrics from database.
|
||||
pub fn forced_import(cfg: &ImportConfig) -> Result<Self> {
|
||||
let v0 = Version::ZERO;
|
||||
let v1 = Version::ONE;
|
||||
let compute_dollars = cfg.compute_dollars();
|
||||
let last = VecBuilderOptions::default().add_last();
|
||||
|
||||
let height_to_supply: EagerVec<PcoVec<Height, Sats>> =
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("supply"), cfg.version + v0)?;
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("supply"), cfg.version)?;
|
||||
|
||||
let price_source = cfg
|
||||
.price
|
||||
@@ -63,7 +62,7 @@ impl SupplyMetrics {
|
||||
cfg.db,
|
||||
&cfg.name("supply"),
|
||||
Source::Vec(height_to_supply.boxed_clone()),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
price_source.clone(),
|
||||
)?;
|
||||
|
||||
@@ -86,25 +85,25 @@ impl SupplyMetrics {
|
||||
&cfg.name("supply_half"),
|
||||
height_to_supply.boxed_clone(),
|
||||
price_source,
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
);
|
||||
|
||||
let indexes_to_supply_half =
|
||||
LazyValueVecsFromDateIndex::from_source::<HalveSats, HalveSatsToBitcoin, HalveDollars>(
|
||||
&cfg.name("supply_half"),
|
||||
&indexes_to_supply,
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
);
|
||||
|
||||
let height_to_utxo_count =
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("utxo_count"), cfg.version + v0)?;
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("utxo_count"), cfg.version)?;
|
||||
|
||||
Ok(Self {
|
||||
indexes_to_utxo_count: ComputedVecsFromHeight::forced_import(
|
||||
cfg.db,
|
||||
&cfg.name("utxo_count"),
|
||||
Source::Vec(height_to_utxo_count.boxed_clone()),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
cfg.indexes,
|
||||
last,
|
||||
)?,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{DateIndex, Dollars, Height, Sats, Version};
|
||||
use brk_types::{DateIndex, Dollars, Height, Sats};
|
||||
use rayon::prelude::*;
|
||||
use vecdb::{
|
||||
AnyStoredVec, AnyVec, EagerVec, Exit, GenericStoredVec, ImportableVec, IterableCloneableVec,
|
||||
@@ -9,11 +9,11 @@ use vecdb::{
|
||||
|
||||
use crate::{
|
||||
ComputeIndexes,
|
||||
distribution::state::UnrealizedState,
|
||||
internal::{
|
||||
ComputedHeightValueVecs, ComputedValueVecsFromDateIndex, ComputedVecsFromDateIndex,
|
||||
DollarsMinus, DollarsPlus, LazyVecsFromDateIndex, Source, VecBuilderOptions,
|
||||
},
|
||||
distribution::state::UnrealizedState,
|
||||
};
|
||||
|
||||
use super::ImportConfig;
|
||||
@@ -57,23 +57,22 @@ pub struct UnrealizedMetrics {
|
||||
impl UnrealizedMetrics {
|
||||
/// Import unrealized metrics from database.
|
||||
pub fn forced_import(cfg: &ImportConfig) -> Result<Self> {
|
||||
let v0 = Version::ZERO;
|
||||
let compute_dollars = cfg.compute_dollars();
|
||||
let last = VecBuilderOptions::default().add_last();
|
||||
|
||||
let dateindex_to_supply_in_profit =
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("supply_in_profit"), cfg.version + v0)?;
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("supply_in_profit"), cfg.version)?;
|
||||
let dateindex_to_supply_in_loss =
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("supply_in_loss"), cfg.version + v0)?;
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("supply_in_loss"), cfg.version)?;
|
||||
let dateindex_to_unrealized_profit =
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("unrealized_profit"), cfg.version + v0)?;
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("unrealized_profit"), cfg.version)?;
|
||||
let dateindex_to_unrealized_loss =
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("unrealized_loss"), cfg.version + v0)?;
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("unrealized_loss"), cfg.version)?;
|
||||
let height_to_unrealized_loss: EagerVec<PcoVec<Height, Dollars>> =
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("unrealized_loss"), cfg.version + v0)?;
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("unrealized_loss"), cfg.version)?;
|
||||
let height_to_neg_unrealized_loss = LazyVecFrom1::transformed::<Negate>(
|
||||
&cfg.name("neg_unrealized_loss"),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
height_to_unrealized_loss.boxed_clone(),
|
||||
);
|
||||
|
||||
@@ -81,26 +80,26 @@ impl UnrealizedMetrics {
|
||||
cfg.db,
|
||||
&cfg.name("unrealized_loss"),
|
||||
Source::Vec(dateindex_to_unrealized_loss.boxed_clone()),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
cfg.indexes,
|
||||
last,
|
||||
)?;
|
||||
|
||||
let indexes_to_neg_unrealized_loss = LazyVecsFromDateIndex::from_computed::<Negate>(
|
||||
&cfg.name("neg_unrealized_loss"),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
Some(dateindex_to_unrealized_loss.boxed_clone()),
|
||||
&indexes_to_unrealized_loss,
|
||||
);
|
||||
|
||||
// Extract profit sources for lazy net/total vecs
|
||||
let height_to_unrealized_profit: EagerVec<PcoVec<Height, Dollars>> =
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("unrealized_profit"), cfg.version + v0)?;
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("unrealized_profit"), cfg.version)?;
|
||||
let indexes_to_unrealized_profit = ComputedVecsFromDateIndex::forced_import(
|
||||
cfg.db,
|
||||
&cfg.name("unrealized_profit"),
|
||||
Source::Vec(dateindex_to_unrealized_profit.boxed_clone()),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
cfg.indexes,
|
||||
last,
|
||||
)?;
|
||||
@@ -108,13 +107,13 @@ impl UnrealizedMetrics {
|
||||
// Create lazy height vecs from profit/loss sources
|
||||
let height_to_net_unrealized_pnl = LazyVecFrom2::transformed::<DollarsMinus>(
|
||||
&cfg.name("net_unrealized_pnl"),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
height_to_unrealized_profit.boxed_clone(),
|
||||
height_to_unrealized_loss.boxed_clone(),
|
||||
);
|
||||
let height_to_total_unrealized_pnl = LazyVecFrom2::transformed::<DollarsPlus>(
|
||||
&cfg.name("total_unrealized_pnl"),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
height_to_unrealized_profit.boxed_clone(),
|
||||
height_to_unrealized_loss.boxed_clone(),
|
||||
);
|
||||
@@ -124,7 +123,7 @@ impl UnrealizedMetrics {
|
||||
cfg.db,
|
||||
&cfg.name("net_unrealized_pnl"),
|
||||
Source::Compute,
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
cfg.indexes,
|
||||
last,
|
||||
)?;
|
||||
@@ -132,15 +131,15 @@ impl UnrealizedMetrics {
|
||||
cfg.db,
|
||||
&cfg.name("total_unrealized_pnl"),
|
||||
Source::Compute,
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
cfg.indexes,
|
||||
last,
|
||||
)?;
|
||||
|
||||
let height_to_supply_in_profit: EagerVec<PcoVec<Height, Sats>> =
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("supply_in_profit"), cfg.version + v0)?;
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("supply_in_profit"), cfg.version)?;
|
||||
let height_to_supply_in_loss: EagerVec<PcoVec<Height, Sats>> =
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("supply_in_loss"), cfg.version + v0)?;
|
||||
EagerVec::forced_import(cfg.db, &cfg.name("supply_in_loss"), cfg.version)?;
|
||||
|
||||
let price_source = cfg
|
||||
.price
|
||||
@@ -150,14 +149,14 @@ impl UnrealizedMetrics {
|
||||
cfg.db,
|
||||
&cfg.name("supply_in_profit"),
|
||||
Source::Vec(height_to_supply_in_profit.boxed_clone()),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
price_source.clone(),
|
||||
)?;
|
||||
let height_to_supply_in_loss_value = ComputedHeightValueVecs::forced_import(
|
||||
cfg.db,
|
||||
&cfg.name("supply_in_loss"),
|
||||
Source::Vec(height_to_supply_in_loss.boxed_clone()),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
price_source,
|
||||
)?;
|
||||
|
||||
@@ -168,7 +167,7 @@ impl UnrealizedMetrics {
|
||||
cfg.db,
|
||||
&cfg.name("supply_in_profit"),
|
||||
Source::Vec(dateindex_to_supply_in_profit.boxed_clone()),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
last,
|
||||
compute_dollars,
|
||||
cfg.indexes,
|
||||
@@ -178,7 +177,7 @@ impl UnrealizedMetrics {
|
||||
cfg.db,
|
||||
&cfg.name("supply_in_loss"),
|
||||
Source::Vec(dateindex_to_supply_in_loss.boxed_clone()),
|
||||
cfg.version + v0,
|
||||
cfg.version,
|
||||
last,
|
||||
compute_dollars,
|
||||
cfg.indexes,
|
||||
|
||||
@@ -19,8 +19,7 @@ use crate::{
|
||||
compute::{StartMode, determine_start_mode, process_blocks, recover_state, reset_state},
|
||||
state::BlockState,
|
||||
},
|
||||
indexes,
|
||||
inputs,
|
||||
indexes, inputs,
|
||||
internal::{ComputedVecsFromHeight, Source, VecBuilderOptions},
|
||||
outputs, price, transactions,
|
||||
};
|
||||
@@ -63,7 +62,7 @@ const SAVED_STAMPED_CHANGES: u16 = 10;
|
||||
impl Vecs {
|
||||
pub fn forced_import(
|
||||
parent: &Path,
|
||||
version: Version,
|
||||
parent_version: Version,
|
||||
indexes: &indexes::Vecs,
|
||||
price: Option<&price::Vecs>,
|
||||
) -> Result<Self> {
|
||||
@@ -74,7 +73,7 @@ impl Vecs {
|
||||
db.set_min_len(PAGE_SIZE * 20_000_000)?;
|
||||
db.set_min_regions(50_000)?;
|
||||
|
||||
let v0 = version + VERSION + Version::ZERO;
|
||||
let version = parent_version + VERSION;
|
||||
|
||||
let utxo_cohorts = UTXOCohorts::forced_import(&db, version, indexes, price, &states_path)?;
|
||||
|
||||
@@ -90,37 +89,37 @@ impl Vecs {
|
||||
|
||||
// Create address data BytesVecs first so we can also use them for identity mappings
|
||||
let loadedaddressindex_to_loadedaddressdata = BytesVec::forced_import_with(
|
||||
vecdb::ImportOptions::new(&db, "loadedaddressdata", v0)
|
||||
vecdb::ImportOptions::new(&db, "loadedaddressdata", version)
|
||||
.with_saved_stamped_changes(SAVED_STAMPED_CHANGES),
|
||||
)?;
|
||||
let emptyaddressindex_to_emptyaddressdata = BytesVec::forced_import_with(
|
||||
vecdb::ImportOptions::new(&db, "emptyaddressdata", v0)
|
||||
vecdb::ImportOptions::new(&db, "emptyaddressdata", version)
|
||||
.with_saved_stamped_changes(SAVED_STAMPED_CHANGES),
|
||||
)?;
|
||||
|
||||
// Identity mappings for traversable
|
||||
let loadedaddressindex_to_loadedaddressindex = LazyVecFrom1::init(
|
||||
"loadedaddressindex",
|
||||
v0,
|
||||
version,
|
||||
loadedaddressindex_to_loadedaddressdata.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
);
|
||||
let emptyaddressindex_to_emptyaddressindex = LazyVecFrom1::init(
|
||||
"emptyaddressindex",
|
||||
v0,
|
||||
version,
|
||||
emptyaddressindex_to_emptyaddressdata.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
);
|
||||
|
||||
// Extract address type height vecs before struct literal to use as sources
|
||||
let addresstype_to_height_to_addr_count =
|
||||
AddressTypeToHeightToAddressCount::forced_import(&db, "addr_count", v0)?;
|
||||
AddressTypeToHeightToAddressCount::forced_import(&db, "addr_count", version)?;
|
||||
let addresstype_to_height_to_empty_addr_count =
|
||||
AddressTypeToHeightToAddressCount::forced_import(&db, "empty_addr_count", v0)?;
|
||||
AddressTypeToHeightToAddressCount::forced_import(&db, "empty_addr_count", version)?;
|
||||
|
||||
let this = Self {
|
||||
chain_state: BytesVec::forced_import_with(
|
||||
vecdb::ImportOptions::new(&db, "chain", v0)
|
||||
vecdb::ImportOptions::new(&db, "chain", version)
|
||||
.with_saved_stamped_changes(SAVED_STAMPED_CHANGES),
|
||||
)?,
|
||||
|
||||
@@ -128,7 +127,7 @@ impl Vecs {
|
||||
&db,
|
||||
"addr_count",
|
||||
Source::Compute,
|
||||
v0,
|
||||
version,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
@@ -136,23 +135,24 @@ impl Vecs {
|
||||
&db,
|
||||
"empty_addr_count",
|
||||
Source::Compute,
|
||||
v0,
|
||||
version,
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
|
||||
addresstype_to_indexes_to_addr_count: AddressTypeToIndexesToAddressCount::forced_import(
|
||||
&db,
|
||||
"addr_count",
|
||||
v0,
|
||||
indexes,
|
||||
&addresstype_to_height_to_addr_count,
|
||||
)?,
|
||||
addresstype_to_indexes_to_addr_count:
|
||||
AddressTypeToIndexesToAddressCount::forced_import(
|
||||
&db,
|
||||
"addr_count",
|
||||
version,
|
||||
indexes,
|
||||
&addresstype_to_height_to_addr_count,
|
||||
)?,
|
||||
addresstype_to_indexes_to_empty_addr_count:
|
||||
AddressTypeToIndexesToAddressCount::forced_import(
|
||||
&db,
|
||||
"empty_addr_count",
|
||||
v0,
|
||||
version,
|
||||
indexes,
|
||||
&addresstype_to_height_to_empty_addr_count,
|
||||
)?,
|
||||
@@ -162,7 +162,7 @@ impl Vecs {
|
||||
utxo_cohorts,
|
||||
address_cohorts,
|
||||
|
||||
any_address_indexes: AnyAddressIndexesVecs::forced_import(&db, v0)?,
|
||||
any_address_indexes: AnyAddressIndexesVecs::forced_import(&db, version)?,
|
||||
addresses_data: AddressesDataVecs {
|
||||
loaded: loadedaddressindex_to_loadedaddressdata,
|
||||
empty: emptyaddressindex_to_emptyaddressdata,
|
||||
@@ -328,11 +328,52 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
// 6b. Compute address count dateindex vecs (per-addresstype)
|
||||
self.addresstype_to_indexes_to_addr_count.compute(
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
&self.addresstype_to_height_to_addr_count,
|
||||
)?;
|
||||
self.addresstype_to_indexes_to_empty_addr_count.compute(
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
&self.addresstype_to_height_to_empty_addr_count,
|
||||
)?;
|
||||
|
||||
// 6c. Compute global address count dateindex vecs (sum of all address types)
|
||||
let addr_count_sources: Vec<_> =
|
||||
self.addresstype_to_height_to_addr_count.values().collect();
|
||||
self.indexes_to_addr_count
|
||||
.compute_all(indexes, starting_indexes, exit, |height_vec| {
|
||||
Ok(height_vec.compute_sum_of_others(
|
||||
starting_indexes.height,
|
||||
&addr_count_sources,
|
||||
exit,
|
||||
)?)
|
||||
})?;
|
||||
|
||||
let empty_addr_count_sources: Vec<_> = self
|
||||
.addresstype_to_height_to_empty_addr_count
|
||||
.values()
|
||||
.collect();
|
||||
self.indexes_to_empty_addr_count.compute_all(
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|height_vec| {
|
||||
Ok(height_vec.compute_sum_of_others(
|
||||
starting_indexes.height,
|
||||
&empty_addr_count_sources,
|
||||
exit,
|
||||
)?)
|
||||
},
|
||||
)?;
|
||||
|
||||
// 7. Compute rest part2 (relative metrics)
|
||||
let supply_metrics = &self.utxo_cohorts.all.metrics.supply;
|
||||
|
||||
let height_to_supply = &supply_metrics.height_to_supply_value.bitcoin.clone();
|
||||
|
||||
let height_to_market_cap = supply_metrics
|
||||
.height_to_supply_value
|
||||
.dollars
|
||||
@@ -354,7 +395,6 @@ impl Vecs {
|
||||
indexes,
|
||||
price,
|
||||
starting_indexes,
|
||||
height_to_supply,
|
||||
height_to_market_cap_ref,
|
||||
dateindex_to_market_cap_ref,
|
||||
exit,
|
||||
|
||||
Reference in New Issue
Block a user