mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-05-24 08:44:46 -07:00
global: snapshot
This commit is contained in:
@@ -6,7 +6,8 @@ use brk_reader::Reader;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{BlkPosition, Height, TxIndex, Version};
|
||||
use vecdb::{
|
||||
AnyStoredVec, AnyVec, Database, Exit, GenericStoredVec, PAGE_SIZE, PcoVec, TypedVecIterator,
|
||||
AnyStoredVec, AnyVec, Database, Exit, GenericStoredVec, Importable, PAGE_SIZE, PcoVec,
|
||||
TypedVecIterator,
|
||||
};
|
||||
|
||||
use super::Indexes;
|
||||
@@ -34,7 +35,7 @@ impl Vecs {
|
||||
};
|
||||
|
||||
this.db.retain_regions(
|
||||
this.iter_any_writable()
|
||||
this.iter_any_exportable()
|
||||
.flat_map(|v| v.region_names())
|
||||
.collect(),
|
||||
)?;
|
||||
|
||||
@@ -10,8 +10,8 @@ use brk_types::{
|
||||
TxVersion, Version, WeekIndex, Weight, YearIndex,
|
||||
};
|
||||
use vecdb::{
|
||||
Database, EagerVec, Exit, GenericStoredVec, IterableCloneableVec, IterableVec, LazyVecFrom1,
|
||||
LazyVecFrom2, PAGE_SIZE, TypedVecIterator, VecIndex, unlikely,
|
||||
Database, EagerVec, Exit, GenericStoredVec, Importable, IterableCloneableVec, IterableVec,
|
||||
LazyVecFrom1, LazyVecFrom2, PAGE_SIZE, PcoVec, TypedVecIterator, VecIndex, unlikely,
|
||||
};
|
||||
|
||||
use crate::grouped::{
|
||||
@@ -47,13 +47,13 @@ pub struct Vecs {
|
||||
pub yearindex_to_block_count_target: LazyVecFrom1<YearIndex, StoredU64, YearIndex, YearIndex>,
|
||||
pub decadeindex_to_block_count_target:
|
||||
LazyVecFrom1<DecadeIndex, StoredU64, DecadeIndex, DecadeIndex>,
|
||||
pub height_to_interval: EagerVec<Height, Timestamp>,
|
||||
pub height_to_24h_block_count: EagerVec<Height, StoredU32>,
|
||||
pub height_to_24h_coinbase_sum: EagerVec<Height, Sats>,
|
||||
pub height_to_24h_coinbase_usd_sum: EagerVec<Height, Dollars>,
|
||||
pub height_to_vbytes: EagerVec<Height, StoredU64>,
|
||||
pub difficultyepoch_to_timestamp: EagerVec<DifficultyEpoch, Timestamp>,
|
||||
pub halvingepoch_to_timestamp: EagerVec<HalvingEpoch, Timestamp>,
|
||||
pub height_to_interval: EagerVec<PcoVec<Height, Timestamp>>,
|
||||
pub height_to_24h_block_count: EagerVec<PcoVec<Height, StoredU32>>,
|
||||
pub height_to_24h_coinbase_sum: EagerVec<PcoVec<Height, Sats>>,
|
||||
pub height_to_24h_coinbase_usd_sum: EagerVec<PcoVec<Height, Dollars>>,
|
||||
pub height_to_vbytes: EagerVec<PcoVec<Height, StoredU64>>,
|
||||
pub difficultyepoch_to_timestamp: EagerVec<PcoVec<DifficultyEpoch, Timestamp>>,
|
||||
pub halvingepoch_to_timestamp: EagerVec<PcoVec<HalvingEpoch, Timestamp>>,
|
||||
pub timeindexes_to_timestamp: ComputedVecsFromDateIndex<Timestamp>,
|
||||
pub indexes_to_block_count: ComputedVecsFromHeight<StoredU32>,
|
||||
pub indexes_to_1w_block_count: ComputedVecsFromDateIndex<StoredU32>,
|
||||
@@ -71,11 +71,11 @@ pub struct Vecs {
|
||||
pub indexes_to_fee: ComputedValueVecsFromTxindex,
|
||||
pub indexes_to_fee_rate: ComputedVecsFromTxindex<FeeRate>,
|
||||
/// Value == 0 when Coinbase
|
||||
pub txindex_to_input_value: EagerVec<TxIndex, Sats>,
|
||||
pub txindex_to_input_value: EagerVec<PcoVec<TxIndex, Sats>>,
|
||||
pub indexes_to_sent: ComputedValueVecsFromHeight,
|
||||
// pub indexes_to_input_value: ComputedVecsFromTxindex<Sats>,
|
||||
pub indexes_to_opreturn_count: ComputedVecsFromHeight<StoredU64>,
|
||||
pub txindex_to_output_value: EagerVec<TxIndex, Sats>,
|
||||
pub txindex_to_output_value: EagerVec<PcoVec<TxIndex, Sats>>,
|
||||
// pub indexes_to_output_value: ComputedVecsFromTxindex<Sats>,
|
||||
pub indexes_to_p2a_count: ComputedVecsFromHeight<StoredU64>,
|
||||
pub indexes_to_p2ms_count: ComputedVecsFromHeight<StoredU64>,
|
||||
@@ -95,17 +95,17 @@ pub struct Vecs {
|
||||
pub indexes_to_tx_vsize: ComputedVecsFromTxindex<StoredU64>,
|
||||
pub indexes_to_tx_weight: ComputedVecsFromTxindex<Weight>,
|
||||
pub indexes_to_unknownoutput_count: ComputedVecsFromHeight<StoredU64>,
|
||||
pub txinindex_to_value: EagerVec<TxInIndex, Sats>,
|
||||
pub txinindex_to_value: EagerVec<PcoVec<TxInIndex, Sats>>,
|
||||
pub indexes_to_input_count: ComputedVecsFromTxindex<StoredU64>,
|
||||
pub txindex_to_is_coinbase: LazyVecFrom2<TxIndex, StoredBool, TxIndex, Height, Height, TxIndex>,
|
||||
pub indexes_to_output_count: ComputedVecsFromTxindex<StoredU64>,
|
||||
pub txindex_to_vsize: LazyVecFrom1<TxIndex, StoredU64, TxIndex, Weight>,
|
||||
pub txindex_to_weight: LazyVecFrom2<TxIndex, Weight, TxIndex, StoredU32, TxIndex, StoredU32>,
|
||||
pub txindex_to_fee: EagerVec<TxIndex, Sats>,
|
||||
pub txindex_to_fee_rate: EagerVec<TxIndex, FeeRate>,
|
||||
pub txindex_to_fee: EagerVec<PcoVec<TxIndex, Sats>>,
|
||||
pub txindex_to_fee_rate: EagerVec<PcoVec<TxIndex, FeeRate>>,
|
||||
pub indexes_to_exact_utxo_count: ComputedVecsFromHeight<StoredU64>,
|
||||
pub dateindex_to_fee_dominance: EagerVec<DateIndex, StoredF32>,
|
||||
pub dateindex_to_subsidy_dominance: EagerVec<DateIndex, StoredF32>,
|
||||
pub dateindex_to_fee_dominance: EagerVec<PcoVec<DateIndex, StoredF32>>,
|
||||
pub dateindex_to_subsidy_dominance: EagerVec<PcoVec<DateIndex, StoredF32>>,
|
||||
pub indexes_to_subsidy_usd_1y_sma: Option<ComputedVecsFromDateIndex<Dollars>>,
|
||||
pub indexes_to_puell_multiple: Option<ComputedVecsFromDateIndex<StoredF32>>,
|
||||
pub indexes_to_hash_rate: ComputedVecsFromHeight<StoredF64>,
|
||||
@@ -155,8 +155,8 @@ impl Vecs {
|
||||
|
||||
let compute_dollars = price.is_some();
|
||||
|
||||
let txinindex_to_value: EagerVec<TxInIndex, Sats> =
|
||||
EagerVec::forced_import_compressed(&db, "value", version + Version::ZERO)?;
|
||||
let txinindex_to_value: EagerVec<PcoVec<TxInIndex, Sats>> =
|
||||
EagerVec::forced_import(&db, "value", version + Version::ZERO)?;
|
||||
|
||||
let txindex_to_weight = LazyVecFrom2::init(
|
||||
"weight",
|
||||
@@ -201,16 +201,15 @@ impl Vecs {
|
||||
);
|
||||
|
||||
let txindex_to_input_value =
|
||||
EagerVec::forced_import_compressed(&db, "input_value", version + Version::ZERO)?;
|
||||
EagerVec::forced_import(&db, "input_value", version + Version::ZERO)?;
|
||||
|
||||
let txindex_to_output_value =
|
||||
EagerVec::forced_import_compressed(&db, "output_value", version + Version::ZERO)?;
|
||||
EagerVec::forced_import(&db, "output_value", version + Version::ZERO)?;
|
||||
|
||||
let txindex_to_fee =
|
||||
EagerVec::forced_import_compressed(&db, "fee", version + Version::ZERO)?;
|
||||
let txindex_to_fee = EagerVec::forced_import(&db, "fee", version + Version::ZERO)?;
|
||||
|
||||
let txindex_to_fee_rate =
|
||||
EagerVec::forced_import_compressed(&db, "fee_rate", version + Version::ZERO)?;
|
||||
EagerVec::forced_import(&db, "fee_rate", version + Version::ZERO)?;
|
||||
|
||||
let dateindex_to_block_count_target = LazyVecFrom1::init(
|
||||
"block_count_target",
|
||||
@@ -263,11 +262,7 @@ impl Vecs {
|
||||
semesterindex_to_block_count_target,
|
||||
yearindex_to_block_count_target,
|
||||
decadeindex_to_block_count_target,
|
||||
height_to_interval: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"interval",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_interval: EagerVec::forced_import(&db, "interval", version + Version::ZERO)?,
|
||||
timeindexes_to_timestamp: ComputedVecsFromDateIndex::forced_import(
|
||||
&db,
|
||||
"timestamp",
|
||||
@@ -345,22 +340,18 @@ impl Vecs {
|
||||
.add_percentiles()
|
||||
.add_cumulative(),
|
||||
)?,
|
||||
height_to_vbytes: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"vbytes",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_24h_block_count: EagerVec::forced_import_compressed(
|
||||
height_to_vbytes: EagerVec::forced_import(&db, "vbytes", version + Version::ZERO)?,
|
||||
height_to_24h_block_count: EagerVec::forced_import(
|
||||
&db,
|
||||
"24h_block_count",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_24h_coinbase_sum: EagerVec::forced_import_compressed(
|
||||
height_to_24h_coinbase_sum: EagerVec::forced_import(
|
||||
&db,
|
||||
"24h_coinbase_sum",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_24h_coinbase_usd_sum: EagerVec::forced_import_compressed(
|
||||
height_to_24h_coinbase_usd_sum: EagerVec::forced_import(
|
||||
&db,
|
||||
"24h_coinbase_usd_sum",
|
||||
version + Version::ZERO,
|
||||
@@ -378,23 +369,23 @@ impl Vecs {
|
||||
.add_percentiles()
|
||||
.add_cumulative(),
|
||||
)?,
|
||||
difficultyepoch_to_timestamp: EagerVec::forced_import_compressed(
|
||||
difficultyepoch_to_timestamp: EagerVec::forced_import(
|
||||
&db,
|
||||
"timestamp",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
halvingepoch_to_timestamp: EagerVec::forced_import_compressed(
|
||||
halvingepoch_to_timestamp: EagerVec::forced_import(
|
||||
&db,
|
||||
"timestamp",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
|
||||
dateindex_to_fee_dominance: EagerVec::forced_import_compressed(
|
||||
dateindex_to_fee_dominance: EagerVec::forced_import(
|
||||
&db,
|
||||
"fee_dominance",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
dateindex_to_subsidy_dominance: EagerVec::forced_import_compressed(
|
||||
dateindex_to_subsidy_dominance: EagerVec::forced_import(
|
||||
&db,
|
||||
"subsidy_dominance",
|
||||
version + Version::ZERO,
|
||||
@@ -1022,7 +1013,7 @@ impl Vecs {
|
||||
};
|
||||
|
||||
this.db.retain_regions(
|
||||
this.iter_any_writable()
|
||||
this.iter_any_exportable()
|
||||
.flat_map(|v| v.region_names())
|
||||
.collect(),
|
||||
)?;
|
||||
|
||||
@@ -279,7 +279,7 @@ impl Vecs {
|
||||
};
|
||||
|
||||
this.db.retain_regions(
|
||||
this.iter_any_writable()
|
||||
this.iter_any_exportable()
|
||||
.flat_map(|v| v.region_names())
|
||||
.collect(),
|
||||
)?;
|
||||
|
||||
@@ -162,7 +162,7 @@ impl Vecs {
|
||||
};
|
||||
|
||||
this.db.retain_regions(
|
||||
this.iter_any_writable()
|
||||
this.iter_any_exportable()
|
||||
.flat_map(|v| v.region_names())
|
||||
.collect(),
|
||||
)?;
|
||||
|
||||
@@ -6,8 +6,8 @@ use brk_indexer::Indexer;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{DateIndex, Height, OHLCCents, Version};
|
||||
use vecdb::{
|
||||
AnyStoredVec, AnyVec, Database, Exit, GenericStoredVec, IterableVec, PAGE_SIZE, RawVec,
|
||||
TypedVecIterator, VecIndex,
|
||||
AnyStoredVec, AnyVec, BytesVec, Database, Exit, GenericStoredVec, Importable, IterableVec,
|
||||
PAGE_SIZE, TypedVecIterator, VecIndex,
|
||||
};
|
||||
|
||||
use super::{Indexes, indexes};
|
||||
@@ -17,8 +17,8 @@ pub struct Vecs {
|
||||
db: Database,
|
||||
fetcher: Fetcher,
|
||||
|
||||
pub dateindex_to_price_ohlc_in_cents: RawVec<DateIndex, OHLCCents>,
|
||||
pub height_to_price_ohlc_in_cents: RawVec<Height, OHLCCents>,
|
||||
pub dateindex_to_price_ohlc_in_cents: BytesVec<DateIndex, OHLCCents>,
|
||||
pub height_to_price_ohlc_in_cents: BytesVec<Height, OHLCCents>,
|
||||
}
|
||||
|
||||
impl Vecs {
|
||||
@@ -29,12 +29,12 @@ impl Vecs {
|
||||
let this = Self {
|
||||
fetcher,
|
||||
|
||||
dateindex_to_price_ohlc_in_cents: RawVec::forced_import(
|
||||
dateindex_to_price_ohlc_in_cents: BytesVec::forced_import(
|
||||
&db,
|
||||
"price_ohlc_in_cents",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_price_ohlc_in_cents: RawVec::forced_import(
|
||||
height_to_price_ohlc_in_cents: BytesVec::forced_import(
|
||||
&db,
|
||||
"price_ohlc_in_cents",
|
||||
version + Version::ZERO,
|
||||
@@ -44,7 +44,7 @@ impl Vecs {
|
||||
};
|
||||
|
||||
this.db.retain_regions(
|
||||
this.iter_any_writable()
|
||||
this.iter_any_exportable()
|
||||
.flat_map(|v| v.region_names())
|
||||
.collect(),
|
||||
)?;
|
||||
|
||||
@@ -2,8 +2,8 @@ use brk_error::{Error, Result};
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{CheckedSub, StoredU64, Version};
|
||||
use vecdb::{
|
||||
AnyStoredVec, AnyVec, Database, EagerVec, Exit, Format, GenericStoredVec, IterableVec,
|
||||
VecIndex, VecValue,
|
||||
AnyStoredVec, AnyVec, Database, EagerVec, Exit, GenericStoredVec, Importable, IterableVec,
|
||||
PcoVec, VecIndex, VecValue,
|
||||
};
|
||||
|
||||
use crate::utils::get_percentile;
|
||||
@@ -16,18 +16,18 @@ where
|
||||
I: VecIndex,
|
||||
T: ComputedVecValue,
|
||||
{
|
||||
pub first: Option<Box<EagerVec<I, T>>>,
|
||||
pub average: Option<Box<EagerVec<I, T>>>,
|
||||
pub sum: Option<Box<EagerVec<I, T>>>,
|
||||
pub max: Option<Box<EagerVec<I, T>>>,
|
||||
pub pct90: Option<Box<EagerVec<I, T>>>,
|
||||
pub pct75: Option<Box<EagerVec<I, T>>>,
|
||||
pub median: Option<Box<EagerVec<I, T>>>,
|
||||
pub pct25: Option<Box<EagerVec<I, T>>>,
|
||||
pub pct10: Option<Box<EagerVec<I, T>>>,
|
||||
pub min: Option<Box<EagerVec<I, T>>>,
|
||||
pub last: Option<Box<EagerVec<I, T>>>,
|
||||
pub cumulative: Option<Box<EagerVec<I, T>>>,
|
||||
pub first: Option<Box<EagerVec<PcoVec<I, T>>>>,
|
||||
pub average: Option<Box<EagerVec<PcoVec<I, T>>>>,
|
||||
pub sum: Option<Box<EagerVec<PcoVec<I, T>>>>,
|
||||
pub max: Option<Box<EagerVec<PcoVec<I, T>>>>,
|
||||
pub pct90: Option<Box<EagerVec<PcoVec<I, T>>>>,
|
||||
pub pct75: Option<Box<EagerVec<PcoVec<I, T>>>>,
|
||||
pub median: Option<Box<EagerVec<PcoVec<I, T>>>>,
|
||||
pub pct25: Option<Box<EagerVec<PcoVec<I, T>>>>,
|
||||
pub pct10: Option<Box<EagerVec<PcoVec<I, T>>>>,
|
||||
pub min: Option<Box<EagerVec<PcoVec<I, T>>>>,
|
||||
pub last: Option<Box<EagerVec<PcoVec<I, T>>>>,
|
||||
pub cumulative: Option<Box<EagerVec<PcoVec<I, T>>>>,
|
||||
}
|
||||
|
||||
const VERSION: Version = Version::ZERO;
|
||||
@@ -37,20 +37,10 @@ where
|
||||
I: VecIndex,
|
||||
T: ComputedVecValue,
|
||||
{
|
||||
pub fn forced_import_compressed(
|
||||
db: &Database,
|
||||
name: &str,
|
||||
version: Version,
|
||||
options: VecBuilderOptions,
|
||||
) -> Result<Self> {
|
||||
Self::forced_import(db, name, version, Format::Compressed, options)
|
||||
}
|
||||
|
||||
pub fn forced_import(
|
||||
db: &Database,
|
||||
name: &str,
|
||||
version: Version,
|
||||
format: Format,
|
||||
options: VecBuilderOptions,
|
||||
) -> Result<Self> {
|
||||
let only_one_active = options.is_only_one_active();
|
||||
@@ -72,15 +62,12 @@ where
|
||||
db,
|
||||
&maybe_suffix("first"),
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap(),
|
||||
)
|
||||
}),
|
||||
last: options.last.then(|| {
|
||||
Box::new(
|
||||
EagerVec::forced_import(db, name, version + Version::ZERO, format).unwrap(),
|
||||
)
|
||||
Box::new(EagerVec::forced_import(db, name, version + Version::ZERO).unwrap())
|
||||
}),
|
||||
min: options.min.then(|| {
|
||||
Box::new(
|
||||
@@ -88,7 +75,6 @@ where
|
||||
db,
|
||||
&maybe_suffix("min"),
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap(),
|
||||
)
|
||||
@@ -99,7 +85,6 @@ where
|
||||
db,
|
||||
&maybe_suffix("max"),
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap(),
|
||||
)
|
||||
@@ -110,7 +95,6 @@ where
|
||||
db,
|
||||
&maybe_suffix("median"),
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap(),
|
||||
)
|
||||
@@ -121,7 +105,6 @@ where
|
||||
db,
|
||||
&maybe_suffix("avg"),
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap(),
|
||||
)
|
||||
@@ -136,7 +119,6 @@ where
|
||||
maybe_suffix("sum")
|
||||
}),
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap(),
|
||||
)
|
||||
@@ -147,7 +129,6 @@ where
|
||||
db,
|
||||
&suffix("cumulative"),
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap(),
|
||||
)
|
||||
@@ -158,7 +139,6 @@ where
|
||||
db,
|
||||
&maybe_suffix("pct90"),
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap(),
|
||||
)
|
||||
@@ -169,7 +149,6 @@ where
|
||||
db,
|
||||
&maybe_suffix("pct75"),
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap(),
|
||||
)
|
||||
@@ -180,7 +159,6 @@ where
|
||||
db,
|
||||
&maybe_suffix("pct25"),
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap(),
|
||||
)
|
||||
@@ -191,7 +169,6 @@ where
|
||||
db,
|
||||
&maybe_suffix("pct10"),
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap(),
|
||||
)
|
||||
@@ -535,51 +512,51 @@ where
|
||||
|
||||
pub fn starting_index(&self, max_from: I) -> I {
|
||||
max_from.min(I::from(
|
||||
self.iter_any_writable().map(|v| v.len()).min().unwrap(),
|
||||
self.iter_any_exportable().map(|v| v.len()).min().unwrap(),
|
||||
))
|
||||
}
|
||||
|
||||
pub fn unwrap_first(&self) -> &EagerVec<I, T> {
|
||||
pub fn unwrap_first(&self) -> &EagerVec<PcoVec<I, T>> {
|
||||
self.first.as_ref().unwrap()
|
||||
}
|
||||
#[allow(unused)]
|
||||
pub fn unwrap_average(&self) -> &EagerVec<I, T> {
|
||||
pub fn unwrap_average(&self) -> &EagerVec<PcoVec<I, T>> {
|
||||
self.average.as_ref().unwrap()
|
||||
}
|
||||
pub fn unwrap_sum(&self) -> &EagerVec<I, T> {
|
||||
pub fn unwrap_sum(&self) -> &EagerVec<PcoVec<I, T>> {
|
||||
self.sum.as_ref().unwrap()
|
||||
}
|
||||
pub fn unwrap_max(&self) -> &EagerVec<I, T> {
|
||||
pub fn unwrap_max(&self) -> &EagerVec<PcoVec<I, T>> {
|
||||
self.max.as_ref().unwrap()
|
||||
}
|
||||
#[allow(unused)]
|
||||
pub fn unwrap_pct90(&self) -> &EagerVec<I, T> {
|
||||
pub fn unwrap_pct90(&self) -> &EagerVec<PcoVec<I, T>> {
|
||||
self.pct90.as_ref().unwrap()
|
||||
}
|
||||
#[allow(unused)]
|
||||
pub fn unwrap_pct75(&self) -> &EagerVec<I, T> {
|
||||
pub fn unwrap_pct75(&self) -> &EagerVec<PcoVec<I, T>> {
|
||||
self.pct75.as_ref().unwrap()
|
||||
}
|
||||
#[allow(unused)]
|
||||
pub fn unwrap_median(&self) -> &EagerVec<I, T> {
|
||||
pub fn unwrap_median(&self) -> &EagerVec<PcoVec<I, T>> {
|
||||
self.median.as_ref().unwrap()
|
||||
}
|
||||
#[allow(unused)]
|
||||
pub fn unwrap_pct25(&self) -> &EagerVec<I, T> {
|
||||
pub fn unwrap_pct25(&self) -> &EagerVec<PcoVec<I, T>> {
|
||||
self.pct25.as_ref().unwrap()
|
||||
}
|
||||
#[allow(unused)]
|
||||
pub fn unwrap_pct10(&self) -> &EagerVec<I, T> {
|
||||
pub fn unwrap_pct10(&self) -> &EagerVec<PcoVec<I, T>> {
|
||||
self.pct10.as_ref().unwrap()
|
||||
}
|
||||
pub fn unwrap_min(&self) -> &EagerVec<I, T> {
|
||||
pub fn unwrap_min(&self) -> &EagerVec<PcoVec<I, T>> {
|
||||
self.min.as_ref().unwrap()
|
||||
}
|
||||
pub fn unwrap_last(&self) -> &EagerVec<I, T> {
|
||||
pub fn unwrap_last(&self) -> &EagerVec<PcoVec<I, T>> {
|
||||
self.last.as_ref().unwrap()
|
||||
}
|
||||
#[allow(unused)]
|
||||
pub fn unwrap_cumulative(&self) -> &EagerVec<I, T> {
|
||||
pub fn unwrap_cumulative(&self) -> &EagerVec<PcoVec<I, T>> {
|
||||
self.cumulative.as_ref().unwrap()
|
||||
}
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ where
|
||||
|
||||
pub fn starting_index(&self, max_from: I) -> I {
|
||||
max_from.min(I::from(
|
||||
self.iter_any_writable().map(|v| v.len()).min().unwrap(),
|
||||
self.iter_any_exportable().map(|v| v.len()).min().unwrap(),
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use std::ops::{Add, AddAssign, Div};
|
||||
|
||||
use serde::Serialize;
|
||||
use vecdb::{Formattable, PcoVecValue};
|
||||
|
||||
pub trait ComputedVecValue
|
||||
@@ -10,7 +11,8 @@ where
|
||||
+ Add<Output = Self>
|
||||
+ AddAssign
|
||||
+ Ord
|
||||
+ Formattable,
|
||||
+ Formattable
|
||||
+ Serialize,
|
||||
{
|
||||
}
|
||||
impl<T> ComputedVecValue for T where
|
||||
@@ -21,5 +23,6 @@ impl<T> ComputedVecValue for T where
|
||||
+ AddAssign
|
||||
+ Ord
|
||||
+ Formattable
|
||||
+ Serialize
|
||||
{
|
||||
}
|
||||
|
||||
@@ -4,7 +4,10 @@ use brk_traversable::Traversable;
|
||||
use brk_types::{
|
||||
DateIndex, DecadeIndex, MonthIndex, QuarterIndex, SemesterIndex, Version, WeekIndex, YearIndex,
|
||||
};
|
||||
use vecdb::{AnyWritableVec, Database, EagerVec, Exit, IterableCloneableVec, IterableVec};
|
||||
use vecdb::{
|
||||
AnyExportableVec, Database, EagerVec, Exit, Importable, IterableCloneableVec, IterableVec,
|
||||
PcoVec,
|
||||
};
|
||||
|
||||
use crate::{Indexes, grouped::LazyVecsBuilder, indexes};
|
||||
|
||||
@@ -15,7 +18,7 @@ pub struct ComputedVecsFromDateIndex<T>
|
||||
where
|
||||
T: ComputedVecValue + PartialOrd,
|
||||
{
|
||||
pub dateindex: Option<EagerVec<DateIndex, T>>,
|
||||
pub dateindex: Option<EagerVec<PcoVec<DateIndex, T>>>,
|
||||
pub dateindex_extra: EagerVecsBuilder<DateIndex, T>,
|
||||
pub weekindex: LazyVecsBuilder<WeekIndex, T, DateIndex, WeekIndex>,
|
||||
pub monthindex: LazyVecsBuilder<MonthIndex, T, DateIndex, MonthIndex>,
|
||||
@@ -40,11 +43,11 @@ where
|
||||
indexes: &indexes::Vecs,
|
||||
options: VecBuilderOptions,
|
||||
) -> Result<Self> {
|
||||
let dateindex = source.is_compute().then(|| {
|
||||
EagerVec::forced_import_compressed(db, name, version + VERSION + Version::ZERO).unwrap()
|
||||
});
|
||||
let dateindex = source
|
||||
.is_compute()
|
||||
.then(|| EagerVec::forced_import(db, name, version + VERSION + Version::ZERO).unwrap());
|
||||
|
||||
let dateindex_extra = EagerVecsBuilder::forced_import_compressed(
|
||||
let dateindex_extra = EagerVecsBuilder::forced_import(
|
||||
db,
|
||||
name,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -116,11 +119,11 @@ where
|
||||
mut compute: F,
|
||||
) -> Result<()>
|
||||
where
|
||||
F: FnMut(&mut EagerVec<DateIndex, T>) -> Result<()>,
|
||||
F: FnMut(&mut EagerVec<PcoVec<DateIndex, T>>) -> Result<()>,
|
||||
{
|
||||
compute(self.dateindex.as_mut().unwrap())?;
|
||||
|
||||
let dateindex: Option<&EagerVec<DateIndex, T>> = None;
|
||||
let dateindex: Option<&EagerVec<PcoVec<DateIndex, T>>> = None;
|
||||
self.compute_rest(starting_indexes, exit, dateindex)
|
||||
}
|
||||
|
||||
@@ -178,17 +181,17 @@ where
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn iter_any_writable(&self) -> impl Iterator<Item = &dyn AnyWritableVec> {
|
||||
let mut regular_iter: Box<dyn Iterator<Item = &dyn AnyWritableVec>> =
|
||||
Box::new(self.dateindex_extra.iter_any_writable());
|
||||
regular_iter = Box::new(regular_iter.chain(self.weekindex.iter_any_writable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.monthindex.iter_any_writable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.quarterindex.iter_any_writable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.semesterindex.iter_any_writable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.yearindex.iter_any_writable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.decadeindex.iter_any_writable()));
|
||||
fn iter_any_exportable(&self) -> impl Iterator<Item = &dyn AnyExportableVec> {
|
||||
let mut regular_iter: Box<dyn Iterator<Item = &dyn AnyExportableVec>> =
|
||||
Box::new(self.dateindex_extra.iter_any_exportable());
|
||||
regular_iter = Box::new(regular_iter.chain(self.weekindex.iter_any_exportable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.monthindex.iter_any_exportable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.quarterindex.iter_any_exportable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.semesterindex.iter_any_exportable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.yearindex.iter_any_exportable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.decadeindex.iter_any_exportable()));
|
||||
if let Some(ref x) = self.dateindex {
|
||||
regular_iter = Box::new(regular_iter.chain(x.iter_any_writable()));
|
||||
regular_iter = Box::new(regular_iter.chain(x.iter_any_exportable()));
|
||||
}
|
||||
regular_iter
|
||||
}
|
||||
|
||||
@@ -5,7 +5,10 @@ use brk_types::{
|
||||
DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, SemesterIndex,
|
||||
Version, WeekIndex, YearIndex,
|
||||
};
|
||||
use vecdb::{AnyWritableVec, Database, EagerVec, Exit, IterableCloneableVec, IterableVec};
|
||||
use vecdb::{
|
||||
AnyExportableVec, Database, EagerVec, Exit, Importable, IterableCloneableVec, IterableVec,
|
||||
PcoVec,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
Indexes,
|
||||
@@ -20,7 +23,7 @@ pub struct ComputedVecsFromHeight<T>
|
||||
where
|
||||
T: ComputedVecValue + PartialOrd,
|
||||
{
|
||||
pub height: Option<EagerVec<Height, T>>,
|
||||
pub height: Option<EagerVec<PcoVec<Height, T>>>,
|
||||
pub height_extra: EagerVecsBuilder<Height, T>,
|
||||
pub dateindex: EagerVecsBuilder<DateIndex, T>,
|
||||
pub weekindex: LazyVecsBuilder<WeekIndex, T, DateIndex, WeekIndex>,
|
||||
@@ -49,23 +52,19 @@ where
|
||||
indexes: &indexes::Vecs,
|
||||
options: VecBuilderOptions,
|
||||
) -> Result<Self> {
|
||||
let height = source.is_compute().then(|| {
|
||||
EagerVec::forced_import_compressed(db, name, version + VERSION + Version::ZERO).unwrap()
|
||||
});
|
||||
let height = source
|
||||
.is_compute()
|
||||
.then(|| EagerVec::forced_import(db, name, version + VERSION + Version::ZERO).unwrap());
|
||||
|
||||
let height_extra = EagerVecsBuilder::forced_import_compressed(
|
||||
let height_extra = EagerVecsBuilder::forced_import(
|
||||
db,
|
||||
name,
|
||||
version + VERSION + Version::ZERO,
|
||||
options.copy_self_extra(),
|
||||
)?;
|
||||
|
||||
let dateindex = EagerVecsBuilder::forced_import_compressed(
|
||||
db,
|
||||
name,
|
||||
version + VERSION + Version::ZERO,
|
||||
options,
|
||||
)?;
|
||||
let dateindex =
|
||||
EagerVecsBuilder::forced_import(db, name, version + VERSION + Version::ZERO, options)?;
|
||||
|
||||
let options = options.remove_percentiles();
|
||||
|
||||
@@ -122,7 +121,7 @@ where
|
||||
height,
|
||||
height_extra,
|
||||
dateindex,
|
||||
difficultyepoch: EagerVecsBuilder::forced_import_compressed(
|
||||
difficultyepoch: EagerVecsBuilder::forced_import(
|
||||
db,
|
||||
name,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -139,11 +138,11 @@ where
|
||||
mut compute: F,
|
||||
) -> Result<()>
|
||||
where
|
||||
F: FnMut(&mut EagerVec<Height, T>) -> Result<()>,
|
||||
F: FnMut(&mut EagerVec<PcoVec<Height, T>>) -> Result<()>,
|
||||
{
|
||||
compute(self.height.as_mut().unwrap())?;
|
||||
|
||||
let height: Option<&EagerVec<Height, T>> = None;
|
||||
let height: Option<&EagerVec<PcoVec<Height, T>>> = None;
|
||||
self.compute_rest(indexes, starting_indexes, exit, height)
|
||||
}
|
||||
|
||||
@@ -239,19 +238,19 @@ where
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn iter_any_writable(&self) -> impl Iterator<Item = &dyn AnyWritableVec> {
|
||||
let mut regular_iter: Box<dyn Iterator<Item = &dyn AnyWritableVec>> =
|
||||
Box::new(self.height_extra.iter_any_writable());
|
||||
regular_iter = Box::new(regular_iter.chain(self.dateindex.iter_any_writable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.weekindex.iter_any_writable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.difficultyepoch.iter_any_writable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.monthindex.iter_any_writable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.quarterindex.iter_any_writable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.semesterindex.iter_any_writable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.yearindex.iter_any_writable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.decadeindex.iter_any_writable()));
|
||||
fn iter_any_exportable(&self) -> impl Iterator<Item = &dyn AnyExportableVec> {
|
||||
let mut regular_iter: Box<dyn Iterator<Item = &dyn AnyExportableVec>> =
|
||||
Box::new(self.height_extra.iter_any_exportable());
|
||||
regular_iter = Box::new(regular_iter.chain(self.dateindex.iter_any_exportable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.weekindex.iter_any_exportable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.difficultyepoch.iter_any_exportable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.monthindex.iter_any_exportable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.quarterindex.iter_any_exportable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.semesterindex.iter_any_exportable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.yearindex.iter_any_exportable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.decadeindex.iter_any_exportable()));
|
||||
if let Some(ref x) = self.height {
|
||||
regular_iter = Box::new(regular_iter.chain(x.iter_any_writable()));
|
||||
regular_iter = Box::new(regular_iter.chain(x.iter_any_exportable()));
|
||||
}
|
||||
regular_iter
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use brk_error::Result;
|
||||
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{DifficultyEpoch, Height, Version};
|
||||
use vecdb::{AnyWritableVec, Database, EagerVec, Exit};
|
||||
use vecdb::{AnyExportableVec, Database, EagerVec, Exit, Importable, PcoVec};
|
||||
|
||||
use crate::{Indexes, indexes};
|
||||
|
||||
@@ -13,7 +13,7 @@ pub struct ComputedVecsFromHeightStrict<T>
|
||||
where
|
||||
T: ComputedVecValue + PartialOrd,
|
||||
{
|
||||
pub height: EagerVec<Height, T>,
|
||||
pub height: EagerVec<PcoVec<Height, T>>,
|
||||
pub height_extra: EagerVecsBuilder<Height, T>,
|
||||
pub difficultyepoch: EagerVecsBuilder<DifficultyEpoch, T>,
|
||||
// TODO: pub halvingepoch: StorableVecGeneator<Halvingepoch, T>,
|
||||
@@ -32,10 +32,9 @@ where
|
||||
version: Version,
|
||||
options: VecBuilderOptions,
|
||||
) -> Result<Self> {
|
||||
let height =
|
||||
EagerVec::forced_import_compressed(db, name, version + VERSION + Version::ZERO)?;
|
||||
let height = EagerVec::forced_import(db, name, version + VERSION + Version::ZERO)?;
|
||||
|
||||
let height_extra = EagerVecsBuilder::forced_import_compressed(
|
||||
let height_extra = EagerVecsBuilder::forced_import(
|
||||
db,
|
||||
name,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -47,7 +46,7 @@ where
|
||||
Ok(Self {
|
||||
height,
|
||||
height_extra,
|
||||
difficultyepoch: EagerVecsBuilder::forced_import_compressed(
|
||||
difficultyepoch: EagerVecsBuilder::forced_import(
|
||||
db,
|
||||
name,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -65,7 +64,7 @@ where
|
||||
mut compute: F,
|
||||
) -> Result<()>
|
||||
where
|
||||
F: FnMut(&mut EagerVec<Height, T>) -> Result<()>,
|
||||
F: FnMut(&mut EagerVec<PcoVec<Height, T>>) -> Result<()>,
|
||||
{
|
||||
compute(&mut self.height)?;
|
||||
|
||||
@@ -111,11 +110,11 @@ where
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn iter_any_writable(&self) -> impl Iterator<Item = &dyn AnyWritableVec> {
|
||||
let mut regular_iter: Box<dyn Iterator<Item = &dyn AnyWritableVec>> =
|
||||
Box::new(self.height.iter_any_writable());
|
||||
regular_iter = Box::new(regular_iter.chain(self.height_extra.iter_any_writable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.difficultyepoch.iter_any_writable()));
|
||||
fn iter_any_exportable(&self) -> impl Iterator<Item = &dyn AnyExportableVec> {
|
||||
let mut regular_iter: Box<dyn Iterator<Item = &dyn AnyExportableVec>> =
|
||||
Box::new(self.height.iter_any_exportable());
|
||||
regular_iter = Box::new(regular_iter.chain(self.height_extra.iter_any_exportable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.difficultyepoch.iter_any_exportable()));
|
||||
regular_iter
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ use brk_types::{
|
||||
Sats, SemesterIndex, TxIndex, Version, WeekIndex, YearIndex,
|
||||
};
|
||||
use vecdb::{
|
||||
AnyVec, AnyWritableVec, CollectableVec, Database, EagerVec, Exit, GenericStoredVec,
|
||||
IterableCloneableVec, TypedVecIterator, VecIndex,
|
||||
AnyExportableVec, AnyVec, CollectableVec, Database, EagerVec, Exit, GenericStoredVec,
|
||||
Importable, IterableCloneableVec, PcoVec, TypedVecIterator, VecIndex,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@@ -23,7 +23,7 @@ pub struct ComputedVecsFromTxindex<T>
|
||||
where
|
||||
T: ComputedVecValue + PartialOrd,
|
||||
{
|
||||
pub txindex: Option<Box<EagerVec<TxIndex, T>>>,
|
||||
pub txindex: Option<Box<EagerVec<PcoVec<TxIndex, T>>>>,
|
||||
pub height: EagerVecsBuilder<Height, T>,
|
||||
pub dateindex: EagerVecsBuilder<DateIndex, T>,
|
||||
pub weekindex: LazyVecsBuilder<WeekIndex, T, DateIndex, WeekIndex>,
|
||||
@@ -53,27 +53,16 @@ where
|
||||
options: VecBuilderOptions,
|
||||
) -> Result<Self> {
|
||||
let txindex = source.is_compute().then(|| {
|
||||
Box::new(
|
||||
EagerVec::forced_import_compressed(db, name, version + VERSION + Version::ZERO)
|
||||
.unwrap(),
|
||||
)
|
||||
Box::new(EagerVec::forced_import(db, name, version + VERSION + Version::ZERO).unwrap())
|
||||
});
|
||||
|
||||
let height = EagerVecsBuilder::forced_import_compressed(
|
||||
db,
|
||||
name,
|
||||
version + VERSION + Version::ZERO,
|
||||
options,
|
||||
)?;
|
||||
let height =
|
||||
EagerVecsBuilder::forced_import(db, name, version + VERSION + Version::ZERO, options)?;
|
||||
|
||||
let options = options.remove_percentiles();
|
||||
|
||||
let dateindex = EagerVecsBuilder::forced_import_compressed(
|
||||
db,
|
||||
name,
|
||||
version + VERSION + Version::ZERO,
|
||||
options,
|
||||
)?;
|
||||
let dateindex =
|
||||
EagerVecsBuilder::forced_import(db, name, version + VERSION + Version::ZERO, options)?;
|
||||
|
||||
Ok(Self {
|
||||
weekindex: LazyVecsBuilder::forced_import(
|
||||
@@ -128,7 +117,7 @@ where
|
||||
txindex,
|
||||
height,
|
||||
dateindex,
|
||||
difficultyepoch: EagerVecsBuilder::forced_import_compressed(
|
||||
difficultyepoch: EagerVecsBuilder::forced_import(
|
||||
db,
|
||||
name,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -149,7 +138,7 @@ where
|
||||
// ) -> Result<()>
|
||||
// where
|
||||
// F: FnMut(
|
||||
// &mut EagerVec<TxIndex, T>,
|
||||
// &mut EagerVec<PcoVec<TxIndex, T>>,
|
||||
// &Indexer,
|
||||
// &indexes::Vecs,
|
||||
// &Indexes,
|
||||
@@ -497,19 +486,19 @@ where
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn iter_any_writable(&self) -> impl Iterator<Item = &dyn AnyWritableVec> {
|
||||
let mut regular_iter: Box<dyn Iterator<Item = &dyn AnyWritableVec>> =
|
||||
Box::new(self.height.iter_any_writable());
|
||||
regular_iter = Box::new(regular_iter.chain(self.dateindex.iter_any_writable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.weekindex.iter_any_writable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.difficultyepoch.iter_any_writable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.monthindex.iter_any_writable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.quarterindex.iter_any_writable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.semesterindex.iter_any_writable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.yearindex.iter_any_writable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.decadeindex.iter_any_writable()));
|
||||
fn iter_any_exportable(&self) -> impl Iterator<Item = &dyn AnyExportableVec> {
|
||||
let mut regular_iter: Box<dyn Iterator<Item = &dyn AnyExportableVec>> =
|
||||
Box::new(self.height.iter_any_exportable());
|
||||
regular_iter = Box::new(regular_iter.chain(self.dateindex.iter_any_exportable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.weekindex.iter_any_exportable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.difficultyepoch.iter_any_exportable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.monthindex.iter_any_exportable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.quarterindex.iter_any_exportable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.semesterindex.iter_any_exportable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.yearindex.iter_any_exportable()));
|
||||
regular_iter = Box::new(regular_iter.chain(self.decadeindex.iter_any_exportable()));
|
||||
if let Some(ref x) = self.txindex {
|
||||
regular_iter = Box::new(regular_iter.chain(x.iter_any_writable()));
|
||||
regular_iter = Box::new(regular_iter.chain(x.iter_any_exportable()));
|
||||
}
|
||||
regular_iter
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Date, DateIndex, Dollars, StoredF32, Version};
|
||||
use vecdb::{
|
||||
use vecdb::{PcoVec,
|
||||
AnyStoredVec, AnyVec, CollectableVec, Database, EagerVec, Exit, GenericStoredVec, IterableVec,
|
||||
TypedVecIterator, VecIndex,
|
||||
};
|
||||
@@ -290,14 +290,14 @@ impl ComputedRatioVecsFromDateIndex {
|
||||
compute: F,
|
||||
) -> Result<()>
|
||||
where
|
||||
F: FnMut(&mut EagerVec<DateIndex, Dollars>) -> Result<()>,
|
||||
F: FnMut(&mut EagerVec<PcoVec<DateIndex, Dollars>>) -> Result<()>,
|
||||
{
|
||||
self.price
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.compute_all(starting_indexes, exit, compute)?;
|
||||
|
||||
let date_to_price_opt: Option<&EagerVec<DateIndex, Dollars>> = None;
|
||||
let date_to_price_opt: Option<&EagerVec<PcoVec<DateIndex, Dollars>>> = None;
|
||||
self.compute_rest(price, starting_indexes, exit, date_to_price_opt)
|
||||
}
|
||||
|
||||
@@ -501,32 +501,32 @@ impl ComputedRatioVecsFromDateIndex {
|
||||
self.ratio_pct1.as_mut().unwrap().compute_rest(
|
||||
starting_indexes,
|
||||
exit,
|
||||
None as Option<&EagerVec<_, _>>,
|
||||
None as Option<&EagerVec<PcoVec<_, _>>>,
|
||||
)?;
|
||||
self.ratio_pct2.as_mut().unwrap().compute_rest(
|
||||
starting_indexes,
|
||||
exit,
|
||||
None as Option<&EagerVec<_, _>>,
|
||||
None as Option<&EagerVec<PcoVec<_, _>>>,
|
||||
)?;
|
||||
self.ratio_pct5.as_mut().unwrap().compute_rest(
|
||||
starting_indexes,
|
||||
exit,
|
||||
None as Option<&EagerVec<_, _>>,
|
||||
None as Option<&EagerVec<PcoVec<_, _>>>,
|
||||
)?;
|
||||
self.ratio_pct95.as_mut().unwrap().compute_rest(
|
||||
starting_indexes,
|
||||
exit,
|
||||
None as Option<&EagerVec<_, _>>,
|
||||
None as Option<&EagerVec<PcoVec<_, _>>>,
|
||||
)?;
|
||||
self.ratio_pct98.as_mut().unwrap().compute_rest(
|
||||
starting_indexes,
|
||||
exit,
|
||||
None as Option<&EagerVec<_, _>>,
|
||||
None as Option<&EagerVec<PcoVec<_, _>>>,
|
||||
)?;
|
||||
self.ratio_pct99.as_mut().unwrap().compute_rest(
|
||||
starting_indexes,
|
||||
exit,
|
||||
None as Option<&EagerVec<_, _>>,
|
||||
None as Option<&EagerVec<PcoVec<_, _>>>,
|
||||
)?;
|
||||
|
||||
let date_to_price = price_opt.unwrap_or_else(|| unsafe {
|
||||
@@ -610,7 +610,7 @@ impl ComputedRatioVecsFromDateIndex {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn mut_ratio_vecs(&mut self) -> Vec<&mut EagerVec<DateIndex, StoredF32>> {
|
||||
fn mut_ratio_vecs(&mut self) -> Vec<&mut EagerVec<PcoVec<DateIndex, StoredF32>>> {
|
||||
let mut vecs = Vec::with_capacity(6);
|
||||
if let Some(v) = self.ratio_pct1.as_mut() {
|
||||
vecs.push(v.dateindex.as_mut().unwrap());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Date, DateIndex, Dollars, StoredF32, Version};
|
||||
use vecdb::{
|
||||
use vecdb::{PcoVec,
|
||||
AnyStoredVec, AnyVec, BoxedVecIterator, CollectableVec, Database, EagerVec, Exit,
|
||||
GenericStoredVec, IterableVec, VecIndex,
|
||||
};
|
||||
@@ -440,7 +440,7 @@ impl ComputedStandardDeviationVecsFromDateIndex {
|
||||
Ok(())
|
||||
})?;
|
||||
|
||||
let sma_opt: Option<&EagerVec<DateIndex, StoredF32>> = None;
|
||||
let sma_opt: Option<&EagerVec<PcoVec<DateIndex, StoredF32>>> = None;
|
||||
self.compute_rest(starting_indexes, exit, sma_opt, source, price_opt)
|
||||
}
|
||||
|
||||
@@ -615,7 +615,7 @@ impl ComputedStandardDeviationVecsFromDateIndex {
|
||||
.try_for_each(|v| v.safe_flush(exit))?;
|
||||
|
||||
self.mut_stateful_computed().try_for_each(|v| {
|
||||
v.compute_rest(starting_indexes, exit, None as Option<&EagerVec<_, _>>)
|
||||
v.compute_rest(starting_indexes, exit, None as Option<&EagerVec<PcoVec<_, _>>>)
|
||||
})?;
|
||||
|
||||
if let Some(zscore) = self.zscore.as_mut() {
|
||||
@@ -805,7 +805,7 @@ impl ComputedStandardDeviationVecsFromDateIndex {
|
||||
|
||||
fn mut_stateful_date_vecs(
|
||||
&mut self,
|
||||
) -> impl Iterator<Item = &mut EagerVec<DateIndex, StoredF32>> {
|
||||
) -> impl Iterator<Item = &mut EagerVec<PcoVec<DateIndex, StoredF32>>> {
|
||||
self.mut_stateful_computed()
|
||||
.map(|c| c.dateindex.as_mut().unwrap())
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Bitcoin, DateIndex, Dollars, Sats, Version};
|
||||
use vecdb::{CollectableVec, Database, EagerVec, Exit, StoredVec};
|
||||
use vecdb::{CollectableVec, Database, EagerVec, Exit, PcoVec};
|
||||
|
||||
use crate::{
|
||||
Indexes,
|
||||
@@ -71,11 +71,11 @@ impl ComputedValueVecsFromDateIndex {
|
||||
mut compute: F,
|
||||
) -> Result<()>
|
||||
where
|
||||
F: FnMut(&mut EagerVec<DateIndex, Sats>) -> Result<()>,
|
||||
F: FnMut(&mut EagerVec<PcoVec<DateIndex, Sats>>) -> Result<()>,
|
||||
{
|
||||
compute(self.sats.dateindex.as_mut().unwrap())?;
|
||||
|
||||
let dateindex: Option<&StoredVec<DateIndex, Sats>> = None;
|
||||
let dateindex: Option<&PcoVec<DateIndex, Sats>> = None;
|
||||
self.compute_rest(price, starting_indexes, exit, dateindex)?;
|
||||
|
||||
Ok(())
|
||||
@@ -96,7 +96,7 @@ impl ComputedValueVecsFromDateIndex {
|
||||
v.compute_from_sats(starting_indexes.dateindex, dateindex, exit)
|
||||
})?;
|
||||
} else {
|
||||
let dateindex: Option<&StoredVec<DateIndex, Sats>> = None;
|
||||
let dateindex: Option<&PcoVec<DateIndex, Sats>> = None;
|
||||
|
||||
self.sats.compute_rest(starting_indexes, exit, dateindex)?;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Bitcoin, Dollars, Height, Sats, Version};
|
||||
use vecdb::{CollectableVec, Database, EagerVec, Exit, StoredVec};
|
||||
use vecdb::{CollectableVec, Database, EagerVec, Exit, PcoVec};
|
||||
|
||||
use crate::{
|
||||
Indexes,
|
||||
@@ -72,11 +72,11 @@ impl ComputedValueVecsFromHeight {
|
||||
mut compute: F,
|
||||
) -> Result<()>
|
||||
where
|
||||
F: FnMut(&mut EagerVec<Height, Sats>) -> Result<()>,
|
||||
F: FnMut(&mut EagerVec<PcoVec<Height, Sats>>) -> Result<()>,
|
||||
{
|
||||
compute(self.sats.height.as_mut().unwrap())?;
|
||||
|
||||
let height: Option<&StoredVec<Height, Sats>> = None;
|
||||
let height: Option<&PcoVec<Height, Sats>> = None;
|
||||
self.compute_rest(indexes, price, starting_indexes, exit, height)?;
|
||||
|
||||
Ok(())
|
||||
@@ -99,7 +99,7 @@ impl ComputedValueVecsFromHeight {
|
||||
v.compute_from_sats(starting_indexes.height, height, exit)
|
||||
})?;
|
||||
} else {
|
||||
let height: Option<&StoredVec<Height, Sats>> = None;
|
||||
let height: Option<&PcoVec<Height, Sats>> = None;
|
||||
|
||||
self.sats
|
||||
.compute_rest(indexes, starting_indexes, exit, height)?;
|
||||
|
||||
@@ -3,7 +3,7 @@ use brk_indexer::Indexer;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Bitcoin, Close, Dollars, Height, Sats, TxIndex, Version};
|
||||
use vecdb::{
|
||||
CollectableVec, Database, Exit, IterableCloneableVec, LazyVecFrom1, LazyVecFrom3, StoredVec,
|
||||
CollectableVec, Database, Exit, IterableCloneableVec, LazyVecFrom1, LazyVecFrom3, PcoVec,
|
||||
VecIndex,
|
||||
};
|
||||
|
||||
@@ -122,7 +122,7 @@ impl ComputedValueVecsFromTxindex {
|
||||
// ) -> Result<()>
|
||||
// where
|
||||
// F: FnMut(
|
||||
// &mut EagerVec<TxIndex, Sats>,
|
||||
// &mut EagerVec<PcoVec<TxIndex, Sats>>,
|
||||
// &Indexer,
|
||||
// &indexes::Vecs,
|
||||
// &Indexes,
|
||||
@@ -137,7 +137,7 @@ impl ComputedValueVecsFromTxindex {
|
||||
// exit,
|
||||
// )?;
|
||||
|
||||
// let txindex: Option<&StoredVec<TxIndex, Sats>> = None;
|
||||
// let txindex: Option<&PcoVec<TxIndex, Sats>> = None;
|
||||
// self.compute_rest(
|
||||
// indexer,
|
||||
// indexes,
|
||||
@@ -163,7 +163,7 @@ impl ComputedValueVecsFromTxindex {
|
||||
self.sats
|
||||
.compute_rest(indexer, indexes, starting_indexes, exit, Some(txindex))?;
|
||||
} else {
|
||||
let txindex: Option<&StoredVec<TxIndex, Sats>> = None;
|
||||
let txindex: Option<&PcoVec<TxIndex, Sats>> = None;
|
||||
self.sats
|
||||
.compute_rest(indexer, indexes, starting_indexes, exit, txindex)?;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Bitcoin, Dollars, Height, Sats, Version};
|
||||
use vecdb::{CollectableVec, Database, EagerVec, Exit, Format, StoredVec};
|
||||
use vecdb::{CollectableVec, Database, EagerVec, Exit, Importable, PcoVec};
|
||||
|
||||
use crate::{
|
||||
Indexes,
|
||||
@@ -12,9 +12,9 @@ use crate::{
|
||||
|
||||
#[derive(Clone, Traversable)]
|
||||
pub struct ComputedHeightValueVecs {
|
||||
pub sats: Option<EagerVec<Height, Sats>>,
|
||||
pub bitcoin: EagerVec<Height, Bitcoin>,
|
||||
pub dollars: Option<EagerVec<Height, Dollars>>,
|
||||
pub sats: Option<EagerVec<PcoVec<Height, Sats>>>,
|
||||
pub bitcoin: EagerVec<PcoVec<Height, Bitcoin>>,
|
||||
pub dollars: Option<EagerVec<PcoVec<Height, Dollars>>>,
|
||||
}
|
||||
|
||||
const VERSION: Version = Version::ZERO;
|
||||
@@ -25,26 +25,22 @@ impl ComputedHeightValueVecs {
|
||||
name: &str,
|
||||
source: Source<Height, Sats>,
|
||||
version: Version,
|
||||
format: Format,
|
||||
compute_dollars: bool,
|
||||
) -> Result<Self> {
|
||||
Ok(Self {
|
||||
sats: source.is_compute().then(|| {
|
||||
EagerVec::forced_import(db, name, version + VERSION + Version::ZERO, format)
|
||||
.unwrap()
|
||||
EagerVec::forced_import(db, name, version + VERSION + Version::ZERO).unwrap()
|
||||
}),
|
||||
bitcoin: EagerVec::forced_import(
|
||||
db,
|
||||
&format!("{name}_btc"),
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
dollars: compute_dollars.then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&format!("{name}_usd"),
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
@@ -59,11 +55,11 @@ impl ComputedHeightValueVecs {
|
||||
mut compute: F,
|
||||
) -> Result<()>
|
||||
where
|
||||
F: FnMut(&mut EagerVec<Height, Sats>) -> Result<()>,
|
||||
F: FnMut(&mut EagerVec<PcoVec<Height, Sats>>) -> Result<()>,
|
||||
{
|
||||
compute(self.sats.as_mut().unwrap())?;
|
||||
|
||||
let height: Option<&StoredVec<Height, Sats>> = None;
|
||||
let height: Option<&PcoVec<Height, Sats>> = None;
|
||||
self.compute_rest(price, starting_indexes, exit, height)?;
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -13,8 +13,8 @@ use brk_types::{
|
||||
YearIndex,
|
||||
};
|
||||
use vecdb::{
|
||||
Database, EagerVec, Exit, GenericStoredVec, IterableCloneableVec, LazyVecFrom1, PAGE_SIZE,
|
||||
TypedVecIterator, unlikely,
|
||||
Database, EagerVec, Exit, GenericStoredVec, Importable, IterableCloneableVec, LazyVecFrom1,
|
||||
PAGE_SIZE, PcoVec, TypedVecIterator, unlikely,
|
||||
};
|
||||
|
||||
const VERSION: Version = Version::ZERO;
|
||||
@@ -23,36 +23,36 @@ const VERSION: Version = Version::ZERO;
|
||||
pub struct Vecs {
|
||||
db: Database,
|
||||
|
||||
pub dateindex_to_date: EagerVec<DateIndex, Date>,
|
||||
pub dateindex_to_dateindex: EagerVec<DateIndex, DateIndex>,
|
||||
pub dateindex_to_first_height: EagerVec<DateIndex, Height>,
|
||||
pub dateindex_to_height_count: EagerVec<DateIndex, StoredU64>,
|
||||
pub dateindex_to_monthindex: EagerVec<DateIndex, MonthIndex>,
|
||||
pub dateindex_to_weekindex: EagerVec<DateIndex, WeekIndex>,
|
||||
pub decadeindex_to_decadeindex: EagerVec<DecadeIndex, DecadeIndex>,
|
||||
pub decadeindex_to_first_yearindex: EagerVec<DecadeIndex, YearIndex>,
|
||||
pub decadeindex_to_yearindex_count: EagerVec<DecadeIndex, StoredU64>,
|
||||
pub difficultyepoch_to_difficultyepoch: EagerVec<DifficultyEpoch, DifficultyEpoch>,
|
||||
pub difficultyepoch_to_first_height: EagerVec<DifficultyEpoch, Height>,
|
||||
pub difficultyepoch_to_height_count: EagerVec<DifficultyEpoch, StoredU64>,
|
||||
pub dateindex_to_date: EagerVec<PcoVec<DateIndex, Date>>,
|
||||
pub dateindex_to_dateindex: EagerVec<PcoVec<DateIndex, DateIndex>>,
|
||||
pub dateindex_to_first_height: EagerVec<PcoVec<DateIndex, Height>>,
|
||||
pub dateindex_to_height_count: EagerVec<PcoVec<DateIndex, StoredU64>>,
|
||||
pub dateindex_to_monthindex: EagerVec<PcoVec<DateIndex, MonthIndex>>,
|
||||
pub dateindex_to_weekindex: EagerVec<PcoVec<DateIndex, WeekIndex>>,
|
||||
pub decadeindex_to_decadeindex: EagerVec<PcoVec<DecadeIndex, DecadeIndex>>,
|
||||
pub decadeindex_to_first_yearindex: EagerVec<PcoVec<DecadeIndex, YearIndex>>,
|
||||
pub decadeindex_to_yearindex_count: EagerVec<PcoVec<DecadeIndex, StoredU64>>,
|
||||
pub difficultyepoch_to_difficultyepoch: EagerVec<PcoVec<DifficultyEpoch, DifficultyEpoch>>,
|
||||
pub difficultyepoch_to_first_height: EagerVec<PcoVec<DifficultyEpoch, Height>>,
|
||||
pub difficultyepoch_to_height_count: EagerVec<PcoVec<DifficultyEpoch, StoredU64>>,
|
||||
pub emptyoutputindex_to_emptyoutputindex:
|
||||
LazyVecFrom1<EmptyOutputIndex, EmptyOutputIndex, EmptyOutputIndex, TxIndex>,
|
||||
pub halvingepoch_to_first_height: EagerVec<HalvingEpoch, Height>,
|
||||
pub halvingepoch_to_halvingepoch: EagerVec<HalvingEpoch, HalvingEpoch>,
|
||||
pub height_to_date: EagerVec<Height, Date>,
|
||||
pub height_to_date_fixed: EagerVec<Height, Date>,
|
||||
pub height_to_dateindex: EagerVec<Height, DateIndex>,
|
||||
pub height_to_difficultyepoch: EagerVec<Height, DifficultyEpoch>,
|
||||
pub height_to_halvingepoch: EagerVec<Height, HalvingEpoch>,
|
||||
pub height_to_height: EagerVec<Height, Height>,
|
||||
pub height_to_timestamp_fixed: EagerVec<Height, Timestamp>,
|
||||
pub height_to_txindex_count: EagerVec<Height, StoredU64>,
|
||||
pub monthindex_to_dateindex_count: EagerVec<MonthIndex, StoredU64>,
|
||||
pub monthindex_to_first_dateindex: EagerVec<MonthIndex, DateIndex>,
|
||||
pub monthindex_to_monthindex: EagerVec<MonthIndex, MonthIndex>,
|
||||
pub monthindex_to_quarterindex: EagerVec<MonthIndex, QuarterIndex>,
|
||||
pub monthindex_to_semesterindex: EagerVec<MonthIndex, SemesterIndex>,
|
||||
pub monthindex_to_yearindex: EagerVec<MonthIndex, YearIndex>,
|
||||
pub halvingepoch_to_first_height: EagerVec<PcoVec<HalvingEpoch, Height>>,
|
||||
pub halvingepoch_to_halvingepoch: EagerVec<PcoVec<HalvingEpoch, HalvingEpoch>>,
|
||||
pub height_to_date: EagerVec<PcoVec<Height, Date>>,
|
||||
pub height_to_date_fixed: EagerVec<PcoVec<Height, Date>>,
|
||||
pub height_to_dateindex: EagerVec<PcoVec<Height, DateIndex>>,
|
||||
pub height_to_difficultyepoch: EagerVec<PcoVec<Height, DifficultyEpoch>>,
|
||||
pub height_to_halvingepoch: EagerVec<PcoVec<Height, HalvingEpoch>>,
|
||||
pub height_to_height: EagerVec<PcoVec<Height, Height>>,
|
||||
pub height_to_timestamp_fixed: EagerVec<PcoVec<Height, Timestamp>>,
|
||||
pub height_to_txindex_count: EagerVec<PcoVec<Height, StoredU64>>,
|
||||
pub monthindex_to_dateindex_count: EagerVec<PcoVec<MonthIndex, StoredU64>>,
|
||||
pub monthindex_to_first_dateindex: EagerVec<PcoVec<MonthIndex, DateIndex>>,
|
||||
pub monthindex_to_monthindex: EagerVec<PcoVec<MonthIndex, MonthIndex>>,
|
||||
pub monthindex_to_quarterindex: EagerVec<PcoVec<MonthIndex, QuarterIndex>>,
|
||||
pub monthindex_to_semesterindex: EagerVec<PcoVec<MonthIndex, SemesterIndex>>,
|
||||
pub monthindex_to_yearindex: EagerVec<PcoVec<MonthIndex, YearIndex>>,
|
||||
pub opreturnindex_to_opreturnindex:
|
||||
LazyVecFrom1<OpReturnIndex, OpReturnIndex, OpReturnIndex, TxIndex>,
|
||||
pub p2aaddressindex_to_p2aaddressindex:
|
||||
@@ -73,27 +73,27 @@ pub struct Vecs {
|
||||
LazyVecFrom1<P2WPKHAddressIndex, P2WPKHAddressIndex, P2WPKHAddressIndex, P2WPKHBytes>,
|
||||
pub p2wshaddressindex_to_p2wshaddressindex:
|
||||
LazyVecFrom1<P2WSHAddressIndex, P2WSHAddressIndex, P2WSHAddressIndex, P2WSHBytes>,
|
||||
pub quarterindex_to_first_monthindex: EagerVec<QuarterIndex, MonthIndex>,
|
||||
pub quarterindex_to_monthindex_count: EagerVec<QuarterIndex, StoredU64>,
|
||||
pub quarterindex_to_quarterindex: EagerVec<QuarterIndex, QuarterIndex>,
|
||||
pub semesterindex_to_first_monthindex: EagerVec<SemesterIndex, MonthIndex>,
|
||||
pub semesterindex_to_monthindex_count: EagerVec<SemesterIndex, StoredU64>,
|
||||
pub semesterindex_to_semesterindex: EagerVec<SemesterIndex, SemesterIndex>,
|
||||
pub txindex_to_input_count: EagerVec<TxIndex, StoredU64>,
|
||||
pub txindex_to_output_count: EagerVec<TxIndex, StoredU64>,
|
||||
pub quarterindex_to_first_monthindex: EagerVec<PcoVec<QuarterIndex, MonthIndex>>,
|
||||
pub quarterindex_to_monthindex_count: EagerVec<PcoVec<QuarterIndex, StoredU64>>,
|
||||
pub quarterindex_to_quarterindex: EagerVec<PcoVec<QuarterIndex, QuarterIndex>>,
|
||||
pub semesterindex_to_first_monthindex: EagerVec<PcoVec<SemesterIndex, MonthIndex>>,
|
||||
pub semesterindex_to_monthindex_count: EagerVec<PcoVec<SemesterIndex, StoredU64>>,
|
||||
pub semesterindex_to_semesterindex: EagerVec<PcoVec<SemesterIndex, SemesterIndex>>,
|
||||
pub txindex_to_input_count: EagerVec<PcoVec<TxIndex, StoredU64>>,
|
||||
pub txindex_to_output_count: EagerVec<PcoVec<TxIndex, StoredU64>>,
|
||||
pub txindex_to_txindex: LazyVecFrom1<TxIndex, TxIndex, TxIndex, Txid>,
|
||||
pub txinindex_to_txinindex: LazyVecFrom1<TxInIndex, TxInIndex, TxInIndex, OutPoint>,
|
||||
pub txinindex_to_txoutindex: EagerVec<TxInIndex, TxOutIndex>,
|
||||
pub txinindex_to_txoutindex: EagerVec<PcoVec<TxInIndex, TxOutIndex>>,
|
||||
pub txoutindex_to_txoutindex: LazyVecFrom1<TxOutIndex, TxOutIndex, TxOutIndex, Sats>,
|
||||
pub unknownoutputindex_to_unknownoutputindex:
|
||||
LazyVecFrom1<UnknownOutputIndex, UnknownOutputIndex, UnknownOutputIndex, TxIndex>,
|
||||
pub weekindex_to_dateindex_count: EagerVec<WeekIndex, StoredU64>,
|
||||
pub weekindex_to_first_dateindex: EagerVec<WeekIndex, DateIndex>,
|
||||
pub weekindex_to_weekindex: EagerVec<WeekIndex, WeekIndex>,
|
||||
pub yearindex_to_decadeindex: EagerVec<YearIndex, DecadeIndex>,
|
||||
pub yearindex_to_first_monthindex: EagerVec<YearIndex, MonthIndex>,
|
||||
pub yearindex_to_monthindex_count: EagerVec<YearIndex, StoredU64>,
|
||||
pub yearindex_to_yearindex: EagerVec<YearIndex, YearIndex>,
|
||||
pub weekindex_to_dateindex_count: EagerVec<PcoVec<WeekIndex, StoredU64>>,
|
||||
pub weekindex_to_first_dateindex: EagerVec<PcoVec<WeekIndex, DateIndex>>,
|
||||
pub weekindex_to_weekindex: EagerVec<PcoVec<WeekIndex, WeekIndex>>,
|
||||
pub yearindex_to_decadeindex: EagerVec<PcoVec<YearIndex, DecadeIndex>>,
|
||||
pub yearindex_to_first_monthindex: EagerVec<PcoVec<YearIndex, MonthIndex>>,
|
||||
pub yearindex_to_monthindex_count: EagerVec<PcoVec<YearIndex, StoredU64>>,
|
||||
pub yearindex_to_yearindex: EagerVec<PcoVec<YearIndex, YearIndex>>,
|
||||
}
|
||||
|
||||
impl Vecs {
|
||||
@@ -108,11 +108,7 @@ impl Vecs {
|
||||
let version = parent_version + VERSION;
|
||||
|
||||
let this = Self {
|
||||
txinindex_to_txoutindex: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"txoutindex",
|
||||
version,
|
||||
)?,
|
||||
txinindex_to_txoutindex: EagerVec::forced_import(&db, "txoutindex", version)?,
|
||||
txoutindex_to_txoutindex: LazyVecFrom1::init(
|
||||
"txoutindex",
|
||||
version + Version::ZERO,
|
||||
@@ -203,217 +199,205 @@ impl Vecs {
|
||||
indexer.vecs.txindex_to_txid.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
),
|
||||
txindex_to_input_count: EagerVec::forced_import_compressed(
|
||||
txindex_to_input_count: EagerVec::forced_import(
|
||||
&db,
|
||||
"input_count",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
txindex_to_output_count: EagerVec::forced_import_compressed(
|
||||
txindex_to_output_count: EagerVec::forced_import(
|
||||
&db,
|
||||
"output_count",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
dateindex_to_date: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"date",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
dateindex_to_dateindex: EagerVec::forced_import_compressed(
|
||||
dateindex_to_date: EagerVec::forced_import(&db, "date", version + Version::ZERO)?,
|
||||
dateindex_to_dateindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"dateindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
dateindex_to_first_height: EagerVec::forced_import_compressed(
|
||||
dateindex_to_first_height: EagerVec::forced_import(
|
||||
&db,
|
||||
"first_height",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
dateindex_to_monthindex: EagerVec::forced_import_compressed(
|
||||
dateindex_to_monthindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"monthindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
dateindex_to_weekindex: EagerVec::forced_import_compressed(
|
||||
dateindex_to_weekindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"weekindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
decadeindex_to_decadeindex: EagerVec::forced_import_compressed(
|
||||
decadeindex_to_decadeindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"decadeindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
decadeindex_to_first_yearindex: EagerVec::forced_import_compressed(
|
||||
decadeindex_to_first_yearindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"first_yearindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
difficultyepoch_to_difficultyepoch: EagerVec::forced_import_compressed(
|
||||
difficultyepoch_to_difficultyepoch: EagerVec::forced_import(
|
||||
&db,
|
||||
"difficultyepoch",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
difficultyepoch_to_first_height: EagerVec::forced_import_compressed(
|
||||
difficultyepoch_to_first_height: EagerVec::forced_import(
|
||||
&db,
|
||||
"first_height",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
halvingepoch_to_first_height: EagerVec::forced_import_compressed(
|
||||
halvingepoch_to_first_height: EagerVec::forced_import(
|
||||
&db,
|
||||
"first_height",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
halvingepoch_to_halvingepoch: EagerVec::forced_import_compressed(
|
||||
halvingepoch_to_halvingepoch: EagerVec::forced_import(
|
||||
&db,
|
||||
"halvingepoch",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_date: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"date",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_difficultyepoch: EagerVec::forced_import_compressed(
|
||||
height_to_date: EagerVec::forced_import(&db, "date", version + Version::ZERO)?,
|
||||
height_to_difficultyepoch: EagerVec::forced_import(
|
||||
&db,
|
||||
"difficultyepoch",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_halvingepoch: EagerVec::forced_import_compressed(
|
||||
height_to_halvingepoch: EagerVec::forced_import(
|
||||
&db,
|
||||
"halvingepoch",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_height: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"height",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
monthindex_to_first_dateindex: EagerVec::forced_import_compressed(
|
||||
height_to_height: EagerVec::forced_import(&db, "height", version + Version::ZERO)?,
|
||||
monthindex_to_first_dateindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"first_dateindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
monthindex_to_monthindex: EagerVec::forced_import_compressed(
|
||||
monthindex_to_monthindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"monthindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
monthindex_to_quarterindex: EagerVec::forced_import_compressed(
|
||||
monthindex_to_quarterindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"quarterindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
monthindex_to_semesterindex: EagerVec::forced_import_compressed(
|
||||
monthindex_to_semesterindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"semesterindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
monthindex_to_yearindex: EagerVec::forced_import_compressed(
|
||||
monthindex_to_yearindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"yearindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
quarterindex_to_first_monthindex: EagerVec::forced_import_compressed(
|
||||
quarterindex_to_first_monthindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"first_monthindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
semesterindex_to_first_monthindex: EagerVec::forced_import_compressed(
|
||||
semesterindex_to_first_monthindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"first_monthindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
weekindex_to_first_dateindex: EagerVec::forced_import_compressed(
|
||||
weekindex_to_first_dateindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"first_dateindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
yearindex_to_first_monthindex: EagerVec::forced_import_compressed(
|
||||
yearindex_to_first_monthindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"first_monthindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
quarterindex_to_quarterindex: EagerVec::forced_import_compressed(
|
||||
quarterindex_to_quarterindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"quarterindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
semesterindex_to_semesterindex: EagerVec::forced_import_compressed(
|
||||
semesterindex_to_semesterindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"semesterindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
weekindex_to_weekindex: EagerVec::forced_import_compressed(
|
||||
weekindex_to_weekindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"weekindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
yearindex_to_decadeindex: EagerVec::forced_import_compressed(
|
||||
yearindex_to_decadeindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"decadeindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
yearindex_to_yearindex: EagerVec::forced_import_compressed(
|
||||
yearindex_to_yearindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"yearindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_date_fixed: EagerVec::forced_import_compressed(
|
||||
height_to_date_fixed: EagerVec::forced_import(
|
||||
&db,
|
||||
"date_fixed",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_dateindex: EagerVec::forced_import_compressed(
|
||||
height_to_dateindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"dateindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_timestamp_fixed: EagerVec::forced_import_compressed(
|
||||
height_to_timestamp_fixed: EagerVec::forced_import(
|
||||
&db,
|
||||
"timestamp_fixed",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_txindex_count: EagerVec::forced_import_compressed(
|
||||
height_to_txindex_count: EagerVec::forced_import(
|
||||
&db,
|
||||
"txindex_count",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
dateindex_to_height_count: EagerVec::forced_import_compressed(
|
||||
dateindex_to_height_count: EagerVec::forced_import(
|
||||
&db,
|
||||
"height_count",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
weekindex_to_dateindex_count: EagerVec::forced_import_compressed(
|
||||
weekindex_to_dateindex_count: EagerVec::forced_import(
|
||||
&db,
|
||||
"dateindex_count",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
difficultyepoch_to_height_count: EagerVec::forced_import_compressed(
|
||||
difficultyepoch_to_height_count: EagerVec::forced_import(
|
||||
&db,
|
||||
"height_count",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
monthindex_to_dateindex_count: EagerVec::forced_import_compressed(
|
||||
monthindex_to_dateindex_count: EagerVec::forced_import(
|
||||
&db,
|
||||
"dateindex_count",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
quarterindex_to_monthindex_count: EagerVec::forced_import_compressed(
|
||||
quarterindex_to_monthindex_count: EagerVec::forced_import(
|
||||
&db,
|
||||
"monthindex_count",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
semesterindex_to_monthindex_count: EagerVec::forced_import_compressed(
|
||||
semesterindex_to_monthindex_count: EagerVec::forced_import(
|
||||
&db,
|
||||
"monthindex_count",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
yearindex_to_monthindex_count: EagerVec::forced_import_compressed(
|
||||
yearindex_to_monthindex_count: EagerVec::forced_import(
|
||||
&db,
|
||||
"monthindex_count",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
decadeindex_to_yearindex_count: EagerVec::forced_import_compressed(
|
||||
decadeindex_to_yearindex_count: EagerVec::forced_import(
|
||||
&db,
|
||||
"yearindex_count",
|
||||
version + Version::ZERO,
|
||||
@@ -422,7 +406,7 @@ impl Vecs {
|
||||
};
|
||||
|
||||
this.db.retain_regions(
|
||||
this.iter_any_writable()
|
||||
this.iter_any_exportable()
|
||||
.flat_map(|v| v.region_names())
|
||||
.collect(),
|
||||
)?;
|
||||
|
||||
@@ -9,7 +9,7 @@ use brk_reader::Reader;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::Version;
|
||||
use log::info;
|
||||
use vecdb::{Exit, Format};
|
||||
use vecdb::Exit;
|
||||
|
||||
mod blks;
|
||||
mod chain;
|
||||
@@ -125,13 +125,8 @@ impl Computer {
|
||||
})?;
|
||||
|
||||
// Threads inside
|
||||
let stateful = stateful::Vecs::forced_import(
|
||||
&computed_path,
|
||||
VERSION,
|
||||
Format::Compressed,
|
||||
&indexes,
|
||||
price.as_ref(),
|
||||
)?;
|
||||
let stateful =
|
||||
stateful::Vecs::forced_import(&computed_path, VERSION, &indexes, price.as_ref())?;
|
||||
|
||||
Ok(Self {
|
||||
constants,
|
||||
|
||||
@@ -3,7 +3,10 @@ use std::{path::Path, thread};
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Date, DateIndex, Dollars, Height, Sats, StoredF32, StoredU16, Version};
|
||||
use vecdb::{Database, EagerVec, Exit, GenericStoredVec, PAGE_SIZE, TypedVecIterator, VecIndex};
|
||||
use vecdb::{
|
||||
Database, EagerVec, Exit, GenericStoredVec, Importable, PAGE_SIZE, PcoVec, TypedVecIterator,
|
||||
VecIndex,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
grouped::{ComputedStandardDeviationVecsFromDateIndex, Source, StandardDeviationVecsOptions},
|
||||
@@ -21,8 +24,8 @@ use super::{
|
||||
pub struct Vecs {
|
||||
db: Database,
|
||||
|
||||
pub height_to_price_ath: EagerVec<Height, Dollars>,
|
||||
pub height_to_price_drawdown: EagerVec<Height, StoredF32>,
|
||||
pub height_to_price_ath: EagerVec<PcoVec<Height, Dollars>>,
|
||||
pub height_to_price_drawdown: EagerVec<PcoVec<Height, StoredF32>>,
|
||||
pub indexes_to_price_ath: ComputedVecsFromDateIndex<Dollars>,
|
||||
pub indexes_to_price_drawdown: ComputedVecsFromDateIndex<StoredF32>,
|
||||
pub indexes_to_days_since_price_ath: ComputedVecsFromDateIndex<StoredU16>,
|
||||
@@ -45,8 +48,8 @@ pub struct Vecs {
|
||||
pub indexes_to_price_1y_min: ComputedVecsFromDateIndex<Dollars>,
|
||||
pub indexes_to_price_1y_max: ComputedVecsFromDateIndex<Dollars>,
|
||||
|
||||
pub dateindex_to_price_true_range: EagerVec<DateIndex, StoredF32>,
|
||||
pub dateindex_to_price_true_range_2w_sum: EagerVec<DateIndex, StoredF32>,
|
||||
pub dateindex_to_price_true_range: EagerVec<PcoVec<DateIndex, StoredF32>>,
|
||||
pub dateindex_to_price_true_range_2w_sum: EagerVec<PcoVec<DateIndex, StoredF32>>,
|
||||
pub indexes_to_price_2w_choppiness_index: ComputedVecsFromDateIndex<StoredF32>,
|
||||
|
||||
pub indexes_to_price_1w_sma: ComputedRatioVecsFromDateIndex,
|
||||
@@ -210,12 +213,12 @@ impl Vecs {
|
||||
let version = parent_version + Version::ZERO;
|
||||
|
||||
let this = Self {
|
||||
height_to_price_ath: EagerVec::forced_import_compressed(
|
||||
height_to_price_ath: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_ath",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_price_drawdown: EagerVec::forced_import_compressed(
|
||||
height_to_price_drawdown: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_drawdown",
|
||||
version + Version::ZERO,
|
||||
@@ -1431,12 +1434,12 @@ impl Vecs {
|
||||
indexes,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
dateindex_to_price_true_range: EagerVec::forced_import_compressed(
|
||||
dateindex_to_price_true_range: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_true_range",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
dateindex_to_price_true_range_2w_sum: EagerVec::forced_import_compressed(
|
||||
dateindex_to_price_true_range_2w_sum: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_true_range_2w_sum",
|
||||
version + Version::ZERO,
|
||||
@@ -1517,7 +1520,7 @@ impl Vecs {
|
||||
};
|
||||
|
||||
this.db.retain_regions(
|
||||
this.iter_any_writable()
|
||||
this.iter_any_exportable()
|
||||
.flat_map(|v| v.region_names())
|
||||
.collect(),
|
||||
)?;
|
||||
@@ -1593,7 +1596,7 @@ impl Vecs {
|
||||
if prev.is_none() {
|
||||
let i = i.to_usize();
|
||||
prev.replace(if i > 0 {
|
||||
slf.get_or_read_at_once(i - 1).unwrap().unwrap()
|
||||
slf.get_pushed_or_read_at_unwrap_once(i - 1)
|
||||
} else {
|
||||
StoredU16::default()
|
||||
});
|
||||
@@ -1624,7 +1627,7 @@ impl Vecs {
|
||||
if prev.is_none() {
|
||||
let i = i.to_usize();
|
||||
prev.replace(if i > 0 {
|
||||
slf.get_or_read_at_unwrap_once(i - 1)
|
||||
slf.get_pushed_or_read_at_unwrap_once(i - 1)
|
||||
} else {
|
||||
StoredU16::ZERO
|
||||
});
|
||||
@@ -2137,19 +2140,19 @@ impl Vecs {
|
||||
starting_indexes,
|
||||
exit,
|
||||
self._1d_price_returns.dateindex.as_ref().unwrap(),
|
||||
None as Option<&EagerVec<DateIndex, Dollars>>,
|
||||
None as Option<&EagerVec<PcoVec<DateIndex, Dollars>>>,
|
||||
)?;
|
||||
self.indexes_to_1d_returns_1m_sd.compute_all(
|
||||
starting_indexes,
|
||||
exit,
|
||||
self._1d_price_returns.dateindex.as_ref().unwrap(),
|
||||
None as Option<&EagerVec<DateIndex, Dollars>>,
|
||||
None as Option<&EagerVec<PcoVec<DateIndex, Dollars>>>,
|
||||
)?;
|
||||
self.indexes_to_1d_returns_1y_sd.compute_all(
|
||||
starting_indexes,
|
||||
exit,
|
||||
self._1d_price_returns.dateindex.as_ref().unwrap(),
|
||||
None as Option<&EagerVec<DateIndex, Dollars>>,
|
||||
None as Option<&EagerVec<PcoVec<DateIndex, Dollars>>>,
|
||||
)?;
|
||||
|
||||
self.indexes_to_price_1w_volatility
|
||||
|
||||
@@ -7,8 +7,8 @@ use brk_traversable::Traversable;
|
||||
use brk_types::{Address, AddressBytes, Height, OutputType, PoolId, Pools, TxOutIndex, pools};
|
||||
use rayon::prelude::*;
|
||||
use vecdb::{
|
||||
AnyStoredVec, AnyVec, Database, Exit, GenericStoredVec, IterableVec, PAGE_SIZE, RawVec,
|
||||
TypedVecIterator, VecIndex, Version,
|
||||
AnyStoredVec, AnyVec, BytesVec, Database, Exit, GenericStoredVec, Importable, IterableVec,
|
||||
PAGE_SIZE, TypedVecIterator, VecIndex, Version,
|
||||
};
|
||||
|
||||
mod vecs;
|
||||
@@ -24,7 +24,7 @@ pub struct Vecs {
|
||||
db: Database,
|
||||
pools: &'static Pools,
|
||||
|
||||
pub height_to_pool: RawVec<Height, PoolId>,
|
||||
pub height_to_pool: BytesVec<Height, PoolId>,
|
||||
pub vecs: BTreeMap<PoolId, vecs::Vecs>,
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ impl Vecs {
|
||||
let version = parent_version + Version::new(3) + Version::new(pools.len() as u64);
|
||||
|
||||
let this = Self {
|
||||
height_to_pool: RawVec::forced_import(&db, "pool", version + Version::ZERO)?,
|
||||
height_to_pool: BytesVec::forced_import(&db, "pool", version + Version::ZERO)?,
|
||||
vecs: pools
|
||||
.iter()
|
||||
.map(|pool| {
|
||||
@@ -62,7 +62,7 @@ impl Vecs {
|
||||
};
|
||||
|
||||
this.db.retain_regions(
|
||||
this.iter_any_writable()
|
||||
this.iter_any_exportable()
|
||||
.flat_map(|v| v.region_names())
|
||||
.collect(),
|
||||
)?;
|
||||
|
||||
@@ -353,7 +353,7 @@ impl Vecs {
|
||||
if prev.is_none() {
|
||||
let i = i.to_usize();
|
||||
prev.replace(if i > 0 {
|
||||
slf.get_or_read_at_unwrap_once(i - 1)
|
||||
slf.get_pushed_or_read_at_unwrap_once(i - 1)
|
||||
} else {
|
||||
StoredU16::ZERO
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@ use brk_types::{
|
||||
Cents, Close, DateIndex, DecadeIndex, DifficultyEpoch, Dollars, Height, High, Low, MonthIndex,
|
||||
OHLCDollars, OHLCSats, Open, QuarterIndex, Sats, SemesterIndex, Version, WeekIndex, YearIndex,
|
||||
};
|
||||
use vecdb::{Database, EagerVec, Exit, PAGE_SIZE};
|
||||
use vecdb::{BytesVec, Database, EagerVec, Exit, Importable, PAGE_SIZE, PcoVec};
|
||||
|
||||
use crate::{fetched, grouped::Source};
|
||||
|
||||
@@ -20,18 +20,18 @@ use super::{
|
||||
pub struct Vecs {
|
||||
db: Database,
|
||||
|
||||
pub dateindex_to_price_close_in_cents: EagerVec<DateIndex, Close<Cents>>,
|
||||
pub dateindex_to_price_high_in_cents: EagerVec<DateIndex, High<Cents>>,
|
||||
pub dateindex_to_price_low_in_cents: EagerVec<DateIndex, Low<Cents>>,
|
||||
pub dateindex_to_price_ohlc: EagerVec<DateIndex, OHLCDollars>,
|
||||
pub dateindex_to_price_ohlc_in_sats: EagerVec<DateIndex, OHLCSats>,
|
||||
pub dateindex_to_price_open_in_cents: EagerVec<DateIndex, Open<Cents>>,
|
||||
pub height_to_price_close_in_cents: EagerVec<Height, Close<Cents>>,
|
||||
pub height_to_price_high_in_cents: EagerVec<Height, High<Cents>>,
|
||||
pub height_to_price_low_in_cents: EagerVec<Height, Low<Cents>>,
|
||||
pub height_to_price_ohlc: EagerVec<Height, OHLCDollars>,
|
||||
pub height_to_price_ohlc_in_sats: EagerVec<Height, OHLCSats>,
|
||||
pub height_to_price_open_in_cents: EagerVec<Height, Open<Cents>>,
|
||||
pub dateindex_to_price_close_in_cents: EagerVec<PcoVec<DateIndex, Close<Cents>>>,
|
||||
pub dateindex_to_price_high_in_cents: EagerVec<PcoVec<DateIndex, High<Cents>>>,
|
||||
pub dateindex_to_price_low_in_cents: EagerVec<PcoVec<DateIndex, Low<Cents>>>,
|
||||
pub dateindex_to_price_ohlc: EagerVec<BytesVec<DateIndex, OHLCDollars>>,
|
||||
pub dateindex_to_price_ohlc_in_sats: EagerVec<BytesVec<DateIndex, OHLCSats>>,
|
||||
pub dateindex_to_price_open_in_cents: EagerVec<PcoVec<DateIndex, Open<Cents>>>,
|
||||
pub height_to_price_close_in_cents: EagerVec<PcoVec<Height, Close<Cents>>>,
|
||||
pub height_to_price_high_in_cents: EagerVec<PcoVec<Height, High<Cents>>>,
|
||||
pub height_to_price_low_in_cents: EagerVec<PcoVec<Height, Low<Cents>>>,
|
||||
pub height_to_price_ohlc: EagerVec<BytesVec<Height, OHLCDollars>>,
|
||||
pub height_to_price_ohlc_in_sats: EagerVec<BytesVec<Height, OHLCSats>>,
|
||||
pub height_to_price_open_in_cents: EagerVec<PcoVec<Height, Open<Cents>>>,
|
||||
pub timeindexes_to_price_close: ComputedVecsFromDateIndex<Close<Dollars>>,
|
||||
pub timeindexes_to_price_high: ComputedVecsFromDateIndex<High<Dollars>>,
|
||||
pub timeindexes_to_price_low: ComputedVecsFromDateIndex<Low<Dollars>>,
|
||||
@@ -48,22 +48,22 @@ pub struct Vecs {
|
||||
pub chainindexes_to_price_high_in_sats: ComputedVecsFromHeightStrict<High<Sats>>,
|
||||
pub chainindexes_to_price_low_in_sats: ComputedVecsFromHeightStrict<Low<Sats>>,
|
||||
pub chainindexes_to_price_close_in_sats: ComputedVecsFromHeightStrict<Close<Sats>>,
|
||||
pub weekindex_to_price_ohlc: EagerVec<WeekIndex, OHLCDollars>,
|
||||
pub weekindex_to_price_ohlc_in_sats: EagerVec<WeekIndex, OHLCSats>,
|
||||
pub difficultyepoch_to_price_ohlc: EagerVec<DifficultyEpoch, OHLCDollars>,
|
||||
pub difficultyepoch_to_price_ohlc_in_sats: EagerVec<DifficultyEpoch, OHLCSats>,
|
||||
pub monthindex_to_price_ohlc: EagerVec<MonthIndex, OHLCDollars>,
|
||||
pub monthindex_to_price_ohlc_in_sats: EagerVec<MonthIndex, OHLCSats>,
|
||||
pub quarterindex_to_price_ohlc: EagerVec<QuarterIndex, OHLCDollars>,
|
||||
pub quarterindex_to_price_ohlc_in_sats: EagerVec<QuarterIndex, OHLCSats>,
|
||||
pub semesterindex_to_price_ohlc: EagerVec<SemesterIndex, OHLCDollars>,
|
||||
pub semesterindex_to_price_ohlc_in_sats: EagerVec<SemesterIndex, OHLCSats>,
|
||||
pub yearindex_to_price_ohlc: EagerVec<YearIndex, OHLCDollars>,
|
||||
pub yearindex_to_price_ohlc_in_sats: EagerVec<YearIndex, OHLCSats>,
|
||||
pub weekindex_to_price_ohlc: EagerVec<BytesVec<WeekIndex, OHLCDollars>>,
|
||||
pub weekindex_to_price_ohlc_in_sats: EagerVec<BytesVec<WeekIndex, OHLCSats>>,
|
||||
pub difficultyepoch_to_price_ohlc: EagerVec<BytesVec<DifficultyEpoch, OHLCDollars>>,
|
||||
pub difficultyepoch_to_price_ohlc_in_sats: EagerVec<BytesVec<DifficultyEpoch, OHLCSats>>,
|
||||
pub monthindex_to_price_ohlc: EagerVec<BytesVec<MonthIndex, OHLCDollars>>,
|
||||
pub monthindex_to_price_ohlc_in_sats: EagerVec<BytesVec<MonthIndex, OHLCSats>>,
|
||||
pub quarterindex_to_price_ohlc: EagerVec<BytesVec<QuarterIndex, OHLCDollars>>,
|
||||
pub quarterindex_to_price_ohlc_in_sats: EagerVec<BytesVec<QuarterIndex, OHLCSats>>,
|
||||
pub semesterindex_to_price_ohlc: EagerVec<BytesVec<SemesterIndex, OHLCDollars>>,
|
||||
pub semesterindex_to_price_ohlc_in_sats: EagerVec<BytesVec<SemesterIndex, OHLCSats>>,
|
||||
pub yearindex_to_price_ohlc: EagerVec<BytesVec<YearIndex, OHLCDollars>>,
|
||||
pub yearindex_to_price_ohlc_in_sats: EagerVec<BytesVec<YearIndex, OHLCSats>>,
|
||||
// pub halvingepoch_to_price_ohlc: StorableVec<Halvingepoch, OHLCDollars>,
|
||||
// pub halvingepoch_to_price_ohlc_in_sats: StorableVec<Halvingepoch, OHLCSats>,
|
||||
pub decadeindex_to_price_ohlc: EagerVec<DecadeIndex, OHLCDollars>,
|
||||
pub decadeindex_to_price_ohlc_in_sats: EagerVec<DecadeIndex, OHLCSats>,
|
||||
pub decadeindex_to_price_ohlc: EagerVec<BytesVec<DecadeIndex, OHLCDollars>>,
|
||||
pub decadeindex_to_price_ohlc_in_sats: EagerVec<BytesVec<DecadeIndex, OHLCSats>>,
|
||||
}
|
||||
|
||||
const VERSION: Version = Version::ZERO;
|
||||
@@ -75,62 +75,62 @@ impl Vecs {
|
||||
db.set_min_len(PAGE_SIZE * 1_000_000)?;
|
||||
|
||||
let this = Self {
|
||||
dateindex_to_price_ohlc: EagerVec::forced_import_raw(
|
||||
dateindex_to_price_ohlc: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_ohlc",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
dateindex_to_price_ohlc_in_sats: EagerVec::forced_import_raw(
|
||||
dateindex_to_price_ohlc_in_sats: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_ohlc_in_sats",
|
||||
version + VERSION + VERSION_IN_SATS + Version::ZERO,
|
||||
)?,
|
||||
dateindex_to_price_close_in_cents: EagerVec::forced_import_compressed(
|
||||
dateindex_to_price_close_in_cents: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_close_in_cents",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
dateindex_to_price_high_in_cents: EagerVec::forced_import_compressed(
|
||||
dateindex_to_price_high_in_cents: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_high_in_cents",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
dateindex_to_price_low_in_cents: EagerVec::forced_import_compressed(
|
||||
dateindex_to_price_low_in_cents: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_low_in_cents",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
dateindex_to_price_open_in_cents: EagerVec::forced_import_compressed(
|
||||
dateindex_to_price_open_in_cents: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_open_in_cents",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
height_to_price_ohlc: EagerVec::forced_import_raw(
|
||||
height_to_price_ohlc: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_ohlc",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
height_to_price_ohlc_in_sats: EagerVec::forced_import_raw(
|
||||
height_to_price_ohlc_in_sats: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_ohlc_in_sats",
|
||||
version + VERSION + VERSION_IN_SATS + Version::ZERO,
|
||||
)?,
|
||||
height_to_price_close_in_cents: EagerVec::forced_import_compressed(
|
||||
height_to_price_close_in_cents: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_close_in_cents",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
height_to_price_high_in_cents: EagerVec::forced_import_compressed(
|
||||
height_to_price_high_in_cents: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_high_in_cents",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
height_to_price_low_in_cents: EagerVec::forced_import_compressed(
|
||||
height_to_price_low_in_cents: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_low_in_cents",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
height_to_price_open_in_cents: EagerVec::forced_import_compressed(
|
||||
height_to_price_open_in_cents: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_open_in_cents",
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -247,74 +247,74 @@ impl Vecs {
|
||||
version + VERSION + VERSION_IN_SATS + Version::ZERO,
|
||||
VecBuilderOptions::default().add_last(),
|
||||
)?,
|
||||
weekindex_to_price_ohlc: EagerVec::forced_import_raw(
|
||||
weekindex_to_price_ohlc: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_ohlc",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
weekindex_to_price_ohlc_in_sats: EagerVec::forced_import_raw(
|
||||
weekindex_to_price_ohlc_in_sats: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_ohlc_in_sats",
|
||||
version + VERSION + VERSION_IN_SATS + Version::ZERO,
|
||||
)?,
|
||||
difficultyepoch_to_price_ohlc: EagerVec::forced_import_raw(
|
||||
difficultyepoch_to_price_ohlc: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_ohlc",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
difficultyepoch_to_price_ohlc_in_sats: EagerVec::forced_import_raw(
|
||||
difficultyepoch_to_price_ohlc_in_sats: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_ohlc_in_sats",
|
||||
version + VERSION + VERSION_IN_SATS + Version::ZERO,
|
||||
)?,
|
||||
monthindex_to_price_ohlc: EagerVec::forced_import_raw(
|
||||
monthindex_to_price_ohlc: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_ohlc",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
monthindex_to_price_ohlc_in_sats: EagerVec::forced_import_raw(
|
||||
monthindex_to_price_ohlc_in_sats: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_ohlc_in_sats",
|
||||
version + VERSION + VERSION_IN_SATS + Version::ZERO,
|
||||
)?,
|
||||
quarterindex_to_price_ohlc: EagerVec::forced_import_raw(
|
||||
quarterindex_to_price_ohlc: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_ohlc",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
quarterindex_to_price_ohlc_in_sats: EagerVec::forced_import_raw(
|
||||
quarterindex_to_price_ohlc_in_sats: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_ohlc_in_sats",
|
||||
version + VERSION + VERSION_IN_SATS + Version::ZERO,
|
||||
)?,
|
||||
semesterindex_to_price_ohlc: EagerVec::forced_import_raw(
|
||||
semesterindex_to_price_ohlc: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_ohlc",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
semesterindex_to_price_ohlc_in_sats: EagerVec::forced_import_raw(
|
||||
semesterindex_to_price_ohlc_in_sats: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_ohlc_in_sats",
|
||||
version + VERSION + VERSION_IN_SATS + Version::ZERO,
|
||||
)?,
|
||||
yearindex_to_price_ohlc: EagerVec::forced_import_raw(
|
||||
yearindex_to_price_ohlc: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_ohlc",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
yearindex_to_price_ohlc_in_sats: EagerVec::forced_import_raw(
|
||||
yearindex_to_price_ohlc_in_sats: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_ohlc_in_sats",
|
||||
version + VERSION + VERSION_IN_SATS + Version::ZERO,
|
||||
)?,
|
||||
// halvingepoch_to_price_ohlc: StorableVec::forced_import(db,
|
||||
// "halvingepoch_to_price_ohlc"), version + VERSION + Version::ZERO, format)?,
|
||||
decadeindex_to_price_ohlc: EagerVec::forced_import_raw(
|
||||
decadeindex_to_price_ohlc: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_ohlc",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
decadeindex_to_price_ohlc_in_sats: EagerVec::forced_import_raw(
|
||||
decadeindex_to_price_ohlc_in_sats: EagerVec::forced_import(
|
||||
&db,
|
||||
"price_ohlc_in_sats",
|
||||
version + VERSION + VERSION_IN_SATS + Version::ZERO,
|
||||
@@ -324,7 +324,7 @@ impl Vecs {
|
||||
};
|
||||
|
||||
this.db.retain_regions(
|
||||
this.iter_any_writable()
|
||||
this.iter_any_exportable()
|
||||
.flat_map(|v| v.region_names())
|
||||
.collect(),
|
||||
)?;
|
||||
|
||||
@@ -4,8 +4,8 @@ use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Bitcoin, DateIndex, Dollars, Height, StoredU64, Version};
|
||||
use vecdb::{
|
||||
AnyStoredVec, AnyVec, Database, EagerVec, Exit, Format, GenericStoredVec, IterableVec,
|
||||
TypedVecIterator,
|
||||
AnyStoredVec, AnyVec, Database, EagerVec, Exit, GenericStoredVec, Importable, IterableVec,
|
||||
PcoVec, TypedVecIterator,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@@ -31,7 +31,7 @@ pub struct Vecs {
|
||||
#[traversable(flatten)]
|
||||
pub inner: common::Vecs,
|
||||
|
||||
pub height_to_addr_count: EagerVec<Height, StoredU64>,
|
||||
pub height_to_addr_count: EagerVec<PcoVec<Height, StoredU64>>,
|
||||
pub indexes_to_addr_count: ComputedVecsFromHeight<StoredU64>,
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ impl Vecs {
|
||||
pub fn forced_import(
|
||||
db: &Database,
|
||||
cohort_name: Option<&str>,
|
||||
format: Format,
|
||||
version: Version,
|
||||
indexes: &indexes::Vecs,
|
||||
price: Option<&price::Vecs>,
|
||||
@@ -64,7 +63,6 @@ impl Vecs {
|
||||
db,
|
||||
&suffix("addr_count"),
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
indexes_to_addr_count: ComputedVecsFromHeight::forced_import(
|
||||
db,
|
||||
@@ -77,7 +75,6 @@ impl Vecs {
|
||||
inner: common::Vecs::forced_import(
|
||||
db,
|
||||
cohort_name,
|
||||
format,
|
||||
version,
|
||||
indexes,
|
||||
price,
|
||||
|
||||
@@ -5,7 +5,7 @@ use brk_grouper::{AddressGroups, ByAmountRange, ByGreatEqualAmount, ByLowerThanA
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Bitcoin, DateIndex, Dollars, Height, Version};
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use vecdb::{Database, Exit, Format, IterableVec};
|
||||
use vecdb::{Database, Exit, IterableVec};
|
||||
|
||||
use crate::{
|
||||
Indexes, indexes, price,
|
||||
@@ -24,7 +24,6 @@ impl Vecs {
|
||||
pub fn forced_import(
|
||||
db: &Database,
|
||||
version: Version,
|
||||
format: Format,
|
||||
indexes: &indexes::Vecs,
|
||||
price: Option<&price::Vecs>,
|
||||
states_path: &Path,
|
||||
@@ -35,7 +34,6 @@ impl Vecs {
|
||||
_0sats: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_with_0sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -45,7 +43,6 @@ impl Vecs {
|
||||
_1sat_to_10sats: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_1sat_under_10sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -55,7 +52,6 @@ impl Vecs {
|
||||
_10sats_to_100sats: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_10sats_under_100sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -65,7 +61,6 @@ impl Vecs {
|
||||
_100sats_to_1k_sats: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_100sats_under_1k_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -75,7 +70,6 @@ impl Vecs {
|
||||
_1k_sats_to_10k_sats: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_1k_sats_under_10k_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -85,7 +79,6 @@ impl Vecs {
|
||||
_10k_sats_to_100k_sats: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_10k_sats_under_100k_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -95,7 +88,6 @@ impl Vecs {
|
||||
_100k_sats_to_1m_sats: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_100k_sats_under_1m_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -105,7 +97,6 @@ impl Vecs {
|
||||
_1m_sats_to_10m_sats: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_1m_sats_under_10m_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -115,7 +106,6 @@ impl Vecs {
|
||||
_10m_sats_to_1btc: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_10m_sats_under_1btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -125,7 +115,6 @@ impl Vecs {
|
||||
_1btc_to_10btc: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_1btc_under_10btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -135,7 +124,6 @@ impl Vecs {
|
||||
_10btc_to_100btc: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_10btc_under_100btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -145,7 +133,6 @@ impl Vecs {
|
||||
_100btc_to_1k_btc: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_100btc_under_1k_btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -155,7 +142,6 @@ impl Vecs {
|
||||
_1k_btc_to_10k_btc: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_1k_btc_under_10k_btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -165,7 +151,6 @@ impl Vecs {
|
||||
_10k_btc_to_100k_btc: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_10k_btc_under_100k_btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -175,7 +160,6 @@ impl Vecs {
|
||||
_100k_btc_or_more: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_100k_btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -187,7 +171,6 @@ impl Vecs {
|
||||
_10sats: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_under_10sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -197,7 +180,6 @@ impl Vecs {
|
||||
_100sats: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_under_100sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -207,7 +189,6 @@ impl Vecs {
|
||||
_1k_sats: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_under_1k_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -217,7 +198,6 @@ impl Vecs {
|
||||
_10k_sats: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_under_10k_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -227,7 +207,6 @@ impl Vecs {
|
||||
_100k_sats: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_under_100k_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -237,7 +216,6 @@ impl Vecs {
|
||||
_1m_sats: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_under_1m_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -247,7 +225,6 @@ impl Vecs {
|
||||
_10m_sats: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_under_10m_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -257,7 +234,6 @@ impl Vecs {
|
||||
_1btc: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_under_1btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -267,7 +243,6 @@ impl Vecs {
|
||||
_10btc: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_under_10btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -277,7 +252,6 @@ impl Vecs {
|
||||
_100btc: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_under_100btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -287,7 +261,6 @@ impl Vecs {
|
||||
_1k_btc: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_under_1k_btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -297,7 +270,6 @@ impl Vecs {
|
||||
_10k_btc: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_under_10k_btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -307,7 +279,6 @@ impl Vecs {
|
||||
_100k_btc: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_under_100k_btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -319,7 +290,6 @@ impl Vecs {
|
||||
_1sat: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_1sat"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -329,7 +299,6 @@ impl Vecs {
|
||||
_10sats: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_10sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -339,7 +308,6 @@ impl Vecs {
|
||||
_100sats: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_100sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -349,7 +317,6 @@ impl Vecs {
|
||||
_1k_sats: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_1k_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -359,7 +326,6 @@ impl Vecs {
|
||||
_10k_sats: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_10k_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -369,7 +335,6 @@ impl Vecs {
|
||||
_100k_sats: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_100k_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -379,7 +344,6 @@ impl Vecs {
|
||||
_1m_sats: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_1m_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -389,7 +353,6 @@ impl Vecs {
|
||||
_10m_sats: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_10m_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -399,7 +362,6 @@ impl Vecs {
|
||||
_1btc: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_1btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -409,7 +371,6 @@ impl Vecs {
|
||||
_10btc: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_10btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -419,7 +380,6 @@ impl Vecs {
|
||||
_100btc: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_100btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -429,7 +389,6 @@ impl Vecs {
|
||||
_1k_btc: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_1k_btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -439,7 +398,6 @@ impl Vecs {
|
||||
_10k_btc: address_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("addrs_above_10k_btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
|
||||
@@ -3,16 +3,16 @@ use brk_grouper::ByAddressType;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Height, StoredU64};
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use vecdb::{EagerVec, GenericStoredVec};
|
||||
use vecdb::{PcoVec, EagerVec, GenericStoredVec};
|
||||
|
||||
use super::AddressTypeToAddressCount;
|
||||
|
||||
#[derive(Debug, Clone, Deref, DerefMut, Traversable)]
|
||||
pub struct AddressTypeToHeightToAddressCount(ByAddressType<EagerVec<Height, StoredU64>>);
|
||||
pub struct AddressTypeToHeightToAddressCount(ByAddressType<EagerVec<PcoVec<Height, StoredU64>>>);
|
||||
|
||||
impl From<ByAddressType<EagerVec<Height, StoredU64>>> for AddressTypeToHeightToAddressCount {
|
||||
impl From<ByAddressType<EagerVec<PcoVec<Height, StoredU64>>>> for AddressTypeToHeightToAddressCount {
|
||||
#[inline]
|
||||
fn from(value: ByAddressType<EagerVec<Height, StoredU64>>) -> Self {
|
||||
fn from(value: ByAddressType<EagerVec<PcoVec<Height, StoredU64>>>) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ use brk_types::{
|
||||
Bitcoin, DateIndex, Dollars, Height, Sats, StoredF32, StoredF64, StoredU64, Version,
|
||||
};
|
||||
use vecdb::{
|
||||
AnyStoredVec, AnyVec, Database, EagerVec, Exit, Format, GenericStoredVec, IterableCloneableVec,
|
||||
IterableVec, TypedVecIterator,
|
||||
AnyStoredVec, AnyVec, Database, EagerVec, Exit, GenericStoredVec, Importable,
|
||||
IterableCloneableVec, IterableVec, PcoVec, TypedVecIterator,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@@ -21,41 +21,41 @@ use crate::{
|
||||
#[derive(Clone, Traversable)]
|
||||
pub struct Vecs {
|
||||
// Cumulative
|
||||
pub height_to_realized_cap: Option<EagerVec<Height, Dollars>>,
|
||||
pub height_to_supply: EagerVec<Height, Sats>,
|
||||
pub height_to_utxo_count: EagerVec<Height, StoredU64>,
|
||||
pub height_to_realized_cap: Option<EagerVec<PcoVec<Height, Dollars>>>,
|
||||
pub height_to_supply: EagerVec<PcoVec<Height, Sats>>,
|
||||
pub height_to_utxo_count: EagerVec<PcoVec<Height, StoredU64>>,
|
||||
// Single
|
||||
pub dateindex_to_supply_in_loss: Option<EagerVec<DateIndex, Sats>>,
|
||||
pub dateindex_to_supply_in_profit: Option<EagerVec<DateIndex, Sats>>,
|
||||
pub dateindex_to_unrealized_loss: Option<EagerVec<DateIndex, Dollars>>,
|
||||
pub dateindex_to_unrealized_profit: Option<EagerVec<DateIndex, Dollars>>,
|
||||
pub height_to_adjusted_value_created: Option<EagerVec<Height, Dollars>>,
|
||||
pub height_to_adjusted_value_destroyed: Option<EagerVec<Height, Dollars>>,
|
||||
pub height_to_max_price_paid: Option<EagerVec<Height, Dollars>>,
|
||||
pub height_to_min_price_paid: Option<EagerVec<Height, Dollars>>,
|
||||
pub height_to_realized_loss: Option<EagerVec<Height, Dollars>>,
|
||||
pub height_to_realized_profit: Option<EagerVec<Height, Dollars>>,
|
||||
pub height_to_supply_in_loss: Option<EagerVec<Height, Sats>>,
|
||||
pub height_to_supply_in_profit: Option<EagerVec<Height, Sats>>,
|
||||
pub height_to_unrealized_loss: Option<EagerVec<Height, Dollars>>,
|
||||
pub height_to_unrealized_profit: Option<EagerVec<Height, Dollars>>,
|
||||
pub height_to_value_created: Option<EagerVec<Height, Dollars>>,
|
||||
pub height_to_value_destroyed: Option<EagerVec<Height, Dollars>>,
|
||||
pub height_to_satblocks_destroyed: EagerVec<Height, Sats>,
|
||||
pub height_to_satdays_destroyed: EagerVec<Height, Sats>,
|
||||
pub dateindex_to_supply_in_loss: Option<EagerVec<PcoVec<DateIndex, Sats>>>,
|
||||
pub dateindex_to_supply_in_profit: Option<EagerVec<PcoVec<DateIndex, Sats>>>,
|
||||
pub dateindex_to_unrealized_loss: Option<EagerVec<PcoVec<DateIndex, Dollars>>>,
|
||||
pub dateindex_to_unrealized_profit: Option<EagerVec<PcoVec<DateIndex, Dollars>>>,
|
||||
pub height_to_adjusted_value_created: Option<EagerVec<PcoVec<Height, Dollars>>>,
|
||||
pub height_to_adjusted_value_destroyed: Option<EagerVec<PcoVec<Height, Dollars>>>,
|
||||
pub height_to_max_price_paid: Option<EagerVec<PcoVec<Height, Dollars>>>,
|
||||
pub height_to_min_price_paid: Option<EagerVec<PcoVec<Height, Dollars>>>,
|
||||
pub height_to_realized_loss: Option<EagerVec<PcoVec<Height, Dollars>>>,
|
||||
pub height_to_realized_profit: Option<EagerVec<PcoVec<Height, Dollars>>>,
|
||||
pub height_to_supply_in_loss: Option<EagerVec<PcoVec<Height, Sats>>>,
|
||||
pub height_to_supply_in_profit: Option<EagerVec<PcoVec<Height, Sats>>>,
|
||||
pub height_to_unrealized_loss: Option<EagerVec<PcoVec<Height, Dollars>>>,
|
||||
pub height_to_unrealized_profit: Option<EagerVec<PcoVec<Height, Dollars>>>,
|
||||
pub height_to_value_created: Option<EagerVec<PcoVec<Height, Dollars>>>,
|
||||
pub height_to_value_destroyed: Option<EagerVec<PcoVec<Height, Dollars>>>,
|
||||
pub height_to_satblocks_destroyed: EagerVec<PcoVec<Height, Sats>>,
|
||||
pub height_to_satdays_destroyed: EagerVec<PcoVec<Height, Sats>>,
|
||||
|
||||
pub indexes_to_coinblocks_destroyed: ComputedVecsFromHeight<StoredF64>,
|
||||
pub indexes_to_coindays_destroyed: ComputedVecsFromHeight<StoredF64>,
|
||||
pub dateindex_to_sopr: Option<EagerVec<DateIndex, StoredF64>>,
|
||||
pub dateindex_to_sopr_7d_ema: Option<EagerVec<DateIndex, StoredF64>>,
|
||||
pub dateindex_to_sopr_30d_ema: Option<EagerVec<DateIndex, StoredF64>>,
|
||||
pub dateindex_to_adjusted_sopr: Option<EagerVec<DateIndex, StoredF64>>,
|
||||
pub dateindex_to_adjusted_sopr_7d_ema: Option<EagerVec<DateIndex, StoredF64>>,
|
||||
pub dateindex_to_adjusted_sopr_30d_ema: Option<EagerVec<DateIndex, StoredF64>>,
|
||||
pub dateindex_to_sopr: Option<EagerVec<PcoVec<DateIndex, StoredF64>>>,
|
||||
pub dateindex_to_sopr_7d_ema: Option<EagerVec<PcoVec<DateIndex, StoredF64>>>,
|
||||
pub dateindex_to_sopr_30d_ema: Option<EagerVec<PcoVec<DateIndex, StoredF64>>>,
|
||||
pub dateindex_to_adjusted_sopr: Option<EagerVec<PcoVec<DateIndex, StoredF64>>>,
|
||||
pub dateindex_to_adjusted_sopr_7d_ema: Option<EagerVec<PcoVec<DateIndex, StoredF64>>>,
|
||||
pub dateindex_to_adjusted_sopr_30d_ema: Option<EagerVec<PcoVec<DateIndex, StoredF64>>>,
|
||||
pub indexes_to_realized_cap_30d_delta: Option<ComputedVecsFromDateIndex<Dollars>>,
|
||||
pub dateindex_to_sell_side_risk_ratio: Option<EagerVec<DateIndex, StoredF32>>,
|
||||
pub dateindex_to_sell_side_risk_ratio_7d_ema: Option<EagerVec<DateIndex, StoredF32>>,
|
||||
pub dateindex_to_sell_side_risk_ratio_30d_ema: Option<EagerVec<DateIndex, StoredF32>>,
|
||||
pub dateindex_to_sell_side_risk_ratio: Option<EagerVec<PcoVec<DateIndex, StoredF32>>>,
|
||||
pub dateindex_to_sell_side_risk_ratio_7d_ema: Option<EagerVec<PcoVec<DateIndex, StoredF32>>>,
|
||||
pub dateindex_to_sell_side_risk_ratio_30d_ema: Option<EagerVec<PcoVec<DateIndex, StoredF32>>>,
|
||||
pub indexes_to_adjusted_value_created: Option<ComputedVecsFromHeight<Dollars>>,
|
||||
pub indexes_to_adjusted_value_destroyed: Option<ComputedVecsFromHeight<Dollars>>,
|
||||
pub indexes_to_neg_realized_loss: Option<ComputedVecsFromHeight<Dollars>>,
|
||||
@@ -73,22 +73,23 @@ pub struct Vecs {
|
||||
pub indexes_to_value_destroyed: Option<ComputedVecsFromHeight<Dollars>>,
|
||||
pub indexes_to_unrealized_profit: Option<ComputedVecsFromDateIndex<Dollars>>,
|
||||
pub indexes_to_unrealized_loss: Option<ComputedVecsFromDateIndex<Dollars>>,
|
||||
pub height_to_total_unrealized_pnl: Option<EagerVec<Height, Dollars>>,
|
||||
pub height_to_total_unrealized_pnl: Option<EagerVec<PcoVec<Height, Dollars>>>,
|
||||
pub indexes_to_total_unrealized_pnl: Option<ComputedVecsFromDateIndex<Dollars>>,
|
||||
pub height_to_total_realized_pnl: Option<EagerVec<Height, Dollars>>,
|
||||
pub height_to_total_realized_pnl: Option<EagerVec<PcoVec<Height, Dollars>>>,
|
||||
pub indexes_to_total_realized_pnl: Option<ComputedVecsFromDateIndex<Dollars>>,
|
||||
pub indexes_to_min_price_paid: Option<ComputedVecsFromHeight<Dollars>>,
|
||||
pub indexes_to_max_price_paid: Option<ComputedVecsFromHeight<Dollars>>,
|
||||
pub height_to_supply_half_value: ComputedHeightValueVecs,
|
||||
pub indexes_to_supply_half: ComputedValueVecsFromDateIndex,
|
||||
pub height_to_neg_unrealized_loss: Option<EagerVec<Height, Dollars>>,
|
||||
pub height_to_neg_unrealized_loss: Option<EagerVec<PcoVec<Height, Dollars>>>,
|
||||
pub indexes_to_neg_unrealized_loss: Option<ComputedVecsFromDateIndex<Dollars>>,
|
||||
pub height_to_net_unrealized_pnl: Option<EagerVec<Height, Dollars>>,
|
||||
pub height_to_net_unrealized_pnl: Option<EagerVec<PcoVec<Height, Dollars>>>,
|
||||
pub indexes_to_net_unrealized_pnl: Option<ComputedVecsFromDateIndex<Dollars>>,
|
||||
pub height_to_unrealized_profit_rel_to_market_cap: Option<EagerVec<Height, StoredF32>>,
|
||||
pub height_to_unrealized_loss_rel_to_market_cap: Option<EagerVec<Height, StoredF32>>,
|
||||
pub height_to_neg_unrealized_loss_rel_to_market_cap: Option<EagerVec<Height, StoredF32>>,
|
||||
pub height_to_net_unrealized_pnl_rel_to_market_cap: Option<EagerVec<Height, StoredF32>>,
|
||||
pub height_to_unrealized_profit_rel_to_market_cap: Option<EagerVec<PcoVec<Height, StoredF32>>>,
|
||||
pub height_to_unrealized_loss_rel_to_market_cap: Option<EagerVec<PcoVec<Height, StoredF32>>>,
|
||||
pub height_to_neg_unrealized_loss_rel_to_market_cap:
|
||||
Option<EagerVec<PcoVec<Height, StoredF32>>>,
|
||||
pub height_to_net_unrealized_pnl_rel_to_market_cap: Option<EagerVec<PcoVec<Height, StoredF32>>>,
|
||||
pub indexes_to_unrealized_profit_rel_to_market_cap:
|
||||
Option<ComputedVecsFromDateIndex<StoredF32>>,
|
||||
pub indexes_to_unrealized_loss_rel_to_market_cap: Option<ComputedVecsFromDateIndex<StoredF32>>,
|
||||
@@ -96,10 +97,14 @@ pub struct Vecs {
|
||||
Option<ComputedVecsFromDateIndex<StoredF32>>,
|
||||
pub indexes_to_net_unrealized_pnl_rel_to_market_cap:
|
||||
Option<ComputedVecsFromDateIndex<StoredF32>>,
|
||||
pub height_to_unrealized_profit_rel_to_own_market_cap: Option<EagerVec<Height, StoredF32>>,
|
||||
pub height_to_unrealized_loss_rel_to_own_market_cap: Option<EagerVec<Height, StoredF32>>,
|
||||
pub height_to_neg_unrealized_loss_rel_to_own_market_cap: Option<EagerVec<Height, StoredF32>>,
|
||||
pub height_to_net_unrealized_pnl_rel_to_own_market_cap: Option<EagerVec<Height, StoredF32>>,
|
||||
pub height_to_unrealized_profit_rel_to_own_market_cap:
|
||||
Option<EagerVec<PcoVec<Height, StoredF32>>>,
|
||||
pub height_to_unrealized_loss_rel_to_own_market_cap:
|
||||
Option<EagerVec<PcoVec<Height, StoredF32>>>,
|
||||
pub height_to_neg_unrealized_loss_rel_to_own_market_cap:
|
||||
Option<EagerVec<PcoVec<Height, StoredF32>>>,
|
||||
pub height_to_net_unrealized_pnl_rel_to_own_market_cap:
|
||||
Option<EagerVec<PcoVec<Height, StoredF32>>>,
|
||||
pub indexes_to_unrealized_profit_rel_to_own_market_cap:
|
||||
Option<ComputedVecsFromDateIndex<StoredF32>>,
|
||||
pub indexes_to_unrealized_loss_rel_to_own_market_cap:
|
||||
@@ -109,13 +114,13 @@ pub struct Vecs {
|
||||
pub indexes_to_net_unrealized_pnl_rel_to_own_market_cap:
|
||||
Option<ComputedVecsFromDateIndex<StoredF32>>,
|
||||
pub height_to_unrealized_profit_rel_to_own_total_unrealized_pnl:
|
||||
Option<EagerVec<Height, StoredF32>>,
|
||||
Option<EagerVec<PcoVec<Height, StoredF32>>>,
|
||||
pub height_to_unrealized_loss_rel_to_own_total_unrealized_pnl:
|
||||
Option<EagerVec<Height, StoredF32>>,
|
||||
Option<EagerVec<PcoVec<Height, StoredF32>>>,
|
||||
pub height_to_neg_unrealized_loss_rel_to_own_total_unrealized_pnl:
|
||||
Option<EagerVec<Height, StoredF32>>,
|
||||
Option<EagerVec<PcoVec<Height, StoredF32>>>,
|
||||
pub height_to_net_unrealized_pnl_rel_to_own_total_unrealized_pnl:
|
||||
Option<EagerVec<Height, StoredF32>>,
|
||||
Option<EagerVec<PcoVec<Height, StoredF32>>>,
|
||||
pub indexes_to_unrealized_profit_rel_to_own_total_unrealized_pnl:
|
||||
Option<ComputedVecsFromDateIndex<StoredF32>>,
|
||||
pub indexes_to_unrealized_loss_rel_to_own_total_unrealized_pnl:
|
||||
@@ -132,13 +137,15 @@ pub struct Vecs {
|
||||
pub height_to_supply_in_profit_value: Option<ComputedHeightValueVecs>,
|
||||
pub indexes_to_supply_in_loss: Option<ComputedValueVecsFromDateIndex>,
|
||||
pub indexes_to_supply_in_profit: Option<ComputedValueVecsFromDateIndex>,
|
||||
pub height_to_supply_in_loss_rel_to_own_supply: Option<EagerVec<Height, StoredF64>>,
|
||||
pub height_to_supply_in_profit_rel_to_own_supply: Option<EagerVec<Height, StoredF64>>,
|
||||
pub height_to_supply_in_loss_rel_to_own_supply: Option<EagerVec<PcoVec<Height, StoredF64>>>,
|
||||
pub height_to_supply_in_profit_rel_to_own_supply: Option<EagerVec<PcoVec<Height, StoredF64>>>,
|
||||
pub indexes_to_supply_in_loss_rel_to_own_supply: Option<ComputedVecsFromDateIndex<StoredF64>>,
|
||||
pub indexes_to_supply_in_profit_rel_to_own_supply: Option<ComputedVecsFromDateIndex<StoredF64>>,
|
||||
pub indexes_to_supply_rel_to_circulating_supply: Option<ComputedVecsFromHeight<StoredF64>>,
|
||||
pub height_to_supply_in_loss_rel_to_circulating_supply: Option<EagerVec<Height, StoredF64>>,
|
||||
pub height_to_supply_in_profit_rel_to_circulating_supply: Option<EagerVec<Height, StoredF64>>,
|
||||
pub height_to_supply_in_loss_rel_to_circulating_supply:
|
||||
Option<EagerVec<PcoVec<Height, StoredF64>>>,
|
||||
pub height_to_supply_in_profit_rel_to_circulating_supply:
|
||||
Option<EagerVec<PcoVec<Height, StoredF64>>>,
|
||||
pub indexes_to_supply_in_loss_rel_to_circulating_supply:
|
||||
Option<ComputedVecsFromDateIndex<StoredF64>>,
|
||||
pub indexes_to_supply_in_profit_rel_to_circulating_supply:
|
||||
@@ -149,7 +156,7 @@ pub struct Vecs {
|
||||
Option<ComputedVecsFromDateIndex<StoredF32>>,
|
||||
pub indexes_to_net_realized_pnl_cumulative_30d_delta_rel_to_market_cap:
|
||||
Option<ComputedVecsFromDateIndex<StoredF32>>,
|
||||
pub dateindex_to_realized_profit_to_loss_ratio: Option<EagerVec<DateIndex, StoredF64>>,
|
||||
pub dateindex_to_realized_profit_to_loss_ratio: Option<EagerVec<PcoVec<DateIndex, StoredF64>>>,
|
||||
}
|
||||
|
||||
impl Vecs {
|
||||
@@ -157,7 +164,6 @@ impl Vecs {
|
||||
pub fn forced_import(
|
||||
db: &Database,
|
||||
cohort_name: Option<&str>,
|
||||
format: Format,
|
||||
parent_version: Version,
|
||||
indexes: &indexes::Vecs,
|
||||
price: Option<&price::Vecs>,
|
||||
@@ -174,54 +180,28 @@ impl Vecs {
|
||||
let suffix = |s: &str| cohort_name.map_or(s.to_string(), |name| format!("{name}_{s}"));
|
||||
|
||||
let dateindex_to_supply_in_profit = compute_dollars.then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("supply_in_profit"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
EagerVec::forced_import(db, &suffix("supply_in_profit"), version + Version::ZERO)
|
||||
.unwrap()
|
||||
});
|
||||
|
||||
let dateindex_to_supply_in_loss = compute_dollars.then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("supply_in_loss"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
EagerVec::forced_import(db, &suffix("supply_in_loss"), version + Version::ZERO).unwrap()
|
||||
});
|
||||
|
||||
let dateindex_to_unrealized_profit = compute_dollars.then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("unrealized_profit"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
EagerVec::forced_import(db, &suffix("unrealized_profit"), version + Version::ZERO)
|
||||
.unwrap()
|
||||
});
|
||||
|
||||
let dateindex_to_unrealized_loss = compute_dollars.then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("unrealized_loss"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
EagerVec::forced_import(db, &suffix("unrealized_loss"), version + Version::ZERO)
|
||||
.unwrap()
|
||||
});
|
||||
|
||||
Ok(Self {
|
||||
height_to_supply_in_profit: compute_dollars.then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("supply_in_profit"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
EagerVec::forced_import(db, &suffix("supply_in_profit"), version + Version::ZERO)
|
||||
.unwrap()
|
||||
}),
|
||||
indexes_to_supply_in_profit: compute_dollars.then(|| {
|
||||
ComputedValueVecsFromDateIndex::forced_import(
|
||||
@@ -240,13 +220,8 @@ impl Vecs {
|
||||
}),
|
||||
dateindex_to_supply_in_profit,
|
||||
height_to_supply_in_loss: compute_dollars.then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("supply_in_loss"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
EagerVec::forced_import(db, &suffix("supply_in_loss"), version + Version::ZERO)
|
||||
.unwrap()
|
||||
}),
|
||||
indexes_to_supply_in_loss: compute_dollars.then(|| {
|
||||
ComputedValueVecsFromDateIndex::forced_import(
|
||||
@@ -265,13 +240,8 @@ impl Vecs {
|
||||
}),
|
||||
dateindex_to_supply_in_loss,
|
||||
height_to_unrealized_profit: compute_dollars.then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("unrealized_profit"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
EagerVec::forced_import(db, &suffix("unrealized_profit"), version + Version::ZERO)
|
||||
.unwrap()
|
||||
}),
|
||||
indexes_to_unrealized_profit: compute_dollars.then(|| {
|
||||
ComputedVecsFromDateIndex::forced_import(
|
||||
@@ -289,31 +259,16 @@ impl Vecs {
|
||||
}),
|
||||
dateindex_to_unrealized_profit,
|
||||
height_to_unrealized_loss: compute_dollars.then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("unrealized_loss"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
EagerVec::forced_import(db, &suffix("unrealized_loss"), version + Version::ZERO)
|
||||
.unwrap()
|
||||
}),
|
||||
height_to_min_price_paid: compute_dollars.then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("min_price_paid"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
EagerVec::forced_import(db, &suffix("min_price_paid"), version + Version::ZERO)
|
||||
.unwrap()
|
||||
}),
|
||||
height_to_max_price_paid: compute_dollars.then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("max_price_paid"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
EagerVec::forced_import(db, &suffix("max_price_paid"), version + Version::ZERO)
|
||||
.unwrap()
|
||||
}),
|
||||
indexes_to_unrealized_loss: compute_dollars.then(|| {
|
||||
ComputedVecsFromDateIndex::forced_import(
|
||||
@@ -330,7 +285,7 @@ impl Vecs {
|
||||
.unwrap()
|
||||
}),
|
||||
height_to_total_unrealized_pnl: compute_dollars.then(|| {
|
||||
EagerVec::forced_import_compressed(
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("total_unrealized_pnl"),
|
||||
version + Version::ZERO,
|
||||
@@ -349,12 +304,8 @@ impl Vecs {
|
||||
.unwrap()
|
||||
}),
|
||||
height_to_total_realized_pnl: compute_dollars.then(|| {
|
||||
EagerVec::forced_import_compressed(
|
||||
db,
|
||||
&suffix("total_realized_pnl"),
|
||||
version + Version::ZERO,
|
||||
)
|
||||
.unwrap()
|
||||
EagerVec::forced_import(db, &suffix("total_realized_pnl"), version + Version::ZERO)
|
||||
.unwrap()
|
||||
}),
|
||||
indexes_to_total_realized_pnl: compute_dollars.then(|| {
|
||||
ComputedVecsFromDateIndex::forced_import(
|
||||
@@ -369,13 +320,8 @@ impl Vecs {
|
||||
}),
|
||||
dateindex_to_unrealized_loss,
|
||||
height_to_realized_cap: compute_dollars.then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("realized_cap"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
EagerVec::forced_import(db, &suffix("realized_cap"), version + Version::ZERO)
|
||||
.unwrap()
|
||||
}),
|
||||
indexes_to_realized_cap: compute_dollars.then(|| {
|
||||
ComputedVecsFromHeight::forced_import(
|
||||
@@ -414,14 +360,12 @@ impl Vecs {
|
||||
db,
|
||||
&suffix("supply"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
height_to_supply_value: ComputedHeightValueVecs::forced_import(
|
||||
db,
|
||||
&suffix("supply"),
|
||||
Source::None,
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
compute_dollars,
|
||||
)?,
|
||||
indexes_to_supply: ComputedValueVecsFromDateIndex::forced_import(
|
||||
@@ -437,7 +381,6 @@ impl Vecs {
|
||||
db,
|
||||
&suffix("utxo_count"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
indexes_to_utxo_count: ComputedVecsFromHeight::forced_import(
|
||||
db,
|
||||
@@ -483,13 +426,8 @@ impl Vecs {
|
||||
},
|
||||
),
|
||||
height_to_realized_profit: compute_dollars.then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("realized_profit"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
EagerVec::forced_import(db, &suffix("realized_profit"), version + Version::ZERO)
|
||||
.unwrap()
|
||||
}),
|
||||
indexes_to_realized_profit: compute_dollars.then(|| {
|
||||
ComputedVecsFromHeight::forced_import(
|
||||
@@ -503,13 +441,8 @@ impl Vecs {
|
||||
.unwrap()
|
||||
}),
|
||||
height_to_realized_loss: compute_dollars.then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("realized_loss"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
EagerVec::forced_import(db, &suffix("realized_loss"), version + Version::ZERO)
|
||||
.unwrap()
|
||||
}),
|
||||
indexes_to_realized_loss: compute_dollars.then(|| {
|
||||
ComputedVecsFromHeight::forced_import(
|
||||
@@ -534,13 +467,8 @@ impl Vecs {
|
||||
.unwrap()
|
||||
}),
|
||||
height_to_value_created: compute_dollars.then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("value_created"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
EagerVec::forced_import(db, &suffix("value_created"), version + Version::ZERO)
|
||||
.unwrap()
|
||||
}),
|
||||
indexes_to_value_created: compute_dollars.then(|| {
|
||||
ComputedVecsFromHeight::forced_import(
|
||||
@@ -569,7 +497,6 @@ impl Vecs {
|
||||
db,
|
||||
&suffix("adjusted_value_created"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
@@ -585,13 +512,8 @@ impl Vecs {
|
||||
.unwrap()
|
||||
}),
|
||||
height_to_value_destroyed: compute_dollars.then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("value_destroyed"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
EagerVec::forced_import(db, &suffix("value_destroyed"), version + Version::ZERO)
|
||||
.unwrap()
|
||||
}),
|
||||
indexes_to_value_destroyed: compute_dollars.then(|| {
|
||||
ComputedVecsFromHeight::forced_import(
|
||||
@@ -609,7 +531,6 @@ impl Vecs {
|
||||
db,
|
||||
&suffix("adjusted_value_destroyed"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
@@ -647,20 +568,14 @@ impl Vecs {
|
||||
.unwrap()
|
||||
}),
|
||||
dateindex_to_sell_side_risk_ratio: compute_dollars.then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("sell_side_risk_ratio"),
|
||||
version + Version::ONE,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
EagerVec::forced_import(db, &suffix("sell_side_risk_ratio"), version + Version::ONE)
|
||||
.unwrap()
|
||||
}),
|
||||
dateindex_to_sell_side_risk_ratio_7d_ema: compute_dollars.then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("sell_side_risk_ratio_7d_ema"),
|
||||
version + Version::ONE,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
@@ -669,46 +584,32 @@ impl Vecs {
|
||||
db,
|
||||
&suffix("sell_side_risk_ratio_30d_ema"),
|
||||
version + Version::ONE,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
dateindex_to_sopr: compute_dollars.then(|| {
|
||||
EagerVec::forced_import(db, &suffix("sopr"), version + Version::ONE, format)
|
||||
.unwrap()
|
||||
EagerVec::forced_import(db, &suffix("sopr"), version + Version::ONE).unwrap()
|
||||
}),
|
||||
dateindex_to_sopr_7d_ema: compute_dollars.then(|| {
|
||||
EagerVec::forced_import(db, &suffix("sopr_7d_ema"), version + Version::ONE, format)
|
||||
.unwrap()
|
||||
EagerVec::forced_import(db, &suffix("sopr_7d_ema"), version + Version::ONE).unwrap()
|
||||
}),
|
||||
dateindex_to_sopr_30d_ema: compute_dollars.then(|| {
|
||||
EagerVec::forced_import(db, &suffix("sopr_30d_ema"), version + Version::ONE, format)
|
||||
EagerVec::forced_import(db, &suffix("sopr_30d_ema"), version + Version::ONE)
|
||||
.unwrap()
|
||||
}),
|
||||
dateindex_to_adjusted_sopr: (compute_dollars && compute_adjusted).then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("adjusted_sopr"),
|
||||
version + Version::ONE,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
EagerVec::forced_import(db, &suffix("adjusted_sopr"), version + Version::ONE)
|
||||
.unwrap()
|
||||
}),
|
||||
dateindex_to_adjusted_sopr_7d_ema: (compute_dollars && compute_adjusted).then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("adjusted_sopr_7d_ema"),
|
||||
version + Version::ONE,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
EagerVec::forced_import(db, &suffix("adjusted_sopr_7d_ema"), version + Version::ONE)
|
||||
.unwrap()
|
||||
}),
|
||||
dateindex_to_adjusted_sopr_30d_ema: (compute_dollars && compute_adjusted).then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("adjusted_sopr_30d_ema"),
|
||||
version + Version::ONE,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
@@ -717,7 +618,6 @@ impl Vecs {
|
||||
&suffix("supply_half"),
|
||||
Source::Compute,
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
compute_dollars,
|
||||
)?,
|
||||
indexes_to_supply_half: ComputedValueVecsFromDateIndex::forced_import(
|
||||
@@ -730,13 +630,8 @@ impl Vecs {
|
||||
indexes,
|
||||
)?,
|
||||
height_to_neg_unrealized_loss: compute_dollars.then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("neg_unrealized_loss"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
EagerVec::forced_import(db, &suffix("neg_unrealized_loss"), version + Version::ZERO)
|
||||
.unwrap()
|
||||
}),
|
||||
indexes_to_neg_unrealized_loss: compute_dollars.then(|| {
|
||||
ComputedVecsFromDateIndex::forced_import(
|
||||
@@ -750,13 +645,8 @@ impl Vecs {
|
||||
.unwrap()
|
||||
}),
|
||||
height_to_net_unrealized_pnl: compute_dollars.then(|| {
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("net_unrealized_pnl"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
EagerVec::forced_import(db, &suffix("net_unrealized_pnl"), version + Version::ZERO)
|
||||
.unwrap()
|
||||
}),
|
||||
indexes_to_net_unrealized_pnl: compute_dollars.then(|| {
|
||||
ComputedVecsFromDateIndex::forced_import(
|
||||
@@ -774,7 +664,6 @@ impl Vecs {
|
||||
db,
|
||||
&suffix("unrealized_profit_rel_to_market_cap"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
@@ -783,7 +672,6 @@ impl Vecs {
|
||||
db,
|
||||
&suffix("unrealized_loss_rel_to_market_cap"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
@@ -792,7 +680,6 @@ impl Vecs {
|
||||
db,
|
||||
&suffix("neg_unrealized_loss_rel_to_market_cap"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
@@ -801,7 +688,6 @@ impl Vecs {
|
||||
db,
|
||||
&suffix("net_unrealized_pnl_rel_to_market_cap"),
|
||||
version + Version::ONE,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
@@ -857,7 +743,6 @@ impl Vecs {
|
||||
db,
|
||||
&suffix("unrealized_profit_rel_to_own_market_cap"),
|
||||
version + Version::ONE,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
@@ -869,7 +754,6 @@ impl Vecs {
|
||||
db,
|
||||
&suffix("unrealized_loss_rel_to_own_market_cap"),
|
||||
version + Version::ONE,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
@@ -881,7 +765,6 @@ impl Vecs {
|
||||
db,
|
||||
&suffix("neg_unrealized_loss_rel_to_own_market_cap"),
|
||||
version + Version::ONE,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
@@ -893,7 +776,6 @@ impl Vecs {
|
||||
db,
|
||||
&suffix("net_unrealized_pnl_rel_to_own_market_cap"),
|
||||
version + Version::TWO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
@@ -960,7 +842,6 @@ impl Vecs {
|
||||
db,
|
||||
&suffix("unrealized_profit_rel_to_own_total_unrealized_pnl"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
@@ -971,7 +852,6 @@ impl Vecs {
|
||||
db,
|
||||
&suffix("unrealized_loss_rel_to_own_total_unrealized_pnl"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
@@ -982,7 +862,6 @@ impl Vecs {
|
||||
db,
|
||||
&suffix("neg_unrealized_loss_rel_to_own_total_unrealized_pnl"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
@@ -993,7 +872,6 @@ impl Vecs {
|
||||
db,
|
||||
&suffix("net_unrealized_pnl_rel_to_own_total_unrealized_pnl"),
|
||||
version + Version::ONE,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
@@ -1088,7 +966,6 @@ impl Vecs {
|
||||
&suffix("supply_in_loss"),
|
||||
Source::None,
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
compute_dollars,
|
||||
)
|
||||
.unwrap()
|
||||
@@ -1099,7 +976,6 @@ impl Vecs {
|
||||
&suffix("supply_in_profit"),
|
||||
Source::None,
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
compute_dollars,
|
||||
)
|
||||
.unwrap()
|
||||
@@ -1109,7 +985,6 @@ impl Vecs {
|
||||
db,
|
||||
&suffix("supply_in_loss_rel_to_own_supply"),
|
||||
version + Version::ONE,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
@@ -1118,7 +993,6 @@ impl Vecs {
|
||||
db,
|
||||
&suffix("supply_in_profit_rel_to_own_supply"),
|
||||
version + Version::ONE,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
@@ -1162,7 +1036,6 @@ impl Vecs {
|
||||
db,
|
||||
&suffix("supply_in_loss_rel_to_circulating_supply"),
|
||||
version + Version::ONE,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
@@ -1173,7 +1046,6 @@ impl Vecs {
|
||||
db,
|
||||
&suffix("supply_in_profit_rel_to_circulating_supply"),
|
||||
version + Version::ONE,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
@@ -1207,13 +1079,11 @@ impl Vecs {
|
||||
db,
|
||||
&suffix("satblocks_destroyed"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
height_to_satdays_destroyed: EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("satdays_destroyed"),
|
||||
version + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
indexes_to_coinblocks_destroyed: ComputedVecsFromHeight::forced_import(
|
||||
db,
|
||||
@@ -1267,7 +1137,7 @@ impl Vecs {
|
||||
.unwrap()
|
||||
}),
|
||||
dateindex_to_realized_profit_to_loss_ratio: (compute_dollars && extended).then(|| {
|
||||
EagerVec::forced_import_compressed(
|
||||
EagerVec::forced_import(
|
||||
db,
|
||||
&suffix("realized_profit_to_loss_ratio"),
|
||||
version + Version::ONE,
|
||||
|
||||
@@ -16,9 +16,9 @@ use rayon::prelude::*;
|
||||
use rustc_hash::FxHashMap;
|
||||
use smallvec::SmallVec;
|
||||
use vecdb::{
|
||||
AnyStoredVec, AnyVec, BoxedVecIterator, CollectableVec, Database, EagerVec, Exit, Format,
|
||||
GenericStoredVec, ImportOptions, IterableCloneableVec, IterableVec, LazyVecFrom1, PAGE_SIZE,
|
||||
RawVec, Reader, Stamp, TypedVecIterator, VecIndex,
|
||||
AnyStoredVec, AnyVec, BoxedVecIterator, BytesVec, CollectableVec, Database, EagerVec, Exit,
|
||||
GenericStoredVec, ImportOptions, Importable, IterableCloneableVec, IterableVec, LazyVecFrom1,
|
||||
PAGE_SIZE, PcoVec, Reader, Stamp, TypedVecIterator, VecIndex,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@@ -56,14 +56,14 @@ pub struct Vecs {
|
||||
// ---
|
||||
// States
|
||||
// ---
|
||||
pub chain_state: RawVec<Height, SupplyState>,
|
||||
pub chain_state: BytesVec<Height, SupplyState>,
|
||||
pub any_address_indexes: AnyAddressIndexes,
|
||||
pub addresses_data: AddressesData,
|
||||
pub utxo_cohorts: utxo_cohorts::Vecs,
|
||||
pub address_cohorts: address_cohorts::Vecs,
|
||||
|
||||
pub height_to_unspendable_supply: EagerVec<Height, Sats>,
|
||||
pub height_to_opreturn_supply: EagerVec<Height, Sats>,
|
||||
pub height_to_unspendable_supply: EagerVec<PcoVec<Height, Sats>>,
|
||||
pub height_to_opreturn_supply: EagerVec<PcoVec<Height, Sats>>,
|
||||
pub addresstype_to_height_to_addr_count: AddressTypeToHeightToAddressCount,
|
||||
pub addresstype_to_height_to_empty_addr_count: AddressTypeToHeightToAddressCount,
|
||||
|
||||
@@ -90,7 +90,6 @@ impl Vecs {
|
||||
pub fn forced_import(
|
||||
parent: &Path,
|
||||
version: Version,
|
||||
format: Format,
|
||||
indexes: &indexes::Vecs,
|
||||
price: Option<&price::Vecs>,
|
||||
) -> Result<Self> {
|
||||
@@ -104,13 +103,13 @@ impl Vecs {
|
||||
let compute_dollars = price.is_some();
|
||||
|
||||
let utxo_cohorts =
|
||||
utxo_cohorts::Vecs::forced_import(&db, version, format, indexes, price, &states_path)?;
|
||||
utxo_cohorts::Vecs::forced_import(&db, version, indexes, price, &states_path)?;
|
||||
|
||||
let loadedaddressindex_to_loadedaddressdata = RawVec::forced_import_with(
|
||||
let loadedaddressindex_to_loadedaddressdata = BytesVec::forced_import_with(
|
||||
ImportOptions::new(&db, "loadedaddressdata", version + VERSION + Version::ZERO)
|
||||
.with_saved_stamped_changes(SAVED_STAMPED_CHANGES),
|
||||
)?;
|
||||
let emptyaddressindex_to_emptyaddressdata = RawVec::forced_import_with(
|
||||
let emptyaddressindex_to_emptyaddressdata = BytesVec::forced_import_with(
|
||||
ImportOptions::new(&db, "emptyaddressdata", version + VERSION + Version::ZERO)
|
||||
.with_saved_stamped_changes(SAVED_STAMPED_CHANGES),
|
||||
)?;
|
||||
@@ -128,12 +127,12 @@ impl Vecs {
|
||||
);
|
||||
|
||||
let this = Self {
|
||||
chain_state: RawVec::forced_import_with(
|
||||
chain_state: BytesVec::forced_import_with(
|
||||
ImportOptions::new(&db, "chain", version + VERSION + Version::ZERO)
|
||||
.with_saved_stamped_changes(SAVED_STAMPED_CHANGES),
|
||||
)?,
|
||||
|
||||
height_to_unspendable_supply: EagerVec::forced_import_compressed(
|
||||
height_to_unspendable_supply: EagerVec::forced_import(
|
||||
&db,
|
||||
"unspendable_supply",
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -147,7 +146,7 @@ impl Vecs {
|
||||
compute_dollars,
|
||||
indexes,
|
||||
)?,
|
||||
height_to_opreturn_supply: EagerVec::forced_import_compressed(
|
||||
height_to_opreturn_supply: EagerVec::forced_import(
|
||||
&db,
|
||||
"opreturn_supply",
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -205,42 +204,42 @@ impl Vecs {
|
||||
}),
|
||||
addresstype_to_height_to_addr_count: AddressTypeToHeightToAddressCount::from(
|
||||
ByAddressType {
|
||||
p2pk65: EagerVec::forced_import_compressed(
|
||||
p2pk65: EagerVec::forced_import(
|
||||
&db,
|
||||
"p2pk65_addr_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
p2pk33: EagerVec::forced_import_compressed(
|
||||
p2pk33: EagerVec::forced_import(
|
||||
&db,
|
||||
"p2pk33_addr_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
p2pkh: EagerVec::forced_import_compressed(
|
||||
p2pkh: EagerVec::forced_import(
|
||||
&db,
|
||||
"p2pkh_addr_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
p2sh: EagerVec::forced_import_compressed(
|
||||
p2sh: EagerVec::forced_import(
|
||||
&db,
|
||||
"p2sh_addr_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
p2wpkh: EagerVec::forced_import_compressed(
|
||||
p2wpkh: EagerVec::forced_import(
|
||||
&db,
|
||||
"p2wpkh_addr_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
p2wsh: EagerVec::forced_import_compressed(
|
||||
p2wsh: EagerVec::forced_import(
|
||||
&db,
|
||||
"p2wsh_addr_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
p2tr: EagerVec::forced_import_compressed(
|
||||
p2tr: EagerVec::forced_import(
|
||||
&db,
|
||||
"p2tr_addr_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
p2a: EagerVec::forced_import_compressed(
|
||||
p2a: EagerVec::forced_import(
|
||||
&db,
|
||||
"p2a_addr_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -249,42 +248,42 @@ impl Vecs {
|
||||
),
|
||||
addresstype_to_height_to_empty_addr_count: AddressTypeToHeightToAddressCount::from(
|
||||
ByAddressType {
|
||||
p2pk65: EagerVec::forced_import_compressed(
|
||||
p2pk65: EagerVec::forced_import(
|
||||
&db,
|
||||
"p2pk65_empty_addr_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
p2pk33: EagerVec::forced_import_compressed(
|
||||
p2pk33: EagerVec::forced_import(
|
||||
&db,
|
||||
"p2pk33_empty_addr_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
p2pkh: EagerVec::forced_import_compressed(
|
||||
p2pkh: EagerVec::forced_import(
|
||||
&db,
|
||||
"p2pkh_empty_addr_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
p2sh: EagerVec::forced_import_compressed(
|
||||
p2sh: EagerVec::forced_import(
|
||||
&db,
|
||||
"p2sh_empty_addr_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
p2wpkh: EagerVec::forced_import_compressed(
|
||||
p2wpkh: EagerVec::forced_import(
|
||||
&db,
|
||||
"p2wpkh_empty_addr_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
p2wsh: EagerVec::forced_import_compressed(
|
||||
p2wsh: EagerVec::forced_import(
|
||||
&db,
|
||||
"p2wsh_empty_addr_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
p2tr: EagerVec::forced_import_compressed(
|
||||
p2tr: EagerVec::forced_import(
|
||||
&db,
|
||||
"p2tr_empty_addr_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
p2a: EagerVec::forced_import_compressed(
|
||||
p2a: EagerVec::forced_import(
|
||||
&db,
|
||||
"p2a_empty_addr_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -431,42 +430,41 @@ impl Vecs {
|
||||
address_cohorts: address_cohorts::Vecs::forced_import(
|
||||
&db,
|
||||
version,
|
||||
format,
|
||||
indexes,
|
||||
price,
|
||||
&states_path,
|
||||
)?,
|
||||
|
||||
any_address_indexes: AnyAddressIndexes {
|
||||
p2a: RawVec::forced_import_with(
|
||||
p2a: BytesVec::forced_import_with(
|
||||
ImportOptions::new(&db, "anyaddressindex", version + VERSION + Version::ZERO)
|
||||
.with_saved_stamped_changes(SAVED_STAMPED_CHANGES),
|
||||
)?,
|
||||
p2pk33: RawVec::forced_import_with(
|
||||
p2pk33: BytesVec::forced_import_with(
|
||||
ImportOptions::new(&db, "anyaddressindex", version + VERSION + Version::ZERO)
|
||||
.with_saved_stamped_changes(SAVED_STAMPED_CHANGES),
|
||||
)?,
|
||||
p2pk65: RawVec::forced_import_with(
|
||||
p2pk65: BytesVec::forced_import_with(
|
||||
ImportOptions::new(&db, "anyaddressindex", version + VERSION + Version::ZERO)
|
||||
.with_saved_stamped_changes(SAVED_STAMPED_CHANGES),
|
||||
)?,
|
||||
p2pkh: RawVec::forced_import_with(
|
||||
p2pkh: BytesVec::forced_import_with(
|
||||
ImportOptions::new(&db, "anyaddressindex", version + VERSION + Version::ZERO)
|
||||
.with_saved_stamped_changes(SAVED_STAMPED_CHANGES),
|
||||
)?,
|
||||
p2sh: RawVec::forced_import_with(
|
||||
p2sh: BytesVec::forced_import_with(
|
||||
ImportOptions::new(&db, "anyaddressindex", version + VERSION + Version::ZERO)
|
||||
.with_saved_stamped_changes(SAVED_STAMPED_CHANGES),
|
||||
)?,
|
||||
p2tr: RawVec::forced_import_with(
|
||||
p2tr: BytesVec::forced_import_with(
|
||||
ImportOptions::new(&db, "anyaddressindex", version + VERSION + Version::ZERO)
|
||||
.with_saved_stamped_changes(SAVED_STAMPED_CHANGES),
|
||||
)?,
|
||||
p2wpkh: RawVec::forced_import_with(
|
||||
p2wpkh: BytesVec::forced_import_with(
|
||||
ImportOptions::new(&db, "anyaddressindex", version + VERSION + Version::ZERO)
|
||||
.with_saved_stamped_changes(SAVED_STAMPED_CHANGES),
|
||||
)?,
|
||||
p2wsh: RawVec::forced_import_with(
|
||||
p2wsh: BytesVec::forced_import_with(
|
||||
ImportOptions::new(&db, "anyaddressindex", version + VERSION + Version::ZERO)
|
||||
.with_saved_stamped_changes(SAVED_STAMPED_CHANGES),
|
||||
)?,
|
||||
@@ -482,7 +480,7 @@ impl Vecs {
|
||||
};
|
||||
|
||||
this.db.retain_regions(
|
||||
this.iter_any_writable()
|
||||
this.iter_any_exportable()
|
||||
.flat_map(|v| v.region_names())
|
||||
.collect(),
|
||||
)?;
|
||||
@@ -1518,9 +1516,7 @@ impl Vecs {
|
||||
|
||||
let loadedaddressdata = addresses_data
|
||||
.loaded
|
||||
.get_or_read(loadedaddressindex, reader)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
.get_pushed_or_read_unwrap(loadedaddressindex, reader);
|
||||
|
||||
WithAddressDataSource::FromLoadedAddressDataVec((
|
||||
loadedaddressindex,
|
||||
@@ -1532,9 +1528,7 @@ impl Vecs {
|
||||
|
||||
let emptyaddressdata = addresses_data
|
||||
.empty
|
||||
.get_or_read(emtpyaddressindex, reader)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
.get_pushed_or_read_unwrap(emtpyaddressindex, reader);
|
||||
|
||||
WithAddressDataSource::FromEmptyAddressDataVec((
|
||||
emtpyaddressindex,
|
||||
@@ -1923,14 +1917,14 @@ impl HeightToAddressTypeToVec<(TypeIndex, Sats)> {
|
||||
|
||||
#[derive(Clone, Traversable)]
|
||||
pub struct AnyAddressIndexes {
|
||||
pub p2pk33: RawVec<P2PK33AddressIndex, AnyAddressIndex>,
|
||||
pub p2pk65: RawVec<P2PK65AddressIndex, AnyAddressIndex>,
|
||||
pub p2pkh: RawVec<P2PKHAddressIndex, AnyAddressIndex>,
|
||||
pub p2sh: RawVec<P2SHAddressIndex, AnyAddressIndex>,
|
||||
pub p2tr: RawVec<P2TRAddressIndex, AnyAddressIndex>,
|
||||
pub p2wpkh: RawVec<P2WPKHAddressIndex, AnyAddressIndex>,
|
||||
pub p2wsh: RawVec<P2WSHAddressIndex, AnyAddressIndex>,
|
||||
pub p2a: RawVec<P2AAddressIndex, AnyAddressIndex>,
|
||||
pub p2pk33: BytesVec<P2PK33AddressIndex, AnyAddressIndex>,
|
||||
pub p2pk65: BytesVec<P2PK65AddressIndex, AnyAddressIndex>,
|
||||
pub p2pkh: BytesVec<P2PKHAddressIndex, AnyAddressIndex>,
|
||||
pub p2sh: BytesVec<P2SHAddressIndex, AnyAddressIndex>,
|
||||
pub p2tr: BytesVec<P2TRAddressIndex, AnyAddressIndex>,
|
||||
pub p2wpkh: BytesVec<P2WPKHAddressIndex, AnyAddressIndex>,
|
||||
pub p2wsh: BytesVec<P2WSHAddressIndex, AnyAddressIndex>,
|
||||
pub p2a: BytesVec<P2AAddressIndex, AnyAddressIndex>,
|
||||
}
|
||||
|
||||
impl AnyAddressIndexes {
|
||||
@@ -1975,20 +1969,35 @@ impl AnyAddressIndexes {
|
||||
&self,
|
||||
address_type: OutputType,
|
||||
typeindex: TypeIndex,
|
||||
reader: &Reader<'static>,
|
||||
reader: &Reader,
|
||||
) -> AnyAddressIndex {
|
||||
let result = match address_type {
|
||||
OutputType::P2PK33 => self.p2pk33.get_or_read(typeindex.into(), reader),
|
||||
OutputType::P2PK65 => self.p2pk65.get_or_read(typeindex.into(), reader),
|
||||
OutputType::P2PKH => self.p2pkh.get_or_read(typeindex.into(), reader),
|
||||
OutputType::P2SH => self.p2sh.get_or_read(typeindex.into(), reader),
|
||||
OutputType::P2TR => self.p2tr.get_or_read(typeindex.into(), reader),
|
||||
OutputType::P2WPKH => self.p2wpkh.get_or_read(typeindex.into(), reader),
|
||||
OutputType::P2WSH => self.p2wsh.get_or_read(typeindex.into(), reader),
|
||||
OutputType::P2A => self.p2a.get_or_read(typeindex.into(), reader),
|
||||
match address_type {
|
||||
OutputType::P2PK33 => self
|
||||
.p2pk33
|
||||
.get_pushed_or_read_at_unwrap(typeindex.into(), reader),
|
||||
OutputType::P2PK65 => self
|
||||
.p2pk65
|
||||
.get_pushed_or_read_at_unwrap(typeindex.into(), reader),
|
||||
OutputType::P2PKH => self
|
||||
.p2pkh
|
||||
.get_pushed_or_read_at_unwrap(typeindex.into(), reader),
|
||||
OutputType::P2SH => self
|
||||
.p2sh
|
||||
.get_pushed_or_read_at_unwrap(typeindex.into(), reader),
|
||||
OutputType::P2TR => self
|
||||
.p2tr
|
||||
.get_pushed_or_read_at_unwrap(typeindex.into(), reader),
|
||||
OutputType::P2WPKH => self
|
||||
.p2wpkh
|
||||
.get_pushed_or_read_at_unwrap(typeindex.into(), reader),
|
||||
OutputType::P2WSH => self
|
||||
.p2wsh
|
||||
.get_pushed_or_read_at_unwrap(typeindex.into(), reader),
|
||||
OutputType::P2A => self
|
||||
.p2a
|
||||
.get_pushed_or_read_at_unwrap(typeindex.into(), reader),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
result.unwrap().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
fn update_or_push(
|
||||
@@ -2040,8 +2049,8 @@ impl AnyAddressIndexes {
|
||||
|
||||
#[derive(Clone, Traversable)]
|
||||
pub struct AddressesData {
|
||||
pub loaded: RawVec<LoadedAddressIndex, LoadedAddressData>,
|
||||
pub empty: RawVec<EmptyAddressIndex, EmptyAddressData>,
|
||||
pub loaded: BytesVec<LoadedAddressIndex, LoadedAddressData>,
|
||||
pub empty: BytesVec<EmptyAddressIndex, EmptyAddressData>,
|
||||
}
|
||||
|
||||
impl AddressesData {
|
||||
@@ -2073,16 +2082,16 @@ impl AddressesData {
|
||||
}
|
||||
}
|
||||
|
||||
struct IndexerReaders<'a> {
|
||||
txinindex_to_outpoint: Reader<'a>,
|
||||
txindex_to_first_txoutindex: Reader<'a>,
|
||||
txoutindex_to_value: Reader<'a>,
|
||||
txoutindex_to_outputtype: Reader<'a>,
|
||||
txoutindex_to_typeindex: Reader<'a>,
|
||||
struct IndexerReaders {
|
||||
txinindex_to_outpoint: Reader,
|
||||
txindex_to_first_txoutindex: Reader,
|
||||
txoutindex_to_value: Reader,
|
||||
txoutindex_to_outputtype: Reader,
|
||||
txoutindex_to_typeindex: Reader,
|
||||
}
|
||||
|
||||
impl<'a> IndexerReaders<'a> {
|
||||
fn new(indexer: &'a Indexer) -> Self {
|
||||
impl IndexerReaders {
|
||||
fn new(indexer: &Indexer) -> Self {
|
||||
Self {
|
||||
txinindex_to_outpoint: indexer.vecs.txinindex_to_outpoint.create_reader(),
|
||||
txindex_to_first_txoutindex: indexer.vecs.txindex_to_first_txoutindex.create_reader(),
|
||||
@@ -2094,31 +2103,31 @@ impl<'a> IndexerReaders<'a> {
|
||||
}
|
||||
|
||||
struct VecsReaders {
|
||||
addresstypeindex_to_anyaddressindex: ByAddressType<Reader<'static>>,
|
||||
anyaddressindex_to_anyaddressdata: ByAnyAddress<Reader<'static>>,
|
||||
addresstypeindex_to_anyaddressindex: ByAddressType<Reader>,
|
||||
anyaddressindex_to_anyaddressdata: ByAnyAddress<Reader>,
|
||||
}
|
||||
|
||||
impl VecsReaders {
|
||||
fn new(vecs: &Vecs) -> Self {
|
||||
Self {
|
||||
addresstypeindex_to_anyaddressindex: ByAddressType {
|
||||
p2pk33: vecs.any_address_indexes.p2pk33.create_static_reader(),
|
||||
p2pk65: vecs.any_address_indexes.p2pk65.create_static_reader(),
|
||||
p2pkh: vecs.any_address_indexes.p2pkh.create_static_reader(),
|
||||
p2sh: vecs.any_address_indexes.p2sh.create_static_reader(),
|
||||
p2tr: vecs.any_address_indexes.p2tr.create_static_reader(),
|
||||
p2wpkh: vecs.any_address_indexes.p2wpkh.create_static_reader(),
|
||||
p2wsh: vecs.any_address_indexes.p2wsh.create_static_reader(),
|
||||
p2a: vecs.any_address_indexes.p2a.create_static_reader(),
|
||||
p2pk33: vecs.any_address_indexes.p2pk33.create_reader(),
|
||||
p2pk65: vecs.any_address_indexes.p2pk65.create_reader(),
|
||||
p2pkh: vecs.any_address_indexes.p2pkh.create_reader(),
|
||||
p2sh: vecs.any_address_indexes.p2sh.create_reader(),
|
||||
p2tr: vecs.any_address_indexes.p2tr.create_reader(),
|
||||
p2wpkh: vecs.any_address_indexes.p2wpkh.create_reader(),
|
||||
p2wsh: vecs.any_address_indexes.p2wsh.create_reader(),
|
||||
p2a: vecs.any_address_indexes.p2a.create_reader(),
|
||||
},
|
||||
anyaddressindex_to_anyaddressdata: ByAnyAddress {
|
||||
loaded: vecs.addresses_data.loaded.create_static_reader(),
|
||||
empty: vecs.addresses_data.empty.create_static_reader(),
|
||||
loaded: vecs.addresses_data.loaded.create_reader(),
|
||||
empty: vecs.addresses_data.empty.create_reader(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn get_anyaddressindex_reader(&self, address_type: OutputType) -> &Reader<'static> {
|
||||
fn get_anyaddressindex_reader(&self, address_type: OutputType) -> &Reader {
|
||||
self.addresstypeindex_to_anyaddressindex
|
||||
.get_unwrap(address_type)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::{ops::Deref, path::Path};
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Bitcoin, DateIndex, Dollars, Height, Version};
|
||||
use vecdb::{Database, Exit, Format, IterableVec};
|
||||
use vecdb::{Database, Exit, IterableVec};
|
||||
|
||||
use crate::{
|
||||
Indexes, UTXOCohortState, indexes, price,
|
||||
@@ -29,7 +29,6 @@ impl Vecs {
|
||||
pub fn forced_import(
|
||||
db: &Database,
|
||||
cohort_name: Option<&str>,
|
||||
format: Format,
|
||||
version: Version,
|
||||
indexes: &indexes::Vecs,
|
||||
price: Option<&price::Vecs>,
|
||||
@@ -54,7 +53,6 @@ impl Vecs {
|
||||
inner: common::Vecs::forced_import(
|
||||
db,
|
||||
cohort_name,
|
||||
format,
|
||||
version,
|
||||
indexes,
|
||||
price,
|
||||
|
||||
@@ -11,7 +11,7 @@ use brk_types::{
|
||||
};
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use rustc_hash::FxHashMap;
|
||||
use vecdb::{Database, Exit, Format, IterableVec, VecIndex};
|
||||
use vecdb::{Database, Exit, IterableVec, VecIndex};
|
||||
|
||||
use crate::{
|
||||
Indexes, indexes, price,
|
||||
@@ -30,7 +30,6 @@ impl Vecs {
|
||||
pub fn forced_import(
|
||||
db: &Database,
|
||||
version: Version,
|
||||
format: Format,
|
||||
indexes: &indexes::Vecs,
|
||||
price: Option<&price::Vecs>,
|
||||
states_path: &Path,
|
||||
@@ -40,7 +39,6 @@ impl Vecs {
|
||||
all: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
None,
|
||||
format,
|
||||
version + VERSION + Version::ONE,
|
||||
indexes,
|
||||
price,
|
||||
@@ -53,7 +51,6 @@ impl Vecs {
|
||||
short: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("sth"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -65,7 +62,6 @@ impl Vecs {
|
||||
long: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("lth"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -79,7 +75,6 @@ impl Vecs {
|
||||
_0: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("epoch_0"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -91,7 +86,6 @@ impl Vecs {
|
||||
_1: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("epoch_1"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -103,7 +97,6 @@ impl Vecs {
|
||||
_2: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("epoch_2"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -115,7 +108,6 @@ impl Vecs {
|
||||
_3: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("epoch_3"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -127,7 +119,6 @@ impl Vecs {
|
||||
_4: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("epoch_4"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -141,7 +132,6 @@ impl Vecs {
|
||||
p2pk65: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("p2pk65"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -153,7 +143,6 @@ impl Vecs {
|
||||
p2pk33: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("p2pk33"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -165,7 +154,6 @@ impl Vecs {
|
||||
p2pkh: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("p2pkh"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -177,7 +165,6 @@ impl Vecs {
|
||||
p2sh: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("p2sh"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -189,7 +176,6 @@ impl Vecs {
|
||||
p2wpkh: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("p2wpkh"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -201,7 +187,6 @@ impl Vecs {
|
||||
p2wsh: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("p2wsh"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -213,7 +198,6 @@ impl Vecs {
|
||||
p2tr: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("p2tr"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -225,7 +209,6 @@ impl Vecs {
|
||||
p2a: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("p2a"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -237,7 +220,6 @@ impl Vecs {
|
||||
p2ms: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("p2ms_outputs"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -249,7 +231,6 @@ impl Vecs {
|
||||
empty: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("empty_outputs"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -261,7 +242,6 @@ impl Vecs {
|
||||
unknown: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("unknown_outputs"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -275,7 +255,6 @@ impl Vecs {
|
||||
_1w: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_up_to_1w_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -287,7 +266,6 @@ impl Vecs {
|
||||
_1m: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_up_to_1m_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -299,7 +277,6 @@ impl Vecs {
|
||||
_2m: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_up_to_2m_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -311,7 +288,6 @@ impl Vecs {
|
||||
_3m: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_up_to_3m_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -323,7 +299,6 @@ impl Vecs {
|
||||
_4m: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_up_to_4m_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -335,7 +310,6 @@ impl Vecs {
|
||||
_5m: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_up_to_5m_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -347,7 +321,6 @@ impl Vecs {
|
||||
_6m: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_up_to_6m_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -359,7 +332,6 @@ impl Vecs {
|
||||
_1y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_up_to_1y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -371,7 +343,6 @@ impl Vecs {
|
||||
_2y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_up_to_2y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -383,7 +354,6 @@ impl Vecs {
|
||||
_3y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_up_to_3y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -395,7 +365,6 @@ impl Vecs {
|
||||
_4y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_up_to_4y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -407,7 +376,6 @@ impl Vecs {
|
||||
_5y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_up_to_5y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -419,7 +387,6 @@ impl Vecs {
|
||||
_6y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_up_to_6y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -431,7 +398,6 @@ impl Vecs {
|
||||
_7y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_up_to_7y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -443,7 +409,6 @@ impl Vecs {
|
||||
_8y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_up_to_8y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -455,7 +420,6 @@ impl Vecs {
|
||||
_10y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_up_to_10y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -467,7 +431,6 @@ impl Vecs {
|
||||
_12y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_up_to_12y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -479,7 +442,6 @@ impl Vecs {
|
||||
_15y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_up_to_15y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -493,7 +455,6 @@ impl Vecs {
|
||||
_1d: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_1d_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -505,7 +466,6 @@ impl Vecs {
|
||||
_1w: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_1w_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -517,7 +477,6 @@ impl Vecs {
|
||||
_1m: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_1m_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -529,7 +488,6 @@ impl Vecs {
|
||||
_2m: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_2m_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -541,7 +499,6 @@ impl Vecs {
|
||||
_3m: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_3m_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -553,7 +510,6 @@ impl Vecs {
|
||||
_4m: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_4m_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -565,7 +521,6 @@ impl Vecs {
|
||||
_5m: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_5m_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -577,7 +532,6 @@ impl Vecs {
|
||||
_6m: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_6m_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -589,7 +543,6 @@ impl Vecs {
|
||||
_1y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_1y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -601,7 +554,6 @@ impl Vecs {
|
||||
_2y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_2y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -613,7 +565,6 @@ impl Vecs {
|
||||
_3y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_3y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -625,7 +576,6 @@ impl Vecs {
|
||||
_4y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_4y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -637,7 +587,6 @@ impl Vecs {
|
||||
_5y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_5y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -649,7 +598,6 @@ impl Vecs {
|
||||
_6y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_6y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -661,7 +609,6 @@ impl Vecs {
|
||||
_7y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_7y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -673,7 +620,6 @@ impl Vecs {
|
||||
_8y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_8y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -685,7 +631,6 @@ impl Vecs {
|
||||
_10y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_10y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -697,7 +642,6 @@ impl Vecs {
|
||||
_12y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_12y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -711,7 +655,6 @@ impl Vecs {
|
||||
up_to_1d: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_up_to_1d_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -723,7 +666,6 @@ impl Vecs {
|
||||
_1d_to_1w: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_1d_up_to_1w_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -735,7 +677,6 @@ impl Vecs {
|
||||
_1w_to_1m: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_1w_up_to_1m_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -747,7 +688,6 @@ impl Vecs {
|
||||
_1m_to_2m: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_1m_up_to_2m_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -759,7 +699,6 @@ impl Vecs {
|
||||
_2m_to_3m: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_2m_up_to_3m_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -771,7 +710,6 @@ impl Vecs {
|
||||
_3m_to_4m: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_3m_up_to_4m_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -783,7 +721,6 @@ impl Vecs {
|
||||
_4m_to_5m: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_4m_up_to_5m_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -795,7 +732,6 @@ impl Vecs {
|
||||
_5m_to_6m: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_5m_up_to_6m_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -807,7 +743,6 @@ impl Vecs {
|
||||
_6m_to_1y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_6m_up_to_1y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -819,7 +754,6 @@ impl Vecs {
|
||||
_1y_to_2y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_1y_up_to_2y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -831,7 +765,6 @@ impl Vecs {
|
||||
_2y_to_3y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_2y_up_to_3y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -843,7 +776,6 @@ impl Vecs {
|
||||
_3y_to_4y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_3y_up_to_4y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -855,7 +787,6 @@ impl Vecs {
|
||||
_4y_to_5y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_4y_up_to_5y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -867,7 +798,6 @@ impl Vecs {
|
||||
_5y_to_6y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_5y_up_to_6y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -879,7 +809,6 @@ impl Vecs {
|
||||
_6y_to_7y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_6y_up_to_7y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -891,7 +820,6 @@ impl Vecs {
|
||||
_7y_to_8y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_7y_up_to_8y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -903,7 +831,6 @@ impl Vecs {
|
||||
_8y_to_10y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_8y_up_to_10y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -915,7 +842,6 @@ impl Vecs {
|
||||
_10y_to_12y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_10y_up_to_12y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -927,7 +853,6 @@ impl Vecs {
|
||||
_12y_to_15y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_12y_up_to_15y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -939,7 +864,6 @@ impl Vecs {
|
||||
from_15y: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_at_least_15y_old"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -953,7 +877,6 @@ impl Vecs {
|
||||
_0sats: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_with_0sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -965,7 +888,6 @@ impl Vecs {
|
||||
_1sat_to_10sats: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_1sat_under_10sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -977,7 +899,6 @@ impl Vecs {
|
||||
_10sats_to_100sats: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_10sats_under_100sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -989,7 +910,6 @@ impl Vecs {
|
||||
_100sats_to_1k_sats: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_100sats_under_1k_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1001,7 +921,6 @@ impl Vecs {
|
||||
_1k_sats_to_10k_sats: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_1k_sats_under_10k_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1013,7 +932,6 @@ impl Vecs {
|
||||
_10k_sats_to_100k_sats: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_10k_sats_under_100k_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1025,7 +943,6 @@ impl Vecs {
|
||||
_100k_sats_to_1m_sats: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_100k_sats_under_1m_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1037,7 +954,6 @@ impl Vecs {
|
||||
_1m_sats_to_10m_sats: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_1m_sats_under_10m_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1049,7 +965,6 @@ impl Vecs {
|
||||
_10m_sats_to_1btc: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_10m_sats_under_1btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1061,7 +976,6 @@ impl Vecs {
|
||||
_1btc_to_10btc: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_1btc_under_10btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1073,7 +987,6 @@ impl Vecs {
|
||||
_10btc_to_100btc: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_10btc_under_100btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1085,7 +998,6 @@ impl Vecs {
|
||||
_100btc_to_1k_btc: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_100btc_under_1k_btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1097,7 +1009,6 @@ impl Vecs {
|
||||
_1k_btc_to_10k_btc: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_1k_btc_under_10k_btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1109,7 +1020,6 @@ impl Vecs {
|
||||
_10k_btc_to_100k_btc: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_10k_btc_under_100k_btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1121,7 +1031,6 @@ impl Vecs {
|
||||
_100k_btc_or_more: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_100k_btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1135,7 +1044,6 @@ impl Vecs {
|
||||
_10sats: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_under_10sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1147,7 +1055,6 @@ impl Vecs {
|
||||
_100sats: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_under_100sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1159,7 +1066,6 @@ impl Vecs {
|
||||
_1k_sats: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_under_1k_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1171,7 +1077,6 @@ impl Vecs {
|
||||
_10k_sats: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_under_10k_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1183,7 +1088,6 @@ impl Vecs {
|
||||
_100k_sats: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_under_100k_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1195,7 +1099,6 @@ impl Vecs {
|
||||
_1m_sats: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_under_1m_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1207,7 +1110,6 @@ impl Vecs {
|
||||
_10m_sats: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_under_10m_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1219,7 +1121,6 @@ impl Vecs {
|
||||
_1btc: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_under_1btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1231,7 +1132,6 @@ impl Vecs {
|
||||
_10btc: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_under_10btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1243,7 +1143,6 @@ impl Vecs {
|
||||
_100btc: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_under_100btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1255,7 +1154,6 @@ impl Vecs {
|
||||
_1k_btc: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_under_1k_btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1267,7 +1165,6 @@ impl Vecs {
|
||||
_10k_btc: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_under_10k_btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1279,7 +1176,6 @@ impl Vecs {
|
||||
_100k_btc: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_under_100k_btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1293,7 +1189,6 @@ impl Vecs {
|
||||
_1sat: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_1sat"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1305,7 +1200,6 @@ impl Vecs {
|
||||
_10sats: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_10sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1317,7 +1211,6 @@ impl Vecs {
|
||||
_100sats: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_100sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1329,7 +1222,6 @@ impl Vecs {
|
||||
_1k_sats: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_1k_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1341,7 +1233,6 @@ impl Vecs {
|
||||
_10k_sats: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_10k_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1353,7 +1244,6 @@ impl Vecs {
|
||||
_100k_sats: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_100k_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1365,7 +1255,6 @@ impl Vecs {
|
||||
_1m_sats: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_1m_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1377,7 +1266,6 @@ impl Vecs {
|
||||
_10m_sats: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_10m_sats"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1389,7 +1277,6 @@ impl Vecs {
|
||||
_1btc: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_1btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1401,7 +1288,6 @@ impl Vecs {
|
||||
_10btc: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_10btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1413,7 +1299,6 @@ impl Vecs {
|
||||
_100btc: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_100btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1425,7 +1310,6 @@ impl Vecs {
|
||||
_1k_btc: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_1k_btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
@@ -1437,7 +1321,6 @@ impl Vecs {
|
||||
_10k_btc: utxo_cohort::Vecs::forced_import(
|
||||
db,
|
||||
Some("utxos_above_10k_btc"),
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
indexes,
|
||||
price,
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::ops::{Add, AddAssign, SubAssign};
|
||||
|
||||
use brk_types::{CheckedSub, LoadedAddressData, Sats};
|
||||
use serde::Serialize;
|
||||
use vecdb::Formattable;
|
||||
use vecdb::{Bytes, Formattable};
|
||||
|
||||
#[derive(Debug, Default, Clone, Serialize)]
|
||||
pub struct SupplyState {
|
||||
@@ -62,3 +62,20 @@ impl Formattable for SupplyState {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
impl Bytes for SupplyState {
|
||||
fn to_bytes(&self) -> Vec<u8> {
|
||||
let mut bytes = Vec::new();
|
||||
bytes.extend_from_slice(&self.utxo_count.to_bytes());
|
||||
bytes.extend_from_slice(&self.value.to_bytes());
|
||||
bytes
|
||||
}
|
||||
|
||||
fn from_bytes(bytes: &[u8]) -> vecdb::Result<Self> {
|
||||
let mut offset = 0;
|
||||
let utxo_count = u64::from_bytes(&bytes[offset..])?;
|
||||
offset += utxo_count.to_bytes().len();
|
||||
let value = Sats::from_bytes(&bytes[offset..])?;
|
||||
Ok(Self { utxo_count, value })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use brk_error::Result;
|
||||
use brk_types::{Bitcoin, CheckedSub, Close, Date, DateIndex, Dollars, Sats, StoredF32};
|
||||
use vecdb::{
|
||||
AnyStoredVec, AnyVec, EagerVec, Exit, GenericStoredVec, IterableVec, VecIndex, Version,
|
||||
AnyStoredVec, AnyVec, EagerVec, Exit, GenericStoredVec, IterableVec, PcoVec, VecIndex, Version,
|
||||
};
|
||||
|
||||
const DCA_AMOUNT: Dollars = Dollars::mint(100.0);
|
||||
@@ -24,7 +24,7 @@ pub trait ComputeDCAStackViaLen {
|
||||
) -> Result<()>;
|
||||
}
|
||||
|
||||
impl ComputeDCAStackViaLen for EagerVec<DateIndex, Sats> {
|
||||
impl ComputeDCAStackViaLen for EagerVec<PcoVec<DateIndex, Sats>> {
|
||||
fn compute_dca_stack_via_len(
|
||||
&mut self,
|
||||
max_from: DateIndex,
|
||||
@@ -142,7 +142,7 @@ pub trait ComputeDCAAveragePriceViaLen {
|
||||
) -> Result<()>;
|
||||
}
|
||||
|
||||
impl ComputeDCAAveragePriceViaLen for EagerVec<DateIndex, Dollars> {
|
||||
impl ComputeDCAAveragePriceViaLen for EagerVec<PcoVec<DateIndex, Dollars>> {
|
||||
fn compute_dca_avg_price_via_len(
|
||||
&mut self,
|
||||
max_from: DateIndex,
|
||||
@@ -223,7 +223,7 @@ pub trait ComputeFromSats<I> {
|
||||
) -> Result<()>;
|
||||
}
|
||||
|
||||
impl<I> ComputeFromSats<I> for EagerVec<I, Bitcoin>
|
||||
impl<I> ComputeFromSats<I> for EagerVec<PcoVec<I, Bitcoin>>
|
||||
where
|
||||
I: VecIndex,
|
||||
{
|
||||
@@ -253,7 +253,7 @@ pub trait ComputeFromBitcoin<I> {
|
||||
) -> Result<()>;
|
||||
}
|
||||
|
||||
impl<I> ComputeFromBitcoin<I> for EagerVec<I, Dollars>
|
||||
impl<I> ComputeFromBitcoin<I> for EagerVec<PcoVec<I, Dollars>>
|
||||
where
|
||||
I: VecIndex,
|
||||
{
|
||||
@@ -285,7 +285,7 @@ pub trait ComputeDrawdown<I> {
|
||||
) -> Result<()>;
|
||||
}
|
||||
|
||||
impl<I> ComputeDrawdown<I> for EagerVec<I, StoredF32>
|
||||
impl<I> ComputeDrawdown<I> for EagerVec<PcoVec<I, StoredF32>>
|
||||
where
|
||||
I: VecIndex,
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user