global: works but data is wrong

This commit is contained in:
nym21
2025-06-04 17:01:16 +02:00
parent 20d5c7e8d5
commit d568469e8b
14 changed files with 2559 additions and 119 deletions

View File

@@ -5,8 +5,10 @@ mod from_height_strict;
mod from_txindex;
mod ratio_from_dateindex;
mod r#type;
mod value_from_dateindex;
mod value_from_height;
mod value_from_txindex;
mod value_height;
pub use builder::*;
pub use from_dateindex::*;
@@ -15,5 +17,7 @@ pub use from_height_strict::*;
pub use from_txindex::*;
pub use ratio_from_dateindex::*;
use r#type::*;
pub use value_from_dateindex::*;
pub use value_from_height::*;
pub use value_from_txindex::*;
pub use value_height::*;

View File

@@ -0,0 +1,176 @@
use std::path::Path;
use brk_core::{Bitcoin, DateIndex, Dollars, Sats, Version};
use brk_exit::Exit;
use brk_indexer::Indexer;
use brk_vec::{AnyCollectableVec, CollectableVec, Format, StoredVec};
use crate::vecs::{Indexes, fetched, grouped::ComputedVecsFromDateIndex, indexes};
use super::StorableVecGeneatorOptions;
#[derive(Clone)]
pub struct ComputedValueVecsFromDateIndex {
pub sats: ComputedVecsFromDateIndex<Sats>,
pub bitcoin: ComputedVecsFromDateIndex<Bitcoin>,
pub dollars: Option<ComputedVecsFromDateIndex<Dollars>>,
}
const VERSION: Version = Version::ZERO;
impl ComputedValueVecsFromDateIndex {
pub fn forced_import(
path: &Path,
name: &str,
compute_source: bool,
version: Version,
format: Format,
options: StorableVecGeneatorOptions,
compute_dollars: bool,
) -> color_eyre::Result<Self> {
Ok(Self {
sats: ComputedVecsFromDateIndex::forced_import(
path,
name,
compute_source,
version + VERSION,
format,
options,
)?,
bitcoin: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_in_btc"),
true,
version + VERSION,
format,
options,
)?,
dollars: compute_dollars.then(|| {
ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_in_usd"),
true,
version + VERSION,
format,
options,
)
.unwrap()
}),
})
}
// pub fn compute_all<F>(
// &mut self,
// indexer: &Indexer,
// indexes: &indexes::Vecs,
// fetched: Option<&fetched::Vecs>,
// starting_indexes: &Indexes,
// exit: &Exit,
// mut compute: F,
// ) -> color_eyre::Result<()>
// where
// F: FnMut(
// &mut EagerVec<DateIndex, Sats>,
// &Indexer,
// &indexes::Vecs,
// &Indexes,
// &Exit,
// ) -> Result<()>,
// {
// compute(
// self.sats.dateindex.as_mut().unwrap(),
// indexer,
// indexes,
// starting_indexes,
// exit,
// )?;
// let dateindex: Option<&StoredVec<DateIndex, Sats>> = None;
// self.compute_rest(indexer, indexes, fetched, starting_indexes, exit, dateindex)?;
// Ok(())
// }
pub fn compute_rest(
&mut self,
indexer: &Indexer,
indexes: &indexes::Vecs,
fetched: Option<&fetched::Vecs>,
starting_indexes: &Indexes,
exit: &Exit,
dateindex: Option<&impl CollectableVec<DateIndex, Sats>>,
) -> color_eyre::Result<()> {
if let Some(dateindex) = dateindex {
self.sats
.compute_rest(indexes, starting_indexes, exit, Some(dateindex))?;
self.bitcoin.compute_all(
indexer,
indexes,
starting_indexes,
exit,
|v, _, _, starting_indexes, exit| {
v.compute_from_sats(starting_indexes.dateindex, dateindex, exit)
},
)?;
} else {
let dateindex: Option<&StoredVec<DateIndex, Sats>> = None;
self.sats
.compute_rest(indexes, starting_indexes, exit, dateindex)?;
self.bitcoin.compute_all(
indexer,
indexes,
starting_indexes,
exit,
|v, _, _, starting_indexes, exit| {
v.compute_from_sats(
starting_indexes.dateindex,
self.sats.dateindex.as_ref().unwrap(),
exit,
)
},
)?;
}
let dateindex_to_bitcoin = self.bitcoin.dateindex.as_ref().unwrap();
let dateindex_to_close = fetched
.as_ref()
.unwrap()
.timeindexes_to_close
.dateindex
.as_ref()
.unwrap();
if let Some(dollars) = self.dollars.as_mut() {
dollars.compute_all(
indexer,
indexes,
starting_indexes,
exit,
|v, _, _, starting_indexes, exit| {
v.compute_from_bitcoin(
starting_indexes.dateindex,
dateindex_to_bitcoin,
dateindex_to_close,
exit,
)
},
)?;
}
Ok(())
}
pub fn vecs(&self) -> Vec<&dyn AnyCollectableVec> {
[
self.sats.vecs(),
self.bitcoin.vecs(),
self.dollars.as_ref().map_or(vec![], |v| v.vecs()),
]
.into_iter()
.flatten()
.collect::<Vec<_>>()
}
}

View File

@@ -0,0 +1,125 @@
use std::path::Path;
use brk_core::{Bitcoin, Dollars, Height, Sats, Version};
use brk_exit::Exit;
use brk_vec::{AnyCollectableVec, CollectableVec, EagerVec, Format};
use crate::vecs::{Indexes, fetched};
#[derive(Clone)]
pub struct ComputedHeightValueVecs {
pub sats: Option<EagerVec<Height, Sats>>,
pub bitcoin: EagerVec<Height, Bitcoin>,
pub dollars: Option<EagerVec<Height, Dollars>>,
}
const VERSION: Version = Version::ZERO;
impl ComputedHeightValueVecs {
pub fn forced_import(
path: &Path,
name: &str,
compute_source: bool,
version: Version,
format: Format,
compute_dollars: bool,
) -> color_eyre::Result<Self> {
Ok(Self {
sats: compute_source.then(|| {
EagerVec::forced_import(path, name, version + VERSION + Version::ZERO, format)
.unwrap()
}),
bitcoin: EagerVec::forced_import(
path,
&format!("{name}_in_btc"),
version + VERSION + Version::ZERO,
format,
)?,
dollars: compute_dollars.then(|| {
EagerVec::forced_import(
path,
&format!("{name}_in_usd"),
version + VERSION + Version::ZERO,
format,
)
.unwrap()
}),
})
}
// pub fn compute_all<F>(
// &mut self,
// indexer: &Indexer,
// indexes: &indexes::Vecs,
// fetched: Option<&fetched::Vecs>,
// starting_indexes: &Indexes,
// exit: &Exit,
// mut compute: F,
// ) -> color_eyre::Result<()>
// where
// F: FnMut(
// &mut EagerVec<Height, Sats>,
// &Indexer,
// &indexes::Vecs,
// &Indexes,
// &Exit,
// ) -> Result<()>,
// {
// compute(
// self.sats.as_mut().unwrap(),
// indexer,
// indexes,
// starting_indexes,
// exit,
// )?;
// let height: Option<&StoredVec<Height, Sats>> = None;
// self.compute_rest(fetched, starting_indexes, exit, height)?;
// Ok(())
// }
pub fn compute_rest(
&mut self,
fetched: Option<&fetched::Vecs>,
starting_indexes: &Indexes,
exit: &Exit,
height: Option<&impl CollectableVec<Height, Sats>>,
) -> color_eyre::Result<()> {
if let Some(height) = height {
self.bitcoin
.compute_from_sats(starting_indexes.height, height, exit)?;
} else {
self.bitcoin.compute_from_sats(
starting_indexes.height,
self.sats.as_ref().unwrap(),
exit,
)?;
}
let height_to_bitcoin = &self.bitcoin;
let height_to_close = &fetched.as_ref().unwrap().chainindexes_to_close.height;
if let Some(dollars) = self.dollars.as_mut() {
dollars.compute_from_bitcoin(
starting_indexes.height,
height_to_bitcoin,
height_to_close,
exit,
)?;
}
Ok(())
}
pub fn vecs(&self) -> Vec<&dyn AnyCollectableVec> {
[
vec![&self.bitcoin as &dyn AnyCollectableVec],
self.sats.as_ref().map_or(vec![], |v| vec![v]),
self.dollars.as_ref().map_or(vec![], |v| vec![v]),
]
.into_iter()
.flatten()
.collect::<Vec<_>>()
}
}

View File

@@ -1,17 +1,23 @@
use std::{fs, path::Path};
use brk_core::{DateIndex, Dollars, Height, Result, Sats, StoredF32, StoredUsize, Version};
use brk_core::{
DateIndex, Dollars, Height, Result, Sats, StoredF32, StoredF64, StoredUsize, Version,
};
use brk_exit::Exit;
use brk_indexer::Indexer;
use brk_state::CohortState;
use brk_vec::{AnyCollectableVec, AnyVec, Computation, EagerVec, Format, StoredIndex, VecIterator};
use brk_vec::{
AnyCollectableVec, AnyIterableVec, AnyVec, Computation, EagerVec, Format, StoredIndex,
VecIterator,
};
use fjall::TransactionalKeyspace;
use crate::vecs::{
Indexes, fetched,
grouped::{
ComputedRatioVecsFromDateIndex, ComputedValueVecsFromHeight, ComputedVecsFromDateIndex,
ComputedVecsFromHeight, StorableVecGeneatorOptions,
ComputedHeightValueVecs, ComputedRatioVecsFromDateIndex, ComputedValueVecsFromDateIndex,
ComputedValueVecsFromHeight, ComputedVecsFromDateIndex, ComputedVecsFromHeight,
StorableVecGeneatorOptions,
},
indexes, market,
};
@@ -65,9 +71,6 @@ pub struct Vecs {
pub indexes_to_utxo_count: ComputedVecsFromHeight<StoredUsize>,
pub indexes_to_value_created: Option<ComputedVecsFromHeight<Dollars>>,
pub indexes_to_value_destroyed: Option<ComputedVecsFromHeight<Dollars>>,
pub indexes_to_supply_in_profit: Option<ComputedVecsFromDateIndex<Sats>>,
pub indexes_to_supply_in_loss: Option<ComputedVecsFromDateIndex<Sats>>,
pub indexes_to_supply_even: Option<ComputedVecsFromDateIndex<Sats>>,
pub indexes_to_unrealized_profit: Option<ComputedVecsFromDateIndex<Dollars>>,
pub indexes_to_unrealized_loss: Option<ComputedVecsFromDateIndex<Dollars>>,
pub indexes_to_min_price_paid: Option<ComputedVecsFromHeight<Dollars>>,
@@ -78,11 +81,37 @@ pub struct Vecs {
pub height_to_net_unrealized_profit_and_loss: Option<EagerVec<Height, Dollars>>,
pub indexes_to_net_unrealized_profit_and_loss: Option<ComputedVecsFromDateIndex<Dollars>>,
pub height_to_net_unrealized_profit_and_loss_relative_to_market_cap:
Option<EagerVec<Height, Dollars>>,
Option<EagerVec<Height, StoredF32>>,
pub indexes_to_net_unrealized_profit_and_loss_relative_to_market_cap:
Option<ComputedVecsFromDateIndex<Dollars>>,
// pub indexes_to_net_realized_profit_and_loss_relative_to_realized_cap:
// Option<ComputedVecsFromHeight<Dollars>>,
Option<ComputedVecsFromDateIndex<StoredF32>>,
pub indexes_to_net_realized_profit_and_loss_relative_to_realized_cap:
Option<ComputedVecsFromHeight<StoredF32>>,
pub height_to_supply_even_value: Option<ComputedHeightValueVecs>,
pub height_to_supply_in_loss_value: Option<ComputedHeightValueVecs>,
pub height_to_supply_in_profit_value: Option<ComputedHeightValueVecs>,
pub indexes_to_supply_even: Option<ComputedValueVecsFromDateIndex>,
pub indexes_to_supply_in_loss: Option<ComputedValueVecsFromDateIndex>,
pub indexes_to_supply_in_profit: Option<ComputedValueVecsFromDateIndex>,
pub height_to_supply_even_relative_to_own_supply: Option<EagerVec<Height, StoredF64>>,
pub height_to_supply_in_loss_relative_to_own_supply: Option<EagerVec<Height, StoredF64>>,
pub height_to_supply_in_profit_relative_to_own_supply: Option<EagerVec<Height, StoredF64>>,
pub indexes_to_supply_even_relative_to_own_supply: Option<ComputedVecsFromDateIndex<StoredF64>>,
pub indexes_to_supply_in_loss_relative_to_own_supply:
Option<ComputedVecsFromDateIndex<StoredF64>>,
pub indexes_to_supply_in_profit_relative_to_own_supply:
Option<ComputedVecsFromDateIndex<StoredF64>>,
pub indexes_to_supply_relative_to_circulating_supply: Option<ComputedVecsFromHeight<StoredF64>>,
pub height_to_supply_even_relative_to_circulating_supply: Option<EagerVec<Height, StoredF64>>,
pub height_to_supply_in_loss_relative_to_circulating_supply:
Option<EagerVec<Height, StoredF64>>,
pub height_to_supply_in_profit_relative_to_circulating_supply:
Option<EagerVec<Height, StoredF64>>,
pub indexes_to_supply_even_relative_to_circulating_supply:
Option<ComputedVecsFromDateIndex<StoredF64>>,
pub indexes_to_supply_in_loss_relative_to_circulating_supply:
Option<ComputedVecsFromDateIndex<StoredF64>>,
pub indexes_to_supply_in_profit_relative_to_circulating_supply:
Option<ComputedVecsFromDateIndex<StoredF64>>,
}
impl Vecs {
@@ -96,6 +125,7 @@ impl Vecs {
fetched: Option<&fetched::Vecs>,
keyspace: &TransactionalKeyspace,
stores_path: &Path,
compute_relative_to_all: bool,
) -> color_eyre::Result<Self> {
let compute_dollars = fetched.is_some();
@@ -136,13 +166,14 @@ impl Vecs {
.unwrap()
}),
indexes_to_supply_in_profit: compute_dollars.then(|| {
ComputedVecsFromDateIndex::forced_import(
ComputedValueVecsFromDateIndex::forced_import(
path,
&suffix("supply_in_profit"),
false,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
compute_dollars,
)
.unwrap()
}),
@@ -165,13 +196,14 @@ impl Vecs {
.unwrap()
}),
indexes_to_supply_even: compute_dollars.then(|| {
ComputedVecsFromDateIndex::forced_import(
ComputedValueVecsFromDateIndex::forced_import(
path,
&suffix("supply_even"),
false,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
compute_dollars,
)
.unwrap()
}),
@@ -194,13 +226,14 @@ impl Vecs {
.unwrap()
}),
indexes_to_supply_in_loss: compute_dollars.then(|| {
ComputedVecsFromDateIndex::forced_import(
ComputedValueVecsFromDateIndex::forced_import(
path,
&suffix("supply_in_loss"),
false,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
compute_dollars,
)
.unwrap()
}),
@@ -636,6 +669,195 @@ impl Vecs {
.unwrap()
},
),
indexes_to_net_realized_profit_and_loss_relative_to_realized_cap: compute_dollars.then(
|| {
ComputedVecsFromHeight::forced_import(
path,
&suffix("net_realized_profit_and_loss_relative_to_realized_cap"),
true,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
)
.unwrap()
},
),
height_to_supply_even_value: compute_dollars.then(|| {
ComputedHeightValueVecs::forced_import(
path,
&suffix("supply_even"),
false,
version,
format,
compute_dollars,
)
.unwrap()
}),
height_to_supply_in_loss_value: compute_dollars.then(|| {
ComputedHeightValueVecs::forced_import(
path,
&suffix("supply_in_loss"),
false,
version,
format,
compute_dollars,
)
.unwrap()
}),
height_to_supply_in_profit_value: compute_dollars.then(|| {
ComputedHeightValueVecs::forced_import(
path,
&suffix("supply_in_profit"),
false,
version,
format,
compute_dollars,
)
.unwrap()
}),
height_to_supply_even_relative_to_own_supply: compute_dollars.then(|| {
EagerVec::forced_import(
path,
&suffix("supply_even_relative_to_own_supply"),
version,
format,
)
.unwrap()
}),
height_to_supply_in_loss_relative_to_own_supply: compute_dollars.then(|| {
EagerVec::forced_import(
path,
&suffix("supply_in_loss_relative_to_own_supply"),
version,
format,
)
.unwrap()
}),
height_to_supply_in_profit_relative_to_own_supply: compute_dollars.then(|| {
EagerVec::forced_import(
path,
&suffix("supply_in_profit_relative_to_own_supply"),
version,
format,
)
.unwrap()
}),
indexes_to_supply_even_relative_to_own_supply: compute_dollars.then(|| {
ComputedVecsFromDateIndex::forced_import(
path,
&suffix("supply_even_relative_to_own_supply"),
true,
version,
format,
StorableVecGeneatorOptions::default().add_last(),
)
.unwrap()
}),
indexes_to_supply_in_loss_relative_to_own_supply: compute_dollars.then(|| {
ComputedVecsFromDateIndex::forced_import(
path,
&suffix("supply_in_loss_relative_to_own_supply"),
true,
version,
format,
StorableVecGeneatorOptions::default().add_last(),
)
.unwrap()
}),
indexes_to_supply_in_profit_relative_to_own_supply: compute_dollars.then(|| {
ComputedVecsFromDateIndex::forced_import(
path,
&suffix("supply_in_profit_relative_to_own_supply"),
true,
version,
format,
StorableVecGeneatorOptions::default().add_last(),
)
.unwrap()
}),
indexes_to_supply_relative_to_circulating_supply: compute_relative_to_all.then(|| {
ComputedVecsFromHeight::forced_import(
path,
&suffix("supply_relative_to_circulating_supply"),
true,
version,
format,
StorableVecGeneatorOptions::default().add_last(),
)
.unwrap()
}),
height_to_supply_even_relative_to_circulating_supply: (compute_relative_to_all
&& compute_dollars)
.then(|| {
EagerVec::forced_import(
path,
&suffix("supply_even_relative_to_circulating_supply"),
version,
format,
)
.unwrap()
}),
height_to_supply_in_loss_relative_to_circulating_supply: (compute_relative_to_all
&& compute_dollars)
.then(|| {
EagerVec::forced_import(
path,
&suffix("supply_in_loss_relative_to_circulating_supply"),
version,
format,
)
.unwrap()
}),
height_to_supply_in_profit_relative_to_circulating_supply: (compute_relative_to_all
&& compute_dollars)
.then(|| {
EagerVec::forced_import(
path,
&suffix("supply_in_profit_relative_to_circulating_supply"),
version,
format,
)
.unwrap()
}),
indexes_to_supply_even_relative_to_circulating_supply: (compute_relative_to_all
&& compute_dollars)
.then(|| {
ComputedVecsFromDateIndex::forced_import(
path,
&suffix("supply_even_relative_to_circulating_supply"),
true,
version,
format,
StorableVecGeneatorOptions::default().add_last(),
)
.unwrap()
}),
indexes_to_supply_in_loss_relative_to_circulating_supply: (compute_relative_to_all
&& compute_dollars)
.then(|| {
ComputedVecsFromDateIndex::forced_import(
path,
&suffix("supply_in_loss_relative_to_circulating_supply"),
true,
version,
format,
StorableVecGeneatorOptions::default().add_last(),
)
.unwrap()
}),
indexes_to_supply_in_profit_relative_to_circulating_supply: (compute_relative_to_all
&& compute_dollars)
.then(|| {
ComputedVecsFromDateIndex::forced_import(
path,
&suffix("supply_in_profit_relative_to_circulating_supply"),
true,
version,
format,
StorableVecGeneatorOptions::default().add_last(),
)
.unwrap()
}),
})
}
@@ -1444,13 +1666,13 @@ impl Vecs {
Ok(())
}
pub fn compute_rest(
#[allow(clippy::too_many_arguments)]
pub fn compute_rest_part1(
&mut self,
indexer: &Indexer,
indexes: &indexes::Vecs,
fetched: Option<&fetched::Vecs>,
starting_indexes: &Indexes,
market: &market::Vecs,
exit: &Exit,
) -> color_eyre::Result<()> {
self.indexes_to_supply.compute_rest(
@@ -1485,6 +1707,42 @@ impl Vecs {
},
)?;
Ok(())
}
#[allow(clippy::too_many_arguments)]
pub fn compute_rest_part2(
&mut self,
indexer: &Indexer,
indexes: &indexes::Vecs,
fetched: Option<&fetched::Vecs>,
starting_indexes: &Indexes,
market: &market::Vecs,
height_to_supply: &impl AnyIterableVec<Height, Sats>,
dateindex_to_supply: &impl AnyIterableVec<DateIndex, Sats>,
height_to_realized_cap: Option<&impl AnyIterableVec<Height, Dollars>>,
exit: &Exit,
) -> color_eyre::Result<()> {
if let Some(v) = self
.indexes_to_supply_relative_to_circulating_supply
.as_mut()
{
v.compute_all(
indexer,
indexes,
starting_indexes,
exit,
|v, _, _, starting_indexes, exit| {
v.compute_percentage(
starting_indexes.height,
&self.height_to_supply,
height_to_supply,
exit,
)
},
)?;
}
if let Some(indexes_to_realized_cap) = self.indexes_to_realized_cap.as_mut() {
indexes_to_realized_cap.compute_rest(
indexes,
@@ -1715,7 +1973,9 @@ impl Vecs {
.as_mut()
.unwrap()
.compute_rest(
indexer,
indexes,
fetched,
starting_indexes,
exit,
Some(self.dateindex_to_supply_in_profit.as_ref().unwrap()),
@@ -1724,13 +1984,17 @@ impl Vecs {
.as_mut()
.unwrap()
.compute_rest(
indexer,
indexes,
fetched,
starting_indexes,
exit,
Some(self.dateindex_to_supply_in_loss.as_ref().unwrap()),
)?;
self.indexes_to_supply_even.as_mut().unwrap().compute_rest(
indexer,
indexes,
fetched,
starting_indexes,
exit,
Some(self.dateindex_to_supply_even.as_ref().unwrap()),
@@ -1859,6 +2123,216 @@ impl Vecs {
)
},
)?;
self.indexes_to_net_realized_profit_and_loss_relative_to_realized_cap
.as_mut()
.unwrap()
.compute_all(
indexer,
indexes,
starting_indexes,
exit,
|vec, _, _, starting_indexes, exit| {
vec.compute_percentage(
starting_indexes.height,
self.indexes_to_net_realized_profit_and_loss
.as_ref()
.unwrap()
.height
.as_ref()
.unwrap(),
*height_to_realized_cap.as_ref().unwrap(),
exit,
)
},
)?;
self.height_to_supply_even_value
.as_mut()
.unwrap()
.compute_rest(
fetched,
starting_indexes,
exit,
Some(self.height_to_supply_even.as_ref().unwrap()),
)?;
self.height_to_supply_in_loss_value
.as_mut()
.unwrap()
.compute_rest(
fetched,
starting_indexes,
exit,
Some(self.height_to_supply_in_loss.as_ref().unwrap()),
)?;
self.height_to_supply_in_profit_value
.as_mut()
.unwrap()
.compute_rest(
fetched,
starting_indexes,
exit,
Some(self.height_to_supply_in_profit.as_ref().unwrap()),
)?;
self.height_to_supply_even_relative_to_own_supply
.as_mut()
.unwrap()
.compute_percentage(
starting_indexes.height,
self.height_to_supply_even.as_ref().unwrap(),
&self.height_to_supply,
exit,
)?;
self.height_to_supply_in_loss_relative_to_own_supply
.as_mut()
.unwrap()
.compute_percentage(
starting_indexes.height,
self.height_to_supply_in_loss.as_ref().unwrap(),
&self.height_to_supply,
exit,
)?;
self.height_to_supply_in_profit_relative_to_own_supply
.as_mut()
.unwrap()
.compute_percentage(
starting_indexes.height,
self.height_to_supply_even.as_ref().unwrap(),
&self.height_to_supply,
exit,
)?;
self.indexes_to_supply_even_relative_to_own_supply
.as_mut()
.unwrap()
.compute_all(
indexer,
indexes,
starting_indexes,
exit,
|v, _, _, starting_indexes, exit| {
v.compute_percentage(
starting_indexes.dateindex,
self.dateindex_to_supply_even.as_ref().unwrap(),
self.indexes_to_supply.sats.dateindex.unwrap_last(),
exit,
)
},
)?;
self.indexes_to_supply_in_loss_relative_to_own_supply
.as_mut()
.unwrap()
.compute_all(
indexer,
indexes,
starting_indexes,
exit,
|v, _, _, starting_indexes, exit| {
v.compute_percentage(
starting_indexes.dateindex,
self.dateindex_to_supply_even.as_ref().unwrap(),
self.indexes_to_supply.sats.dateindex.unwrap_last(),
exit,
)
},
)?;
self.indexes_to_supply_in_profit_relative_to_own_supply
.as_mut()
.unwrap()
.compute_all(
indexer,
indexes,
starting_indexes,
exit,
|v, _, _, starting_indexes, exit| {
v.compute_percentage(
starting_indexes.dateindex,
self.dateindex_to_supply_even.as_ref().unwrap(),
self.indexes_to_supply.sats.dateindex.unwrap_last(),
exit,
)
},
)?;
if let Some(height_to_supply_even_relative_to_circulating_supply) = self
.height_to_supply_even_relative_to_circulating_supply
.as_mut()
{
height_to_supply_even_relative_to_circulating_supply.compute_percentage(
starting_indexes.height,
self.height_to_supply_even.as_ref().unwrap(),
height_to_supply,
exit,
)?;
self.height_to_supply_in_loss_relative_to_circulating_supply
.as_mut()
.unwrap()
.compute_percentage(
starting_indexes.height,
self.height_to_supply_in_loss.as_ref().unwrap(),
height_to_supply,
exit,
)?;
self.height_to_supply_in_profit_relative_to_circulating_supply
.as_mut()
.unwrap()
.compute_percentage(
starting_indexes.height,
self.height_to_supply_in_profit.as_ref().unwrap(),
height_to_supply,
exit,
)?;
self.indexes_to_supply_even_relative_to_circulating_supply
.as_mut()
.unwrap()
.compute_all(
indexer,
indexes,
starting_indexes,
exit,
|v, _, _, starting_indexes, exit| {
v.compute_percentage(
starting_indexes.dateindex,
self.dateindex_to_supply_even.as_ref().unwrap(),
dateindex_to_supply,
exit,
)
},
)?;
self.indexes_to_supply_in_loss_relative_to_circulating_supply
.as_mut()
.unwrap()
.compute_all(
indexer,
indexes,
starting_indexes,
exit,
|v, _, _, starting_indexes, exit| {
v.compute_percentage(
starting_indexes.dateindex,
self.dateindex_to_supply_in_loss.as_ref().unwrap(),
dateindex_to_supply,
exit,
)
},
)?;
self.indexes_to_supply_in_profit_relative_to_circulating_supply
.as_mut()
.unwrap()
.compute_all(
indexer,
indexes,
starting_indexes,
exit,
|v, _, _, starting_indexes, exit| {
v.compute_percentage(
starting_indexes.dateindex,
self.dateindex_to_supply_in_profit.as_ref().unwrap(),
dateindex_to_supply,
exit,
)
},
)?;
}
}
Ok(())
@@ -2017,6 +2491,57 @@ impl Vecs {
self.indexes_to_net_unrealized_profit_and_loss_relative_to_market_cap
.as_ref()
.map_or(vec![], |v| v.vecs()),
self.indexes_to_net_realized_profit_and_loss_relative_to_realized_cap
.as_ref()
.map_or(vec![], |v| v.vecs()),
self.height_to_supply_even_value
.as_ref()
.map_or(vec![], |v| v.vecs()),
self.height_to_supply_in_loss_value
.as_ref()
.map_or(vec![], |v| v.vecs()),
self.height_to_supply_in_profit_value
.as_ref()
.map_or(vec![], |v| v.vecs()),
self.height_to_supply_even_relative_to_own_supply
.as_ref()
.map_or(vec![], |v| vec![v]),
self.height_to_supply_in_loss_relative_to_own_supply
.as_ref()
.map_or(vec![], |v| vec![v]),
self.height_to_supply_in_profit_relative_to_own_supply
.as_ref()
.map_or(vec![], |v| vec![v]),
self.indexes_to_supply_even_relative_to_own_supply
.as_ref()
.map_or(vec![], |v| v.vecs()),
self.indexes_to_supply_in_loss_relative_to_own_supply
.as_ref()
.map_or(vec![], |v| v.vecs()),
self.indexes_to_supply_in_profit_relative_to_own_supply
.as_ref()
.map_or(vec![], |v| v.vecs()),
self.indexes_to_supply_relative_to_circulating_supply
.as_ref()
.map_or(vec![], |v| v.vecs()),
self.height_to_supply_even_relative_to_circulating_supply
.as_ref()
.map_or(vec![], |v| vec![v]),
self.height_to_supply_in_loss_relative_to_circulating_supply
.as_ref()
.map_or(vec![], |v| vec![v]),
self.height_to_supply_in_profit_relative_to_circulating_supply
.as_ref()
.map_or(vec![], |v| vec![v]),
self.indexes_to_supply_even_relative_to_circulating_supply
.as_ref()
.map_or(vec![], |v| v.vecs()),
self.indexes_to_supply_in_loss_relative_to_circulating_supply
.as_ref()
.map_or(vec![], |v| v.vecs()),
self.indexes_to_supply_in_profit_relative_to_circulating_supply
.as_ref()
.map_or(vec![], |v| v.vecs()),
]
.into_iter()
.flatten()

View File

@@ -29,7 +29,7 @@ use super::{
pub mod cohort;
mod outputs;
const VERSION: Version = Version::new(21);
const VERSION: Version = Version::new(9);
#[derive(Clone)]
pub struct Vecs {
@@ -40,6 +40,10 @@ pub struct Vecs {
pub indexes_to_unspendable_supply: ComputedValueVecsFromHeight,
pub height_to_opreturn_supply: EagerVec<Height, Sats>,
pub indexes_to_opreturn_supply: ComputedValueVecsFromHeight,
// pub height_to_satdays_destroyed: EagerVec<Height, Sats>,
// pub indexes_to_satdays_destroyed: ComputedValueVecsFromHeight,
// pub height_to_satblocks_destroyed: EagerVec<Height, Sats>,
// pub indexes_to_satblocks_destroyed: ComputedValueVecsFromHeight,
utxos_vecs: Outputs<(OutputFilter, cohort::Vecs)>,
}
@@ -98,6 +102,36 @@ impl Vecs {
StorableVecGeneatorOptions::default().add_last(),
compute_dollars,
)?,
// height_to_satdays_destroyed: EagerVec::forced_import(
// path,
// "satdays_destroyed",
// version,
// format,
// )?,
// indexes_to_satdays_destroyed: ComputedValueVecsFromHeight::forced_import(
// path,
// "satdays_destroyed",
// false,
// version + VERSION + Version::ZERO,
// format,
// StorableVecGeneatorOptions::default().add_last(),
// compute_dollars,
// )?,
// height_to_satblocks_destroyed: EagerVec::forced_import(
// path,
// "satblocks_destroyed",
// version,
// format,
// )?,
// indexes_to_satblocks_destroyed: ComputedValueVecsFromHeight::forced_import(
// path,
// "satblocks_destroyed",
// false,
// version + VERSION + Version::ZERO,
// format,
// StorableVecGeneatorOptions::default().add_last(),
// compute_dollars,
// )?,
utxos_vecs: {
Outputs::<(OutputFilter, cohort::Vecs)>::from(Outputs {
all: cohort::Vecs::forced_import(
@@ -109,6 +143,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
false,
)?,
by_term: OutputsByTerm {
short: cohort::Vecs::forced_import(
@@ -120,6 +155,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
long: cohort::Vecs::forced_import(
path,
@@ -130,6 +166,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
},
by_up_to_date: OutputsByUpToDate {
@@ -142,6 +179,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_1w: cohort::Vecs::forced_import(
path,
@@ -152,6 +190,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_1m: cohort::Vecs::forced_import(
path,
@@ -162,6 +201,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_2m: cohort::Vecs::forced_import(
path,
@@ -172,6 +212,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_3m: cohort::Vecs::forced_import(
path,
@@ -182,6 +223,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_4m: cohort::Vecs::forced_import(
path,
@@ -192,6 +234,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_5m: cohort::Vecs::forced_import(
path,
@@ -202,6 +245,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_6m: cohort::Vecs::forced_import(
path,
@@ -212,6 +256,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_1y: cohort::Vecs::forced_import(
path,
@@ -222,6 +267,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_2y: cohort::Vecs::forced_import(
path,
@@ -232,6 +278,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_3y: cohort::Vecs::forced_import(
path,
@@ -242,6 +289,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_4y: cohort::Vecs::forced_import(
path,
@@ -252,6 +300,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_5y: cohort::Vecs::forced_import(
path,
@@ -262,6 +311,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_6y: cohort::Vecs::forced_import(
path,
@@ -272,6 +322,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_7y: cohort::Vecs::forced_import(
path,
@@ -282,6 +333,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_8y: cohort::Vecs::forced_import(
path,
@@ -292,6 +344,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_10y: cohort::Vecs::forced_import(
path,
@@ -302,6 +355,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_15y: cohort::Vecs::forced_import(
path,
@@ -312,6 +366,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
},
by_from_date: OutputsByFromDate {
@@ -324,6 +379,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_1w: cohort::Vecs::forced_import(
path,
@@ -334,6 +390,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_1m: cohort::Vecs::forced_import(
path,
@@ -344,6 +401,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_2m: cohort::Vecs::forced_import(
path,
@@ -354,6 +412,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_3m: cohort::Vecs::forced_import(
path,
@@ -364,6 +423,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_4m: cohort::Vecs::forced_import(
path,
@@ -374,6 +434,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_5m: cohort::Vecs::forced_import(
path,
@@ -384,6 +445,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_6m: cohort::Vecs::forced_import(
path,
@@ -394,6 +456,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_1y: cohort::Vecs::forced_import(
path,
@@ -404,6 +467,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_2y: cohort::Vecs::forced_import(
path,
@@ -414,6 +478,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_3y: cohort::Vecs::forced_import(
path,
@@ -424,6 +489,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_4y: cohort::Vecs::forced_import(
path,
@@ -434,6 +500,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_5y: cohort::Vecs::forced_import(
path,
@@ -444,6 +511,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_6y: cohort::Vecs::forced_import(
path,
@@ -454,6 +522,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_7y: cohort::Vecs::forced_import(
path,
@@ -464,6 +533,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_8y: cohort::Vecs::forced_import(
path,
@@ -474,6 +544,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_10y: cohort::Vecs::forced_import(
path,
@@ -484,6 +555,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_15y: cohort::Vecs::forced_import(
path,
@@ -494,6 +566,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
},
by_date_range: OutputsByDateRange {
@@ -506,6 +579,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_1d_to_1w: cohort::Vecs::forced_import(
path,
@@ -516,6 +590,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_1w_to_1m: cohort::Vecs::forced_import(
path,
@@ -526,6 +601,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_1m_to_3m: cohort::Vecs::forced_import(
path,
@@ -536,6 +612,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_3m_to_6m: cohort::Vecs::forced_import(
path,
@@ -546,6 +623,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_6m_to_1y: cohort::Vecs::forced_import(
path,
@@ -556,6 +634,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_1y_to_2y: cohort::Vecs::forced_import(
path,
@@ -566,6 +645,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_2y_to_3y: cohort::Vecs::forced_import(
path,
@@ -576,6 +656,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_3y_to_4y: cohort::Vecs::forced_import(
path,
@@ -586,6 +667,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_4y_to_5y: cohort::Vecs::forced_import(
path,
@@ -596,6 +678,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_5y_to_7y: cohort::Vecs::forced_import(
path,
@@ -606,6 +689,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_7y_to_10y: cohort::Vecs::forced_import(
path,
@@ -616,6 +700,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_10y_to_15y: cohort::Vecs::forced_import(
path,
@@ -626,6 +711,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_15y_to_end: cohort::Vecs::forced_import(
path,
@@ -636,6 +722,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
},
by_epoch: OutputsByEpoch {
@@ -648,6 +735,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_1: cohort::Vecs::forced_import(
path,
@@ -658,6 +746,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_2: cohort::Vecs::forced_import(
path,
@@ -668,6 +757,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_3: cohort::Vecs::forced_import(
path,
@@ -678,6 +768,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_4: cohort::Vecs::forced_import(
path,
@@ -688,6 +779,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
},
by_size_range: OutputsBySizeRange {
@@ -700,6 +792,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
from_1sat_to_10sats: cohort::Vecs::forced_import(
path,
@@ -710,6 +803,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
from_10sats_to_100sats: cohort::Vecs::forced_import(
path,
@@ -720,6 +814,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
from_100sats_to_1_000sats: cohort::Vecs::forced_import(
path,
@@ -730,6 +825,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
from_1_000sats_to_10_000sats: cohort::Vecs::forced_import(
path,
@@ -740,6 +836,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
from_10_000sats_to_100_000sats: cohort::Vecs::forced_import(
path,
@@ -750,6 +847,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
from_100_000sats_to_1_000_000sats: cohort::Vecs::forced_import(
path,
@@ -760,6 +858,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
from_1_000_000sats_to_10_000_000sats: cohort::Vecs::forced_import(
path,
@@ -770,6 +869,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
from_10_000_000sats_to_1btc: cohort::Vecs::forced_import(
path,
@@ -780,6 +880,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
from_1btc_to_10btc: cohort::Vecs::forced_import(
path,
@@ -790,6 +891,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
from_10btc_to_100btc: cohort::Vecs::forced_import(
path,
@@ -800,6 +902,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
from_100btc_to_1_000btc: cohort::Vecs::forced_import(
path,
@@ -810,6 +913,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
from_1_000btc_to_10_000btc: cohort::Vecs::forced_import(
path,
@@ -820,6 +924,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
from_10_000btc_to_100_000btc: cohort::Vecs::forced_import(
path,
@@ -830,6 +935,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
from_100_000btc: cohort::Vecs::forced_import(
path,
@@ -840,6 +946,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
},
by_up_to_size: OutputsByUpToSize {
@@ -852,6 +959,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_10_000sats: cohort::Vecs::forced_import(
path,
@@ -862,6 +970,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_1btc: cohort::Vecs::forced_import(
path,
@@ -872,6 +981,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_10btc: cohort::Vecs::forced_import(
path,
@@ -882,6 +992,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_100btc: cohort::Vecs::forced_import(
path,
@@ -892,6 +1003,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
},
by_from_size: OutputsByFromSize {
@@ -904,6 +1016,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_1btc: cohort::Vecs::forced_import(
path,
@@ -914,6 +1027,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_10btc: cohort::Vecs::forced_import(
path,
@@ -924,6 +1038,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
_100btc: cohort::Vecs::forced_import(
path,
@@ -934,6 +1049,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
},
// by_value: OutputsByValue {
@@ -1039,6 +1155,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
p2pk33: cohort::Vecs::forced_import(
path,
@@ -1049,6 +1166,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
p2pkh: cohort::Vecs::forced_import(
path,
@@ -1059,6 +1177,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
p2ms: cohort::Vecs::forced_import(
path,
@@ -1069,6 +1188,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
p2sh: cohort::Vecs::forced_import(
path,
@@ -1079,6 +1199,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
// opreturn: cohort::Vecs::forced_import(
// path,
@@ -1098,6 +1219,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
p2wsh: cohort::Vecs::forced_import(
path,
@@ -1108,6 +1230,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
p2tr: cohort::Vecs::forced_import(
path,
@@ -1118,6 +1241,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
p2a: cohort::Vecs::forced_import(
path,
@@ -1128,6 +1252,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
empty: cohort::Vecs::forced_import(
path,
@@ -1138,6 +1263,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
unknown: cohort::Vecs::forced_import(
path,
@@ -1148,6 +1274,7 @@ impl Vecs {
fetched,
keyspace,
&stores_path,
true,
)?,
},
})
@@ -1250,6 +1377,14 @@ impl Vecs {
.validate_computed_version_or_reset_file(
base_version + self.height_to_opreturn_supply.inner_version(),
)?;
// self.height_to_satblocks_destroyed
// .validate_computed_version_or_reset_file(
// base_version + self.height_to_satblocks_destroyed.inner_version(),
// )?;
// self.height_to_satdays_destroyed
// .validate_computed_version_or_reset_file(
// base_version + self.height_to_satdays_destroyed.inner_version(),
// )?;
let mut chain_state: Vec<BlockState>;
let mut chain_state_starting_height = Height::from(self.chain_state.len());
@@ -1302,6 +1437,8 @@ impl Vecs {
.min(stateful_starting_height)
.min(Height::from(self.height_to_unspendable_supply.len()))
.min(Height::from(self.height_to_opreturn_supply.len()));
// .min(Height::from(self.height_to_satblocks_destroyed.len()));
// .min(Height::from(self.height_to_satdays_destroyed.len()));
// ---
// INIT
@@ -1318,7 +1455,6 @@ impl Vecs {
} else {
Sats::ZERO
};
let mut opreturn_supply = if let Some(prev_height) = starting_height.decremented() {
self.height_to_opreturn_supply
.into_iter()
@@ -1326,6 +1462,20 @@ impl Vecs {
} else {
Sats::ZERO
};
// let mut satblocks_destroyed = if let Some(prev_height) = starting_height.decremented() {
// self.height_to_satblocks_destroyed
// .into_iter()
// .unwrap_get_inner(prev_height)
// } else {
// Sats::ZERO
// };
// let mut satdays_destroyed = if let Some(prev_height) = starting_height.decremented() {
// self.height_to_satdays_destroyed
// .into_iter()
// .unwrap_get_inner(prev_height)
// } else {
// Sats::ZERO
// };
let mut height = starting_height;
starting_indexes.update_from_height(height, indexes);
@@ -1561,12 +1711,39 @@ impl Vecs {
info!("Computing rest...");
// Compute other vecs from height vecs
self.utxos_vecs
.as_mut_vecs()
.par_iter_mut()
.try_for_each(|(_, v)| {
v.compute_rest(indexer, indexes, fetched, &starting_indexes, market, exit)
v.compute_rest_part1(indexer, indexes, fetched, &starting_indexes, exit)
})?;
let height_to_supply = self.utxos_vecs.all.1.height_to_supply.clone();
let dateindex_to_supply = self
.utxos_vecs
.all
.1
.indexes_to_supply
.sats
.dateindex
.unwrap_last()
.clone();
let height_to_realized_cap = self.utxos_vecs.all.1.height_to_realized_cap.clone();
let height_to_realized_cap = height_to_realized_cap.as_ref();
self.utxos_vecs
.as_mut_vecs()
.par_iter_mut()
.try_for_each(|(_, v)| {
v.compute_rest_part2(
indexer,
indexes,
fetched,
&starting_indexes,
market,
&height_to_supply,
&dateindex_to_supply,
height_to_realized_cap,
exit,
)
})?;
self.indexes_to_unspendable_supply.compute_rest(
indexer,
@@ -1584,6 +1761,22 @@ impl Vecs {
exit,
Some(&self.height_to_opreturn_supply),
)?;
// self.indexes_to_satblocks_destroyed.compute_rest(
// indexer,
// indexes,
// fetched,
// &starting_indexes,
// exit,
// Some(&self.height_to_satblocks_destroyed),
// )?;
// self.indexes_to_satdays_destroyed.compute_rest(
// indexer,
// indexes,
// fetched,
// &starting_indexes,
// exit,
// Some(&self.height_to_satdays_destroyed),
// )?;
exit.release();
@@ -1602,6 +1795,8 @@ impl Vecs {
.try_for_each(|(_, v)| v.safe_flush_stateful_vecs(height, exit))?;
self.height_to_unspendable_supply.safe_flush(exit)?;
self.height_to_opreturn_supply.safe_flush(exit)?;
// self.height_to_satblocks_destroyed.safe_flush(exit)?;
// self.height_to_satdays_destroyed.safe_flush(exit)?;
self.chain_state.truncate_if_needed(Height::ZERO)?;
chain_state.iter().for_each(|block_state| {
@@ -1625,6 +1820,16 @@ impl Vecs {
&self.height_to_unspendable_supply,
&self.height_to_opreturn_supply,
],
// self.indexes_to_satblocks_destroyed.vecs(),
// vec![
// &self.height_to_unspendable_supply,
// &self.height_to_satblocks_destroyed,
// ],
// self.indexes_to_satdays_destroyed.vecs(),
// vec![
// &self.height_to_unspendable_supply,
// &self.height_to_satdays_destroyed,
// ],
]
.into_iter()
.flatten()