mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-25 23:29:58 -07:00
global: utxos part 6
This commit is contained in:
@@ -20,14 +20,14 @@ impl Add<BlockState> for BlockState {
|
||||
}
|
||||
|
||||
impl AddAssign<&BlockState> for BlockState {
|
||||
fn add_assign(&mut self, rhs: &BlockState) {
|
||||
fn add_assign(&mut self, rhs: &Self) {
|
||||
self.supply += &rhs.supply;
|
||||
}
|
||||
}
|
||||
|
||||
impl SubAssign for BlockState {
|
||||
fn sub_assign(&mut self, rhs: Self) {
|
||||
self.supply -= rhs.supply;
|
||||
impl SubAssign<&BlockState> for BlockState {
|
||||
fn sub_assign(&mut self, rhs: &Self) {
|
||||
self.supply -= &rhs.supply;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,9 +56,7 @@ impl<'a> From<ReceivedBlockStateData<'a>> for BlockState {
|
||||
.for_each(|spendable_block_state| {
|
||||
block_state.supply += &spendable_block_state.0;
|
||||
});
|
||||
block_state.supply.value += received.unspendable.unknown.0.value;
|
||||
block_state.supply.utxos +=
|
||||
received.unspendable.empty.0.utxos + received.unspendable.unknown.0.utxos;
|
||||
block_state.supply.utxos += received.unspendable.empty.0.utxos;
|
||||
block_state
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use brk_core::{Bitcoin, CheckedSub, Dollars};
|
||||
use super::SupplyState;
|
||||
|
||||
// Vecs ? probably
|
||||
#[derive(Default, Clone)]
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct CohortState {
|
||||
pub supply: SupplyState,
|
||||
pub realized_cap: Option<Dollars>,
|
||||
@@ -18,7 +18,7 @@ impl CohortState {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn decrement(&mut self, supply_state: SupplyState, price: Option<Dollars>) {
|
||||
pub fn decrement(&mut self, supply_state: &SupplyState, price: Option<Dollars>) {
|
||||
if let Some(realized_cap) = self.realized_cap.as_mut() {
|
||||
*realized_cap = realized_cap
|
||||
.checked_sub(price.unwrap() * Bitcoin::from(supply_state.value))
|
||||
|
||||
@@ -15,6 +15,7 @@ pub struct OutputsBySpendableType<T> {
|
||||
pub p2wsh: T,
|
||||
pub p2tr: T,
|
||||
pub p2a: T,
|
||||
pub unknown: T,
|
||||
}
|
||||
|
||||
impl<T> OutputsBySpendableType<T> {
|
||||
@@ -29,6 +30,7 @@ impl<T> OutputsBySpendableType<T> {
|
||||
OutputType::P2WSH => &self.p2wsh,
|
||||
OutputType::P2TR => &self.p2tr,
|
||||
OutputType::P2A => &self.p2a,
|
||||
OutputType::Unknown => &self.unknown,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
@@ -44,11 +46,12 @@ impl<T> OutputsBySpendableType<T> {
|
||||
OutputType::P2WSH => &mut self.p2wsh,
|
||||
OutputType::P2TR => &mut self.p2tr,
|
||||
OutputType::P2A => &mut self.p2a,
|
||||
OutputType::Unknown => &mut self.unknown,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_vec(&self) -> [&T; 9] {
|
||||
pub fn as_vec(&self) -> [&T; 10] {
|
||||
[
|
||||
&self.p2pk65,
|
||||
&self.p2pk33,
|
||||
@@ -59,10 +62,11 @@ impl<T> OutputsBySpendableType<T> {
|
||||
&self.p2wsh,
|
||||
&self.p2tr,
|
||||
&self.p2a,
|
||||
&self.unknown,
|
||||
]
|
||||
}
|
||||
|
||||
pub fn as_mut_vec(&mut self) -> [&mut T; 9] {
|
||||
pub fn as_mut_vec(&mut self) -> [&mut T; 10] {
|
||||
[
|
||||
&mut self.p2pk65,
|
||||
&mut self.p2pk33,
|
||||
@@ -73,10 +77,11 @@ impl<T> OutputsBySpendableType<T> {
|
||||
&mut self.p2wsh,
|
||||
&mut self.p2tr,
|
||||
&mut self.p2a,
|
||||
&mut self.unknown,
|
||||
]
|
||||
}
|
||||
|
||||
pub fn as_typed_vec(&self) -> [(OutputType, &T); 9] {
|
||||
pub fn as_typed_vec(&self) -> [(OutputType, &T); 10] {
|
||||
[
|
||||
(OutputType::P2PK65, &self.p2pk65),
|
||||
(OutputType::P2PK33, &self.p2pk33),
|
||||
@@ -87,12 +92,13 @@ impl<T> OutputsBySpendableType<T> {
|
||||
(OutputType::P2WSH, &self.p2wsh),
|
||||
(OutputType::P2TR, &self.p2tr),
|
||||
(OutputType::P2A, &self.p2a),
|
||||
(OutputType::Unknown, &self.unknown),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> OutputsBySpendableType<(OutputFilter, T)> {
|
||||
pub fn vecs(&self) -> [&T; 9] {
|
||||
pub fn vecs(&self) -> [&T; 10] {
|
||||
[
|
||||
&self.p2pk65.1,
|
||||
&self.p2pk33.1,
|
||||
@@ -103,6 +109,7 @@ impl<T> OutputsBySpendableType<(OutputFilter, T)> {
|
||||
&self.p2wsh.1,
|
||||
&self.p2tr.1,
|
||||
&self.p2a.1,
|
||||
&self.unknown.1,
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -119,6 +126,7 @@ impl<T> From<OutputsBySpendableType<T>> for OutputsBySpendableType<(OutputFilter
|
||||
p2wsh: (OutputFilter::Type(OutputType::P2WSH), value.p2wsh),
|
||||
p2tr: (OutputFilter::Type(OutputType::P2TR), value.p2tr),
|
||||
p2a: (OutputFilter::Type(OutputType::P2A), value.p2a),
|
||||
unknown: (OutputFilter::Type(OutputType::Unknown), value.unknown),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,9 +37,9 @@ impl<T> OutputsByType<T> {
|
||||
OutputType::P2WSH => &mut self.spendable.p2wsh,
|
||||
OutputType::P2TR => &mut self.spendable.p2tr,
|
||||
OutputType::P2A => &mut self.spendable.p2a,
|
||||
OutputType::Unknown => &mut self.spendable.unknown,
|
||||
OutputType::OpReturn => &mut self.unspendable.op_return,
|
||||
OutputType::Empty => &mut self.unspendable.empty,
|
||||
OutputType::Unknown => &mut self.unspendable.unknown,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
pub struct OutputsByUnspendableType<T> {
|
||||
pub op_return: T,
|
||||
pub empty: T,
|
||||
pub unknown: T,
|
||||
// pub unknown: T,
|
||||
}
|
||||
|
||||
impl<T> OutputsByUnspendableType<T> {
|
||||
@@ -33,8 +33,12 @@ impl<T> OutputsByUnspendableType<T> {
|
||||
// .collect::<Vec<_>>()
|
||||
// }
|
||||
|
||||
pub fn as_vec(&self) -> [&T; 3] {
|
||||
[&self.op_return, &self.empty, &self.unknown]
|
||||
pub fn as_vec(&self) -> [&T; 2] {
|
||||
[
|
||||
&self.op_return,
|
||||
&self.empty,
|
||||
// &self.unknown
|
||||
]
|
||||
}
|
||||
|
||||
// pub fn as_mut_vec(&mut self) -> [&mut T; 3] {
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::ops::Range;
|
||||
|
||||
use brk_core::{HalvingEpoch, OutputType, Sats};
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum OutputFilter {
|
||||
All,
|
||||
To(usize),
|
||||
|
||||
@@ -37,13 +37,13 @@ pub struct Outputs<T> {
|
||||
pub all: T,
|
||||
pub by_term: OutputsByTerm<T>,
|
||||
// pub by_up_to: OutputsByUpTo<T>,
|
||||
// pub by_from: OutputsByFrom<T>,
|
||||
pub by_from: OutputsByFrom<T>,
|
||||
// pub by_range: OutputsByRange<T>,
|
||||
// pub by_epoch: OutputsByEpoch<T>,
|
||||
// pub by_size: OutputsBySize<T>,
|
||||
pub by_epoch: OutputsByEpoch<T>,
|
||||
pub by_size: OutputsBySize<T>,
|
||||
// // Needs whole UTXO set, TODO later
|
||||
// // pub by_value: OutputsByValue<T>,
|
||||
// pub by_spendable_type: OutputsBySpendableType<T>,
|
||||
pub by_spendable_type: OutputsBySpendableType<T>,
|
||||
}
|
||||
|
||||
impl<T> Outputs<T> {
|
||||
@@ -52,12 +52,12 @@ impl<T> Outputs<T> {
|
||||
.into_iter()
|
||||
.chain(self.by_term.as_mut_vec())
|
||||
// .chain(self.by_up_to.as_mut_vec())
|
||||
// .chain(self.by_from.as_mut_vec())
|
||||
.chain(self.by_from.as_mut_vec())
|
||||
// .chain(self.by_range.as_mut_vec())
|
||||
// .chain(self.by_epoch.as_mut_vec())
|
||||
// .chain(self.by_size.as_mut_vec())
|
||||
.chain(self.by_epoch.as_mut_vec())
|
||||
.chain(self.by_size.as_mut_vec())
|
||||
// // .chain(self.by_value.as_mut_vec())
|
||||
// .chain(self.by_spendable_type.as_mut_vec())
|
||||
.chain(self.by_spendable_type.as_mut_vec())
|
||||
.collect::<Vec<_>>()
|
||||
}
|
||||
}
|
||||
@@ -73,9 +73,9 @@ impl Outputs<(OutputFilter, vecs::utxos::cohort::Vecs)> {
|
||||
self.by_term
|
||||
.as_mut_vec()
|
||||
.into_par_iter()
|
||||
// .chain(self.by_up_to.as_mut_vec())
|
||||
// .chain(self.by_from.as_mut_vec())
|
||||
// .chain(self.by_range.as_mut_vec())
|
||||
// .chain(self.by_up_to.as_mut_vec())
|
||||
.chain(self.by_from.as_mut_vec())
|
||||
// .chain(self.by_range.as_mut_vec())
|
||||
.for_each(|(filter, v)| {
|
||||
let state = &mut v.state;
|
||||
|
||||
@@ -107,7 +107,7 @@ impl Outputs<(OutputFilter, vecs::utxos::cohort::Vecs)> {
|
||||
if is && !was {
|
||||
state.increment(&block_state.supply, block_state.price);
|
||||
} else if was && !is {
|
||||
state.decrement(block_state.supply.clone(), block_state.price);
|
||||
state.decrement(&block_state.supply, block_state.price);
|
||||
}
|
||||
|
||||
ControlFlow::Continue(())
|
||||
@@ -124,10 +124,10 @@ impl Outputs<(OutputFilter, vecs::utxos::cohort::Vecs)> {
|
||||
.by_term
|
||||
.as_mut_vec()
|
||||
.into_iter()
|
||||
// .chain(self.by_up_to.as_mut_vec())
|
||||
// .chain(self.by_from.as_mut_vec())
|
||||
// .chain(self.by_range.as_mut_vec())
|
||||
// .chain(self.by_epoch.as_mut_vec())
|
||||
// .chain(self.by_up_to.as_mut_vec())
|
||||
.chain(self.by_from.as_mut_vec())
|
||||
// .chain(self.by_range.as_mut_vec())
|
||||
.chain(self.by_epoch.as_mut_vec())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let last_timestamp = chain_state.last().unwrap().timestamp;
|
||||
@@ -143,41 +143,41 @@ impl Outputs<(OutputFilter, vecs::utxos::cohort::Vecs)> {
|
||||
.timestamp
|
||||
.difference_in_days_between(last_timestamp);
|
||||
|
||||
self.all.1.state.decrement(supply_state.clone(), price);
|
||||
self.all.1.state.decrement(&supply_state, price);
|
||||
|
||||
// by_spendable_type.as_typed_vec().into_iter().for_each(
|
||||
// |(output_type, (supply_state, _))| {
|
||||
// self.by_spendable_type
|
||||
// .get_mut(output_type)
|
||||
// .1
|
||||
// .state
|
||||
// .decrement(supply_state.clone(), price)
|
||||
// },
|
||||
// );
|
||||
by_spendable_type.as_typed_vec().into_iter().for_each(
|
||||
|(output_type, (supply_state, _))| {
|
||||
self.by_spendable_type
|
||||
.get_mut(output_type)
|
||||
.1
|
||||
.state
|
||||
.decrement(supply_state, price)
|
||||
},
|
||||
);
|
||||
|
||||
// by_spendable_type
|
||||
// .as_vec()
|
||||
// .into_iter()
|
||||
// .flat_map(|(_, sats_received)| sats_received.iter())
|
||||
// .for_each(|sats| {
|
||||
// let sats = *sats;
|
||||
// self.by_size
|
||||
// .as_mut_vec()
|
||||
// .iter_mut()
|
||||
// .filter(|(filter, _)| match filter {
|
||||
// OutputFilter::Size(range) => range.contains(&sats),
|
||||
// _ => unreachable!(),
|
||||
// })
|
||||
// .for_each(|(_, vec)| {
|
||||
// vec.state.decrement(
|
||||
// SupplyState {
|
||||
// utxos: 1,
|
||||
// value: sats,
|
||||
// },
|
||||
// price,
|
||||
// );
|
||||
// });
|
||||
// });
|
||||
by_spendable_type
|
||||
.as_vec()
|
||||
.into_iter()
|
||||
.flat_map(|(_, sats_received)| sats_received.iter())
|
||||
.for_each(|sats| {
|
||||
let sats = *sats;
|
||||
self.by_size
|
||||
.as_mut_vec()
|
||||
.iter_mut()
|
||||
.filter(|(filter, _)| match filter {
|
||||
OutputFilter::Size(range) => range.contains(&sats),
|
||||
_ => unreachable!(),
|
||||
})
|
||||
.for_each(|(_, vec)| {
|
||||
vec.state.decrement(
|
||||
&SupplyState {
|
||||
utxos: 1,
|
||||
value: sats,
|
||||
},
|
||||
price,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
time_based_vecs
|
||||
.iter_mut()
|
||||
@@ -189,7 +189,7 @@ impl Outputs<(OutputFilter, vecs::utxos::cohort::Vecs)> {
|
||||
_ => unreachable!(),
|
||||
})
|
||||
.for_each(|(_, vecs)| {
|
||||
vecs.state.decrement(supply_state.clone(), price);
|
||||
vecs.state.decrement(&supply_state, price);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -205,7 +205,7 @@ impl Outputs<(OutputFilter, vecs::utxos::cohort::Vecs)> {
|
||||
[
|
||||
&mut self.all.1,
|
||||
&mut self.by_term.short.1,
|
||||
// &mut self.by_epoch.mut_vec_from_height(height).1,
|
||||
&mut self.by_epoch.mut_vec_from_height(height).1,
|
||||
// Skip from and range as can't receive in the past
|
||||
]
|
||||
.into_iter()
|
||||
@@ -214,43 +214,44 @@ impl Outputs<(OutputFilter, vecs::utxos::cohort::Vecs)> {
|
||||
v.state.increment(&supply_state, price);
|
||||
});
|
||||
|
||||
// let mut by_size = self.by_size.as_mut_vec();
|
||||
let mut by_size = self.by_size.as_mut_vec();
|
||||
|
||||
// received
|
||||
// .spendable
|
||||
// .as_vec()
|
||||
// .into_iter()
|
||||
// .flat_map(|(_, sats_received)| sats_received.iter())
|
||||
// .for_each(|sats| {
|
||||
// let sats = *sats;
|
||||
// by_size
|
||||
// .iter_mut()
|
||||
// .filter(|(filter, _)| match filter {
|
||||
// OutputFilter::Size(range) => range.contains(&sats),
|
||||
// _ => unreachable!(),
|
||||
// })
|
||||
// .for_each(|(_, vec)| {
|
||||
// vec.state.increment(
|
||||
// &SupplyState {
|
||||
// utxos: 1,
|
||||
// value: sats,
|
||||
// },
|
||||
// price,
|
||||
// );
|
||||
// });
|
||||
// });
|
||||
received
|
||||
.spendable
|
||||
.as_vec()
|
||||
.into_iter()
|
||||
.flat_map(|(_, sats_received)| sats_received.iter())
|
||||
.for_each(|sats| {
|
||||
let sats = *sats;
|
||||
|
||||
// self.by_spendable_type
|
||||
// .as_mut_vec()
|
||||
// .into_iter()
|
||||
// .for_each(|(filter, vecs)| {
|
||||
// let output_type = match filter {
|
||||
// OutputFilter::Type(output_type) => *output_type,
|
||||
// _ => unreachable!(),
|
||||
// };
|
||||
// vecs.state
|
||||
// .increment(&received.spendable.get(output_type).0, price)
|
||||
// });
|
||||
by_size
|
||||
.iter_mut()
|
||||
.filter(|(filter, _)| match filter {
|
||||
OutputFilter::Size(range) => range.contains(&sats),
|
||||
_ => unreachable!(),
|
||||
})
|
||||
.for_each(|(_, vec)| {
|
||||
vec.state.increment(
|
||||
&SupplyState {
|
||||
utxos: 1,
|
||||
value: sats,
|
||||
},
|
||||
price,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
self.by_spendable_type
|
||||
.as_mut_vec()
|
||||
.into_iter()
|
||||
.for_each(|(filter, vecs)| {
|
||||
let output_type = match filter {
|
||||
OutputFilter::Type(output_type) => *output_type,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
vecs.state
|
||||
.increment(&received.spendable.get(output_type).0, price)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,12 +261,12 @@ impl<T> Outputs<(OutputFilter, T)> {
|
||||
.into_iter()
|
||||
.chain(self.by_term.vecs())
|
||||
// .chain(self.by_up_to.vecs())
|
||||
// .chain(self.by_from.vecs())
|
||||
.chain(self.by_from.vecs())
|
||||
// .chain(self.by_range.vecs())
|
||||
// .chain(self.by_epoch.vecs())
|
||||
// .chain(self.by_size.vecs())
|
||||
.chain(self.by_epoch.vecs())
|
||||
.chain(self.by_size.vecs())
|
||||
// // .chain(self.by_value.vecs())
|
||||
// .chain(self.by_spendable_type.vecs())
|
||||
.chain(self.by_spendable_type.vecs())
|
||||
.collect::<Vec<_>>()
|
||||
}
|
||||
}
|
||||
@@ -276,13 +277,13 @@ impl<T> From<Outputs<T>> for Outputs<(OutputFilter, T)> {
|
||||
all: (OutputFilter::All, value.all),
|
||||
by_term: OutputsByTerm::from(value.by_term),
|
||||
// by_up_to: OutputsByUpTo::from(value.by_up_to),
|
||||
// by_from: OutputsByFrom::from(value.by_from),
|
||||
by_from: OutputsByFrom::from(value.by_from),
|
||||
// by_range: OutputsByRange::from(value.by_range),
|
||||
// by_epoch: OutputsByEpoch::from(value.by_epoch),
|
||||
// by_size: OutputsBySize::from(value.by_size),
|
||||
by_epoch: OutputsByEpoch::from(value.by_epoch),
|
||||
by_size: OutputsBySize::from(value.by_size),
|
||||
// // Needs whole UTXO set, TODO later
|
||||
// // by_value: OutputsByValue<T>,
|
||||
// by_spendable_type: OutputsBySpendableType::from(value.by_spendable_type),
|
||||
by_spendable_type: OutputsBySpendableType::from(value.by_spendable_type),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ impl AddAssign<&SupplyState> for SupplyState {
|
||||
}
|
||||
}
|
||||
|
||||
impl SubAssign for SupplyState {
|
||||
fn sub_assign(&mut self, rhs: Self) {
|
||||
impl SubAssign<&SupplyState> for SupplyState {
|
||||
fn sub_assign(&mut self, rhs: &Self) {
|
||||
self.utxos = self.utxos.checked_sub(rhs.utxos).unwrap();
|
||||
self.value = self.value.checked_sub(rhs.value).unwrap();
|
||||
}
|
||||
|
||||
@@ -103,9 +103,7 @@ where
|
||||
)?;
|
||||
|
||||
let height: Option<&EagerVec<Height, T>> = None;
|
||||
self.compute_rest(indexes, starting_indexes, exit, height)?;
|
||||
|
||||
Ok(())
|
||||
self.compute_rest(indexes, starting_indexes, exit, height)
|
||||
}
|
||||
|
||||
pub fn compute_rest(
|
||||
|
||||
@@ -18,7 +18,7 @@ use super::{ComputedVecsFromDateIndex, StorableVecGeneatorOptions};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ComputedRatioVecsFromDateIndex {
|
||||
pub price: ComputedVecsFromDateIndex<Dollars>,
|
||||
pub price: Option<ComputedVecsFromDateIndex<Dollars>>,
|
||||
|
||||
pub ratio: ComputedVecsFromDateIndex<StoredF32>,
|
||||
pub ratio_sma: ComputedVecsFromDateIndex<StoredF32>,
|
||||
@@ -60,19 +60,22 @@ impl ComputedRatioVecsFromDateIndex {
|
||||
pub fn forced_import(
|
||||
path: &Path,
|
||||
name: &str,
|
||||
// _compute_source: bool,
|
||||
compute_source: bool,
|
||||
version: Version,
|
||||
compressed: Compressed,
|
||||
options: StorableVecGeneatorOptions,
|
||||
) -> color_eyre::Result<Self> {
|
||||
Ok(Self {
|
||||
price: ComputedVecsFromDateIndex::forced_import(
|
||||
path,
|
||||
name,
|
||||
VERSION + version,
|
||||
compressed,
|
||||
options,
|
||||
)?,
|
||||
price: compute_source.then(|| {
|
||||
ComputedVecsFromDateIndex::forced_import(
|
||||
path,
|
||||
name,
|
||||
VERSION + version,
|
||||
compressed,
|
||||
options,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
ratio: ComputedVecsFromDateIndex::forced_import(
|
||||
path,
|
||||
&format!("{name}_ratio"),
|
||||
@@ -300,7 +303,7 @@ impl ComputedRatioVecsFromDateIndex {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn compute<F>(
|
||||
pub fn compute_all<F>(
|
||||
&mut self,
|
||||
indexer: &Indexer,
|
||||
indexes: &indexes::Vecs,
|
||||
@@ -319,8 +322,34 @@ impl ComputedRatioVecsFromDateIndex {
|
||||
) -> Result<()>,
|
||||
{
|
||||
self.price
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.compute(indexer, indexes, starting_indexes, exit, compute)?;
|
||||
|
||||
let date_to_price_opt: Option<&EagerVec<DateIndex, Dollars>> = None;
|
||||
self.compute_rest(
|
||||
indexer,
|
||||
indexes,
|
||||
fetched,
|
||||
starting_indexes,
|
||||
exit,
|
||||
date_to_price_opt,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn compute_rest(
|
||||
&mut self,
|
||||
indexer: &Indexer,
|
||||
indexes: &indexes::Vecs,
|
||||
fetched: &fetched::Vecs,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
date_to_price_opt: Option<&impl AnyIterableVec<DateIndex, Dollars>>,
|
||||
) -> color_eyre::Result<()> {
|
||||
let date_to_price = date_to_price_opt.unwrap_or_else(|| unsafe {
|
||||
std::mem::transmute(&self.price.as_ref().unwrap().dateindex)
|
||||
});
|
||||
|
||||
let closes = &fetched.timeindexes_to_close.dateindex;
|
||||
|
||||
self.ratio.compute(
|
||||
@@ -329,7 +358,7 @@ impl ComputedRatioVecsFromDateIndex {
|
||||
starting_indexes,
|
||||
exit,
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
let mut price = self.price.dateindex.into_iter();
|
||||
let mut price = date_to_price.iter();
|
||||
v.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
closes,
|
||||
@@ -590,6 +619,10 @@ impl ComputedRatioVecsFromDateIndex {
|
||||
self.ratio_m3sd
|
||||
.compute_rest(indexes, starting_indexes, exit)?;
|
||||
|
||||
let date_to_price = date_to_price_opt.unwrap_or_else(|| unsafe {
|
||||
std::mem::transmute(&self.price.as_ref().unwrap().dateindex)
|
||||
});
|
||||
|
||||
self.ratio_p99_as_price.compute(
|
||||
indexer,
|
||||
indexes,
|
||||
@@ -599,7 +632,7 @@ impl ComputedRatioVecsFromDateIndex {
|
||||
let mut iter = self.ratio_p99.dateindex.into_iter();
|
||||
vec.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
&self.price.dateindex,
|
||||
date_to_price,
|
||||
|(i, price, ..)| {
|
||||
let multiplier = iter.unwrap_get_inner(i);
|
||||
(i, price * multiplier)
|
||||
@@ -618,7 +651,7 @@ impl ComputedRatioVecsFromDateIndex {
|
||||
let mut iter = self.ratio_p99_5.dateindex.into_iter();
|
||||
vec.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
&self.price.dateindex,
|
||||
date_to_price,
|
||||
|(i, price, ..)| {
|
||||
let multiplier = iter.unwrap_get_inner(i);
|
||||
(i, price * multiplier)
|
||||
@@ -637,7 +670,7 @@ impl ComputedRatioVecsFromDateIndex {
|
||||
let mut iter = self.ratio_p99_9.dateindex.into_iter();
|
||||
vec.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
&self.price.dateindex,
|
||||
date_to_price,
|
||||
|(i, price, ..)| {
|
||||
let multiplier = iter.unwrap_get_inner(i);
|
||||
(i, price * multiplier)
|
||||
@@ -656,7 +689,7 @@ impl ComputedRatioVecsFromDateIndex {
|
||||
let mut iter = self.ratio_p1.dateindex.into_iter();
|
||||
vec.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
&self.price.dateindex,
|
||||
date_to_price,
|
||||
|(i, price, ..)| {
|
||||
let multiplier = iter.unwrap_get_inner(i);
|
||||
(i, price * multiplier)
|
||||
@@ -675,7 +708,7 @@ impl ComputedRatioVecsFromDateIndex {
|
||||
let mut iter = self.ratio_p0_5.dateindex.into_iter();
|
||||
vec.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
&self.price.dateindex,
|
||||
date_to_price,
|
||||
|(i, price, ..)| {
|
||||
let multiplier = iter.unwrap_get_inner(i);
|
||||
(i, price * multiplier)
|
||||
@@ -694,7 +727,7 @@ impl ComputedRatioVecsFromDateIndex {
|
||||
let mut iter = self.ratio_p0_1.dateindex.into_iter();
|
||||
vec.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
&self.price.dateindex,
|
||||
date_to_price,
|
||||
|(i, price, ..)| {
|
||||
let multiplier = iter.unwrap_get_inner(i);
|
||||
(i, price * multiplier)
|
||||
@@ -713,7 +746,7 @@ impl ComputedRatioVecsFromDateIndex {
|
||||
let mut iter = self.ratio_p1sd.dateindex.into_iter();
|
||||
vec.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
&self.price.dateindex,
|
||||
date_to_price,
|
||||
|(i, price, ..)| {
|
||||
let multiplier = iter.unwrap_get_inner(i);
|
||||
(i, price * multiplier)
|
||||
@@ -732,7 +765,7 @@ impl ComputedRatioVecsFromDateIndex {
|
||||
let mut iter = self.ratio_p2sd.dateindex.into_iter();
|
||||
vec.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
&self.price.dateindex,
|
||||
date_to_price,
|
||||
|(i, price, ..)| {
|
||||
let multiplier = iter.unwrap_get_inner(i);
|
||||
(i, price * multiplier)
|
||||
@@ -751,7 +784,7 @@ impl ComputedRatioVecsFromDateIndex {
|
||||
let mut iter = self.ratio_p3sd.dateindex.into_iter();
|
||||
vec.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
&self.price.dateindex,
|
||||
date_to_price,
|
||||
|(i, price, ..)| {
|
||||
let multiplier = iter.unwrap_get_inner(i);
|
||||
(i, price * multiplier)
|
||||
@@ -770,7 +803,7 @@ impl ComputedRatioVecsFromDateIndex {
|
||||
let mut iter = self.ratio_m1sd.dateindex.into_iter();
|
||||
vec.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
&self.price.dateindex,
|
||||
date_to_price,
|
||||
|(i, price, ..)| {
|
||||
let multiplier = iter.unwrap_get_inner(i);
|
||||
(i, price * multiplier)
|
||||
@@ -789,7 +822,7 @@ impl ComputedRatioVecsFromDateIndex {
|
||||
let mut iter = self.ratio_m2sd.dateindex.into_iter();
|
||||
vec.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
&self.price.dateindex,
|
||||
date_to_price,
|
||||
|(i, price, ..)| {
|
||||
let multiplier = iter.unwrap_get_inner(i);
|
||||
(i, price * multiplier)
|
||||
@@ -808,7 +841,7 @@ impl ComputedRatioVecsFromDateIndex {
|
||||
let mut iter = self.ratio_m3sd.dateindex.into_iter();
|
||||
vec.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
&self.price.dateindex,
|
||||
date_to_price,
|
||||
|(i, price, ..)| {
|
||||
let multiplier = iter.unwrap_get_inner(i);
|
||||
(i, price * multiplier)
|
||||
@@ -862,7 +895,7 @@ impl ComputedRatioVecsFromDateIndex {
|
||||
|
||||
pub fn vecs(&self) -> Vec<&dyn AnyCollectableVec> {
|
||||
[
|
||||
self.price.vecs(),
|
||||
self.price.as_ref().map_or(vec![], |v| v.vecs()),
|
||||
self.ratio.vecs(),
|
||||
self.ratio_sma.vecs(),
|
||||
self.ratio_1w_sma.vecs(),
|
||||
|
||||
@@ -209,6 +209,7 @@ impl Vecs {
|
||||
indexes_to_1w_sma: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
path,
|
||||
"1w_sma",
|
||||
true,
|
||||
VERSION + Version::ZERO,
|
||||
compressed,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
@@ -216,6 +217,7 @@ impl Vecs {
|
||||
indexes_to_8d_sma: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
path,
|
||||
"8d_sma",
|
||||
true,
|
||||
VERSION + Version::ZERO,
|
||||
compressed,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
@@ -223,6 +225,7 @@ impl Vecs {
|
||||
indexes_to_13d_sma: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
path,
|
||||
"13d_sma",
|
||||
true,
|
||||
VERSION + Version::ZERO,
|
||||
compressed,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
@@ -230,6 +233,7 @@ impl Vecs {
|
||||
indexes_to_21d_sma: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
path,
|
||||
"21d_sma",
|
||||
true,
|
||||
VERSION + Version::ZERO,
|
||||
compressed,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
@@ -237,6 +241,7 @@ impl Vecs {
|
||||
indexes_to_1m_sma: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
path,
|
||||
"1m_sma",
|
||||
true,
|
||||
VERSION + Version::ZERO,
|
||||
compressed,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
@@ -244,6 +249,7 @@ impl Vecs {
|
||||
indexes_to_34d_sma: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
path,
|
||||
"34d_sma",
|
||||
true,
|
||||
VERSION + Version::ZERO,
|
||||
compressed,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
@@ -251,6 +257,7 @@ impl Vecs {
|
||||
indexes_to_55d_sma: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
path,
|
||||
"55d_sma",
|
||||
true,
|
||||
VERSION + Version::ZERO,
|
||||
compressed,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
@@ -258,6 +265,7 @@ impl Vecs {
|
||||
indexes_to_89d_sma: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
path,
|
||||
"89d_sma",
|
||||
true,
|
||||
VERSION + Version::ZERO,
|
||||
compressed,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
@@ -265,6 +273,7 @@ impl Vecs {
|
||||
indexes_to_144d_sma: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
path,
|
||||
"144d_sma",
|
||||
true,
|
||||
VERSION + Version::ZERO,
|
||||
compressed,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
@@ -272,6 +281,7 @@ impl Vecs {
|
||||
indexes_to_1y_sma: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
path,
|
||||
"1y_sma",
|
||||
true,
|
||||
VERSION + Version::ZERO,
|
||||
compressed,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
@@ -279,6 +289,7 @@ impl Vecs {
|
||||
indexes_to_2y_sma: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
path,
|
||||
"2y_sma",
|
||||
true,
|
||||
VERSION + Version::ZERO,
|
||||
compressed,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
@@ -286,6 +297,7 @@ impl Vecs {
|
||||
indexes_to_200w_sma: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
path,
|
||||
"200w_sma",
|
||||
true,
|
||||
VERSION + Version::ZERO,
|
||||
compressed,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
@@ -293,6 +305,7 @@ impl Vecs {
|
||||
indexes_to_4y_sma: ComputedRatioVecsFromDateIndex::forced_import(
|
||||
path,
|
||||
"4y_sma",
|
||||
true,
|
||||
VERSION + Version::ZERO,
|
||||
compressed,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
@@ -1622,7 +1635,7 @@ impl Vecs {
|
||||
.into_iter()
|
||||
.for_each(|(vecs, sma)| {
|
||||
s.spawn(move || -> color_eyre::Result<()> {
|
||||
vecs.compute(
|
||||
vecs.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
fetched,
|
||||
|
||||
@@ -25,7 +25,7 @@ pub struct Vecs {
|
||||
pub mining: mining::Vecs,
|
||||
pub market: market::Vecs,
|
||||
pub transactions: transactions::Vecs,
|
||||
// pub utxos: utxos::Vecs,
|
||||
pub utxos: utxos::Vecs,
|
||||
pub fetched: Option<fetched::Vecs>,
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ impl Vecs {
|
||||
mining: mining::Vecs::forced_import(path, computation, compressed)?,
|
||||
constants: constants::Vecs::forced_import(path, computation, compressed)?,
|
||||
market: market::Vecs::forced_import(path, computation, compressed)?,
|
||||
// utxos: utxos::Vecs::forced_import(path, computation, compressed, fetched.as_ref())?,
|
||||
utxos: utxos::Vecs::forced_import(path, computation, compressed, fetched.as_ref())?,
|
||||
transactions: transactions::Vecs::forced_import(
|
||||
path,
|
||||
indexer,
|
||||
@@ -110,14 +110,14 @@ impl Vecs {
|
||||
)?;
|
||||
}
|
||||
|
||||
// self.utxos.compute(
|
||||
// indexer,
|
||||
// &self.indexes,
|
||||
// &self.transactions,
|
||||
// self.fetched.as_ref(),
|
||||
// &starting_indexes,
|
||||
// exit,
|
||||
// )?;
|
||||
self.utxos.compute(
|
||||
indexer,
|
||||
&self.indexes,
|
||||
&self.transactions,
|
||||
self.fetched.as_ref(),
|
||||
&starting_indexes,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -130,7 +130,7 @@ impl Vecs {
|
||||
self.mining.vecs(),
|
||||
self.market.vecs(),
|
||||
self.transactions.vecs(),
|
||||
// self.utxos.vecs(),
|
||||
self.utxos.vecs(),
|
||||
self.fetched.as_ref().map_or(vec![], |v| v.vecs()),
|
||||
]
|
||||
.into_iter()
|
||||
|
||||
@@ -12,7 +12,8 @@ use crate::{
|
||||
vecs::{
|
||||
Indexes, fetched,
|
||||
grouped::{
|
||||
ComputedValueVecsFromHeight, ComputedVecsFromHeight, StorableVecGeneatorOptions,
|
||||
ComputedRatioVecsFromDateIndex, ComputedValueVecsFromHeight, ComputedVecsFromHeight,
|
||||
StorableVecGeneatorOptions,
|
||||
},
|
||||
indexes,
|
||||
},
|
||||
@@ -30,6 +31,9 @@ pub struct Vecs {
|
||||
pub indexes_to_supply: ComputedValueVecsFromHeight,
|
||||
pub height_to_utxo_count: EagerVec<Height, StoredUsize>,
|
||||
pub indexes_to_utxo_count: ComputedVecsFromHeight<StoredUsize>,
|
||||
|
||||
pub indexes_to_realized_price: Option<ComputedVecsFromHeight<Dollars>>,
|
||||
pub indexes_to_realized_price_extra: Option<ComputedRatioVecsFromDateIndex>,
|
||||
}
|
||||
|
||||
impl Vecs {
|
||||
@@ -38,6 +42,7 @@ impl Vecs {
|
||||
cohort_name: Option<&str>,
|
||||
_computation: Computation,
|
||||
compressed: Compressed,
|
||||
version: Version,
|
||||
fetched: Option<&fetched::Vecs>,
|
||||
) -> color_eyre::Result<Self> {
|
||||
let compute_dollars = fetched.is_some();
|
||||
@@ -48,15 +53,20 @@ impl Vecs {
|
||||
|
||||
let suffix = |s: &str| cohort_name.map_or(s.to_string(), |name| format!("{name}_{s}"));
|
||||
|
||||
let mut state = CohortState::default();
|
||||
if compute_dollars {
|
||||
state.realized_cap = Some(Dollars::ZERO);
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
starting_height: Height::ZERO,
|
||||
state: CohortState::default(),
|
||||
state,
|
||||
|
||||
height_to_realized_cap: compute_dollars.then(|| {
|
||||
EagerVec::forced_import(
|
||||
path,
|
||||
&suffix("realized_cap"),
|
||||
VERSION + Version::ZERO,
|
||||
VERSION + Version::ZERO + version,
|
||||
compressed,
|
||||
)
|
||||
.unwrap()
|
||||
@@ -66,7 +76,7 @@ impl Vecs {
|
||||
path,
|
||||
&suffix("realized_cap"),
|
||||
false,
|
||||
VERSION + Version::ZERO,
|
||||
VERSION + Version::ZERO + version,
|
||||
compressed,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
)
|
||||
@@ -75,14 +85,14 @@ impl Vecs {
|
||||
height_to_supply: EagerVec::forced_import(
|
||||
path,
|
||||
&suffix("supply"),
|
||||
VERSION + Version::ZERO,
|
||||
VERSION + Version::ZERO + version,
|
||||
compressed,
|
||||
)?,
|
||||
indexes_to_supply: ComputedValueVecsFromHeight::forced_import(
|
||||
path,
|
||||
&suffix("supply"),
|
||||
false,
|
||||
VERSION + Version::ZERO,
|
||||
VERSION + Version::ZERO + version,
|
||||
compressed,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
compute_dollars,
|
||||
@@ -90,22 +100,45 @@ impl Vecs {
|
||||
height_to_utxo_count: EagerVec::forced_import(
|
||||
path,
|
||||
&suffix("utxo_count"),
|
||||
VERSION + Version::ZERO,
|
||||
VERSION + Version::ZERO + version,
|
||||
compressed,
|
||||
)?,
|
||||
indexes_to_utxo_count: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
&suffix("utxo_count"),
|
||||
false,
|
||||
VERSION + Version::ZERO,
|
||||
VERSION + Version::ZERO + version,
|
||||
compressed,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
)?,
|
||||
|
||||
indexes_to_realized_price: compute_dollars.then(|| {
|
||||
ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
&suffix("realized_price"),
|
||||
true,
|
||||
VERSION + Version::ZERO + version,
|
||||
compressed,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
indexes_to_realized_price_extra: compute_dollars.then(|| {
|
||||
ComputedRatioVecsFromDateIndex::forced_import(
|
||||
path,
|
||||
&suffix("realized_price"),
|
||||
false,
|
||||
VERSION + Version::ZERO,
|
||||
compressed,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn init(&mut self, starting_indexes: &Indexes) -> Height {
|
||||
self.starting_height = [
|
||||
pub fn starting_height(&self) -> Height {
|
||||
[
|
||||
self.height_to_supply.len(),
|
||||
self.height_to_utxo_count.len(),
|
||||
self.height_to_realized_cap
|
||||
@@ -116,29 +149,33 @@ impl Vecs {
|
||||
.map(Height::from)
|
||||
.min()
|
||||
.unwrap()
|
||||
.min(starting_indexes.height);
|
||||
}
|
||||
|
||||
if let Some(height_to_realized_cap) = self.height_to_realized_cap.as_mut() {
|
||||
if let Some(prev_height) = self.starting_height.checked_sub(Height::new(1)) {
|
||||
self.state.supply.value = self
|
||||
.height_to_supply
|
||||
.into_iter()
|
||||
.unwrap_get_inner(prev_height);
|
||||
self.state.supply.utxos = *self
|
||||
.height_to_utxo_count
|
||||
.into_iter()
|
||||
.unwrap_get_inner(prev_height);
|
||||
pub fn init(&mut self, starting_height: Height) {
|
||||
if starting_height > self.starting_height() {
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
self.starting_height = starting_height;
|
||||
|
||||
if let Some(prev_height) = starting_height.checked_sub(Height::new(1)) {
|
||||
self.state.supply.value = self
|
||||
.height_to_supply
|
||||
.into_iter()
|
||||
.unwrap_get_inner(prev_height);
|
||||
self.state.supply.utxos = *self
|
||||
.height_to_utxo_count
|
||||
.into_iter()
|
||||
.unwrap_get_inner(prev_height);
|
||||
|
||||
if let Some(height_to_realized_cap) = self.height_to_realized_cap.as_mut() {
|
||||
self.state.realized_cap = Some(
|
||||
height_to_realized_cap
|
||||
.into_iter()
|
||||
.unwrap_get_inner(prev_height),
|
||||
);
|
||||
} else {
|
||||
self.state.realized_cap = Some(Dollars::ZERO);
|
||||
}
|
||||
}
|
||||
|
||||
self.starting_height
|
||||
}
|
||||
|
||||
pub fn validate_computed_versions(&mut self, base_version: Version) -> Result<()> {
|
||||
@@ -157,10 +194,15 @@ impl Vecs {
|
||||
base_version + height_to_realized_cap.inner_version(),
|
||||
)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn forced_pushed_at(&mut self, height: Height, exit: &Exit) -> Result<()> {
|
||||
if self.starting_height > height {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
self.height_to_supply
|
||||
.forced_push_at(height, self.state.supply.value, exit)?;
|
||||
|
||||
@@ -173,7 +215,10 @@ impl Vecs {
|
||||
if let Some(height_to_realized_cap) = self.height_to_realized_cap.as_mut() {
|
||||
height_to_realized_cap.forced_push_at(
|
||||
height,
|
||||
self.state.realized_cap.unwrap(),
|
||||
self.state.realized_cap.unwrap_or_else(|| {
|
||||
dbg!(&self.state);
|
||||
panic!();
|
||||
}),
|
||||
exit,
|
||||
)?;
|
||||
}
|
||||
@@ -225,6 +270,41 @@ impl Vecs {
|
||||
)?;
|
||||
}
|
||||
|
||||
if let Some(indexes_to_realized_price) = self.indexes_to_realized_price.as_mut() {
|
||||
indexes_to_realized_price.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|vec, _, _, starting_indexes, exit| {
|
||||
vec.compute_divide(
|
||||
starting_indexes.height,
|
||||
self.height_to_realized_cap.as_ref().unwrap(),
|
||||
&**self.indexes_to_supply.bitcoin.height.as_ref().unwrap(),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
)?;
|
||||
}
|
||||
|
||||
if let Some(indexes_to_realized_price_extra) = self.indexes_to_realized_price_extra.as_mut()
|
||||
{
|
||||
indexes_to_realized_price_extra.compute_rest(
|
||||
indexer,
|
||||
indexes,
|
||||
fetched.as_ref().unwrap(),
|
||||
starting_indexes,
|
||||
exit,
|
||||
Some(
|
||||
self.indexes_to_realized_price
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.dateindex
|
||||
.unwrap_last(),
|
||||
),
|
||||
)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -242,6 +322,12 @@ impl Vecs {
|
||||
self.indexes_to_realized_cap
|
||||
.as_ref()
|
||||
.map_or(vec![], |v| v.vecs()),
|
||||
self.indexes_to_realized_price
|
||||
.as_ref()
|
||||
.map_or(vec![], |v| v.vecs()),
|
||||
self.indexes_to_realized_price_extra
|
||||
.as_ref()
|
||||
.map_or(vec![], |v| v.vecs()),
|
||||
]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
@@ -261,6 +347,9 @@ impl Clone for Vecs {
|
||||
indexes_to_supply: self.indexes_to_supply.clone(),
|
||||
height_to_utxo_count: self.height_to_utxo_count.clone(),
|
||||
indexes_to_utxo_count: self.indexes_to_utxo_count.clone(),
|
||||
|
||||
indexes_to_realized_price: self.indexes_to_realized_price.clone(),
|
||||
indexes_to_realized_price_extra: self.indexes_to_realized_price_extra.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user