global: renames + refactor + p2a support

This commit is contained in:
nym21
2025-04-25 18:16:23 +02:00
parent 1492834d1e
commit 07618ebe43
51 changed files with 2802 additions and 1833 deletions
+17 -20
View File
@@ -1,34 +1,31 @@
use std::path::Path;
use brk_core::{AddressindexTxoutindex, Unit};
use brk_indexer::Store;
use brk_vec::Version;
use fjall::TransactionalKeyspace;
#[derive(Clone)]
pub struct Stores {
pub address_to_utxos_received: Store<AddressindexTxoutindex, Unit>,
pub address_to_utxos_spent: Store<AddressindexTxoutindex, Unit>,
// pub address_to_utxos_received: Store<AddressIndexOutputIndex, Unit>,
// pub address_to_utxos_spent: Store<AddressIndexOutputIndex, Unit>,
}
impl Stores {
pub fn import(path: &Path, keyspace: &TransactionalKeyspace) -> color_eyre::Result<Self> {
let address_to_utxos_received = Store::import(
keyspace.clone(),
path,
"address_to_utxos_received",
Version::ZERO,
)?;
let address_to_utxos_spent = Store::import(
keyspace.clone(),
path,
"address_to_utxos_spent",
Version::ZERO,
)?;
pub fn import(_: &Path, _: &TransactionalKeyspace) -> color_eyre::Result<Self> {
// let address_to_utxos_received = Store::import(
// keyspace.clone(),
// path,
// "address_to_utxos_received",
// Version::ZERO,
// )?;
// let address_to_utxos_spent = Store::import(
// keyspace.clone(),
// path,
// "address_to_utxos_spent",
// Version::ZERO,
// )?;
Ok(Self {
address_to_utxos_received,
address_to_utxos_spent,
// address_to_utxos_received,
// address_to_utxos_spent,
})
}
}
@@ -1,6 +1,6 @@
use std::path::Path;
use brk_core::{Dateindex, Decadeindex, Monthindex, Quarterindex, Weekindex, Yearindex};
use brk_core::{DateIndex, DecadeIndex, MonthIndex, QuarterIndex, WeekIndex, YearIndex};
use brk_exit::Exit;
use brk_indexer::Indexer;
use brk_vec::{AnyStoredVec, Compressed, Result, Version};
@@ -14,13 +14,13 @@ pub struct ComputedVecsFromDateindex<T>
where
T: ComputedType + PartialOrd,
{
pub dateindex: EagerVec<Dateindex, T>,
pub dateindex_extra: ComputedVecBuilder<Dateindex, T>,
pub weekindex: ComputedVecBuilder<Weekindex, T>,
pub monthindex: ComputedVecBuilder<Monthindex, T>,
pub quarterindex: ComputedVecBuilder<Quarterindex, T>,
pub yearindex: ComputedVecBuilder<Yearindex, T>,
pub decadeindex: ComputedVecBuilder<Decadeindex, T>,
pub dateindex: EagerVec<DateIndex, T>,
pub dateindex_extra: ComputedVecBuilder<DateIndex, T>,
pub weekindex: ComputedVecBuilder<WeekIndex, T>,
pub monthindex: ComputedVecBuilder<MonthIndex, T>,
pub quarterindex: ComputedVecBuilder<QuarterIndex, T>,
pub yearindex: ComputedVecBuilder<YearIndex, T>,
pub decadeindex: ComputedVecBuilder<DecadeIndex, T>,
}
const VERSION: Version = Version::ZERO;
@@ -79,7 +79,7 @@ where
) -> color_eyre::Result<()>
where
F: FnMut(
&mut EagerVec<Dateindex, T>,
&mut EagerVec<DateIndex, T>,
&mut Indexer,
&mut indexes::Vecs,
&Indexes,
@@ -1,7 +1,7 @@
use std::path::Path;
use brk_core::{
Dateindex, Decadeindex, Difficultyepoch, Height, Monthindex, Quarterindex, Weekindex, Yearindex,
DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex,
};
use brk_exit::Exit;
use brk_indexer::Indexer;
@@ -18,14 +18,14 @@ where
{
pub height: Option<EagerVec<Height, T>>,
pub height_extra: ComputedVecBuilder<Height, T>,
pub dateindex: ComputedVecBuilder<Dateindex, T>,
pub weekindex: ComputedVecBuilder<Weekindex, T>,
pub difficultyepoch: ComputedVecBuilder<Difficultyepoch, T>,
pub monthindex: ComputedVecBuilder<Monthindex, T>,
pub quarterindex: ComputedVecBuilder<Quarterindex, T>,
pub yearindex: ComputedVecBuilder<Yearindex, T>,
pub dateindex: ComputedVecBuilder<DateIndex, T>,
pub weekindex: ComputedVecBuilder<WeekIndex, T>,
pub difficultyepoch: ComputedVecBuilder<DifficultyEpoch, T>,
pub monthindex: ComputedVecBuilder<MonthIndex, T>,
pub quarterindex: ComputedVecBuilder<QuarterIndex, T>,
pub yearindex: ComputedVecBuilder<YearIndex, T>,
// TODO: pub halvingepoch: StorableVecGeneator<Halvingepoch, T>,
pub decadeindex: ComputedVecBuilder<Decadeindex, T>,
pub decadeindex: ComputedVecBuilder<DecadeIndex, T>,
}
const VERSION: Version = Version::ZERO;
@@ -1,6 +1,6 @@
use std::path::Path;
use brk_core::{Difficultyepoch, Height};
use brk_core::{DifficultyEpoch, Height};
use brk_exit::Exit;
use brk_indexer::Indexer;
use brk_vec::{AnyStoredVec, Compressed, Result, Version};
@@ -16,7 +16,7 @@ where
{
pub height: EagerVec<Height, T>,
pub height_extra: ComputedVecBuilder<Height, T>,
pub difficultyepoch: ComputedVecBuilder<Difficultyepoch, T>,
pub difficultyepoch: ComputedVecBuilder<DifficultyEpoch, T>,
// TODO: pub halvingepoch: StorableVecGeneator<Halvingepoch, T>,
}
@@ -1,8 +1,8 @@
use std::path::Path;
use brk_core::{
Dateindex, Decadeindex, Difficultyepoch, Height, Monthindex, Quarterindex, Txindex, Weekindex,
Yearindex,
DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, TxIndex, WeekIndex,
YearIndex,
};
use brk_exit::Exit;
use brk_indexer::Indexer;
@@ -17,16 +17,16 @@ pub struct ComputedVecsFromTxindex<T>
where
T: ComputedType + PartialOrd,
{
pub txindex: Option<EagerVec<Txindex, T>>,
pub txindex: Option<EagerVec<TxIndex, T>>,
pub height: ComputedVecBuilder<Height, T>,
pub dateindex: ComputedVecBuilder<Dateindex, T>,
pub weekindex: ComputedVecBuilder<Weekindex, T>,
pub difficultyepoch: ComputedVecBuilder<Difficultyepoch, T>,
pub monthindex: ComputedVecBuilder<Monthindex, T>,
pub quarterindex: ComputedVecBuilder<Quarterindex, T>,
pub yearindex: ComputedVecBuilder<Yearindex, T>,
pub dateindex: ComputedVecBuilder<DateIndex, T>,
pub weekindex: ComputedVecBuilder<WeekIndex, T>,
pub difficultyepoch: ComputedVecBuilder<DifficultyEpoch, T>,
pub monthindex: ComputedVecBuilder<MonthIndex, T>,
pub quarterindex: ComputedVecBuilder<QuarterIndex, T>,
pub yearindex: ComputedVecBuilder<YearIndex, T>,
// TODO: pub halvingepoch: StorableVecGeneator<Halvingepoch, T>,
pub decadeindex: ComputedVecBuilder<Decadeindex, T>,
pub decadeindex: ComputedVecBuilder<DecadeIndex, T>,
}
const VERSION: Version = Version::ZERO;
@@ -91,7 +91,7 @@ where
) -> color_eyre::Result<()>
where
F: FnMut(
&mut EagerVec<Txindex, T>,
&mut EagerVec<TxIndex, T>,
&mut Indexer,
&mut indexes::Vecs,
&Indexes,
@@ -117,7 +117,7 @@ where
indexes: &mut indexes::Vecs,
starting_indexes: &Indexes,
exit: &Exit,
txindex: Option<&mut StoredVec<Txindex, T>>,
txindex: Option<&mut StoredVec<TxIndex, T>>,
) -> color_eyre::Result<()> {
let txindex = txindex.unwrap_or_else(|| self.txindex.as_mut().unwrap().mut_vec());
@@ -1,6 +1,6 @@
use std::path::Path;
use brk_core::{Bitcoin, Dollars, Sats, Txindex};
use brk_core::{Bitcoin, Dollars, Sats, TxIndex};
use brk_exit::Exit;
use brk_indexer::Indexer;
use brk_vec::{AnyStoredVec, Compressed, Result, StoredVec, Version};
@@ -73,7 +73,7 @@ impl ComputedValueVecsFromTxindex {
) -> color_eyre::Result<()>
where
F: FnMut(
&mut EagerVec<Txindex, Sats>,
&mut EagerVec<TxIndex, Sats>,
&mut Indexer,
&mut indexes::Vecs,
&Indexes,
@@ -100,7 +100,7 @@ impl ComputedValueVecsFromTxindex {
marketprices: &mut Option<&mut marketprice::Vecs>,
starting_indexes: &Indexes,
exit: &Exit,
mut txindex: Option<&mut StoredVec<Txindex, Sats>>,
mut txindex: Option<&mut StoredVec<TxIndex, Sats>>,
) -> color_eyre::Result<()> {
if let Some(txindex) = txindex.as_mut() {
self.sats
@@ -136,11 +136,11 @@ impl ComputedValueVecsFromTxindex {
indexes,
starting_indexes,
exit,
|v, indexer, _, starting_indexes, exit| {
|v, _, indexes, starting_indexes, exit| {
v.compute_from_bitcoin(
starting_indexes.txindex,
txindex,
indexer.mut_vecs().txindex_to_height.mut_vec(),
indexes.txindex_to_height.mut_vec(),
price,
exit,
)
+165 -171
View File
@@ -1,10 +1,10 @@
use std::{fs, ops::Deref, path::Path};
use brk_core::{
Addressindex, Date, Dateindex, Decadeindex, Difficultyepoch, Emptyindex, Halvingepoch, Height,
Monthindex, Multisigindex, Opreturnindex, P2PK33index, P2PK65index, P2PKHindex, P2SHindex,
P2TRindex, P2WPKHindex, P2WSHindex, Pushonlyindex, Quarterindex, Timestamp, Txindex, Txinindex,
Txoutindex, Unknownindex, Weekindex, Yearindex,
Date, DateIndex, DecadeIndex, DifficultyEpoch, EmptyOutputIndex, HalvingEpoch, Height,
InputIndex, MonthIndex, OpReturnIndex, OutputIndex, P2AIndex, P2MSIndex, P2PK33Index,
P2PK65Index, P2PKHIndex, P2SHIndex, P2TRIndex, P2WPKHIndex, P2WSHIndex, QuarterIndex,
Timestamp, TxIndex, UnknownOutputIndex, WeekIndex, YearIndex,
};
use brk_exit::Exit;
use brk_indexer::Indexer;
@@ -14,70 +14,70 @@ use super::EagerVec;
#[derive(Clone)]
pub struct Vecs {
pub addressindex_to_addressindex: EagerVec<Addressindex, Addressindex>,
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_last_height: EagerVec<Dateindex, Height>,
pub dateindex_to_monthindex: EagerVec<Dateindex, Monthindex>,
pub dateindex_to_timestamp: EagerVec<Dateindex, Timestamp>,
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_last_yearindex: EagerVec<Decadeindex, Yearindex>,
pub decadeindex_to_timestamp: EagerVec<Decadeindex, Timestamp>,
pub difficultyepoch_to_difficultyepoch: EagerVec<Difficultyepoch, Difficultyepoch>,
pub difficultyepoch_to_first_height: EagerVec<Difficultyepoch, Height>,
pub difficultyepoch_to_last_height: EagerVec<Difficultyepoch, Height>,
pub difficultyepoch_to_timestamp: EagerVec<Difficultyepoch, Timestamp>,
pub emptyindex_to_emptyindex: EagerVec<Emptyindex, Emptyindex>,
pub halvingepoch_to_first_height: EagerVec<Halvingepoch, Height>,
pub halvingepoch_to_halvingepoch: EagerVec<Halvingepoch, Halvingepoch>,
pub halvingepoch_to_last_height: EagerVec<Halvingepoch, Height>,
pub halvingepoch_to_timestamp: EagerVec<Halvingepoch, Timestamp>,
pub height_to_dateindex: EagerVec<Height, Dateindex>,
pub height_to_difficultyepoch: EagerVec<Height, Difficultyepoch>,
pub height_to_fixed_date: EagerVec<Height, Date>,
pub height_to_fixed_timestamp: EagerVec<Height, Timestamp>,
pub height_to_halvingepoch: EagerVec<Height, Halvingepoch>,
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_last_height: EagerVec<DateIndex, Height>,
pub dateindex_to_monthindex: EagerVec<DateIndex, MonthIndex>,
pub dateindex_to_timestamp: EagerVec<DateIndex, Timestamp>,
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_last_yearindex: EagerVec<DecadeIndex, YearIndex>,
pub decadeindex_to_timestamp: EagerVec<DecadeIndex, Timestamp>,
pub difficultyepoch_to_difficultyepoch: EagerVec<DifficultyEpoch, DifficultyEpoch>,
pub difficultyepoch_to_first_height: EagerVec<DifficultyEpoch, Height>,
pub difficultyepoch_to_last_height: EagerVec<DifficultyEpoch, Height>,
pub difficultyepoch_to_timestamp: EagerVec<DifficultyEpoch, Timestamp>,
pub emptyoutputindex_to_emptyoutputindex: EagerVec<EmptyOutputIndex, EmptyOutputIndex>,
pub halvingepoch_to_first_height: EagerVec<HalvingEpoch, Height>,
pub halvingepoch_to_halvingepoch: EagerVec<HalvingEpoch, HalvingEpoch>,
pub halvingepoch_to_last_height: EagerVec<HalvingEpoch, Height>,
pub halvingepoch_to_timestamp: EagerVec<HalvingEpoch, Timestamp>,
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_last_txindex: EagerVec<Height, Txindex>,
pub height_to_real_date: EagerVec<Height, Date>,
pub monthindex_to_first_dateindex: EagerVec<Monthindex, Dateindex>,
pub monthindex_to_last_dateindex: EagerVec<Monthindex, Dateindex>,
pub monthindex_to_monthindex: EagerVec<Monthindex, Monthindex>,
pub monthindex_to_quarterindex: EagerVec<Monthindex, Quarterindex>,
pub monthindex_to_timestamp: EagerVec<Monthindex, Timestamp>,
pub monthindex_to_yearindex: EagerVec<Monthindex, Yearindex>,
pub multisigindex_to_multisigindex: EagerVec<Multisigindex, Multisigindex>,
pub opreturnindex_to_opreturnindex: EagerVec<Opreturnindex, Opreturnindex>,
pub p2pk33index_to_p2pk33index: EagerVec<P2PK33index, P2PK33index>,
pub p2pk65index_to_p2pk65index: EagerVec<P2PK65index, P2PK65index>,
pub p2pkhindex_to_p2pkhindex: EagerVec<P2PKHindex, P2PKHindex>,
pub p2shindex_to_p2shindex: EagerVec<P2SHindex, P2SHindex>,
pub p2trindex_to_p2trindex: EagerVec<P2TRindex, P2TRindex>,
pub p2wpkhindex_to_p2wpkhindex: EagerVec<P2WPKHindex, P2WPKHindex>,
pub p2wshindex_to_p2wshindex: EagerVec<P2WSHindex, P2WSHindex>,
pub pushonlyindex_to_pushonlyindex: EagerVec<Pushonlyindex, Pushonlyindex>,
pub quarterindex_to_first_monthindex: EagerVec<Quarterindex, Monthindex>,
pub quarterindex_to_last_monthindex: EagerVec<Quarterindex, Monthindex>,
pub quarterindex_to_quarterindex: EagerVec<Quarterindex, Quarterindex>,
pub quarterindex_to_timestamp: EagerVec<Quarterindex, Timestamp>,
pub txindex_to_last_txinindex: EagerVec<Txindex, Txinindex>,
pub txindex_to_last_txoutindex: EagerVec<Txindex, Txoutindex>,
pub txindex_to_txindex: EagerVec<Txindex, Txindex>,
pub txinindex_to_txinindex: EagerVec<Txinindex, Txinindex>,
pub txoutindex_to_txoutindex: EagerVec<Txoutindex, Txoutindex>,
pub unknownindex_to_unknownindex: EagerVec<Unknownindex, Unknownindex>,
pub weekindex_to_first_dateindex: EagerVec<Weekindex, Dateindex>,
pub weekindex_to_last_dateindex: EagerVec<Weekindex, Dateindex>,
pub weekindex_to_timestamp: EagerVec<Weekindex, Timestamp>,
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_last_monthindex: EagerVec<Yearindex, Monthindex>,
pub yearindex_to_timestamp: EagerVec<Yearindex, Timestamp>,
pub yearindex_to_yearindex: EagerVec<Yearindex, Yearindex>,
pub height_to_last_txindex: EagerVec<Height, TxIndex>,
pub height_to_timestamp_fixed: EagerVec<Height, Timestamp>,
pub inputindex_to_inputindex: EagerVec<InputIndex, InputIndex>,
pub monthindex_to_first_dateindex: EagerVec<MonthIndex, DateIndex>,
pub monthindex_to_last_dateindex: EagerVec<MonthIndex, DateIndex>,
pub monthindex_to_monthindex: EagerVec<MonthIndex, MonthIndex>,
pub monthindex_to_quarterindex: EagerVec<MonthIndex, QuarterIndex>,
pub monthindex_to_timestamp: EagerVec<MonthIndex, Timestamp>,
pub monthindex_to_yearindex: EagerVec<MonthIndex, YearIndex>,
pub opreturnindex_to_opreturnindex: EagerVec<OpReturnIndex, OpReturnIndex>,
pub outputindex_to_outputindex: EagerVec<OutputIndex, OutputIndex>,
pub p2aindex_to_p2aindex: EagerVec<P2AIndex, P2AIndex>,
pub p2msindex_to_p2msindex: EagerVec<P2MSIndex, P2MSIndex>,
pub p2pk33index_to_p2pk33index: EagerVec<P2PK33Index, P2PK33Index>,
pub p2pk65index_to_p2pk65index: EagerVec<P2PK65Index, P2PK65Index>,
pub p2pkhindex_to_p2pkhindex: EagerVec<P2PKHIndex, P2PKHIndex>,
pub p2shindex_to_p2shindex: EagerVec<P2SHIndex, P2SHIndex>,
pub p2trindex_to_p2trindex: EagerVec<P2TRIndex, P2TRIndex>,
pub p2wpkhindex_to_p2wpkhindex: EagerVec<P2WPKHIndex, P2WPKHIndex>,
pub p2wshindex_to_p2wshindex: EagerVec<P2WSHIndex, P2WSHIndex>,
pub quarterindex_to_first_monthindex: EagerVec<QuarterIndex, MonthIndex>,
pub quarterindex_to_last_monthindex: EagerVec<QuarterIndex, MonthIndex>,
pub quarterindex_to_quarterindex: EagerVec<QuarterIndex, QuarterIndex>,
pub quarterindex_to_timestamp: EagerVec<QuarterIndex, Timestamp>,
pub txindex_to_height: EagerVec<TxIndex, Height>,
pub txindex_to_last_inputindex: EagerVec<TxIndex, InputIndex>,
pub txindex_to_last_outputindex: EagerVec<TxIndex, OutputIndex>,
pub txindex_to_txindex: EagerVec<TxIndex, TxIndex>,
pub unknownoutputindex_to_unknownoutputindex: EagerVec<UnknownOutputIndex, UnknownOutputIndex>,
pub weekindex_to_first_dateindex: EagerVec<WeekIndex, DateIndex>,
pub weekindex_to_last_dateindex: EagerVec<WeekIndex, DateIndex>,
pub weekindex_to_timestamp: EagerVec<WeekIndex, Timestamp>,
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_last_monthindex: EagerVec<YearIndex, MonthIndex>,
pub yearindex_to_timestamp: EagerVec<YearIndex, Timestamp>,
pub yearindex_to_yearindex: EagerVec<YearIndex, YearIndex>,
}
impl Vecs {
@@ -105,13 +105,13 @@ impl Vecs {
Version::ZERO,
compressed,
)?,
height_to_real_date: EagerVec::forced_import(
&path.join("height_to_real_date"),
height_to_date: EagerVec::forced_import(
&path.join("height_to_date"),
Version::ZERO,
compressed,
)?,
height_to_fixed_date: EagerVec::forced_import(
&path.join("height_to_fixed_date"),
height_to_date_fixed: EagerVec::forced_import(
&path.join("height_to_date_fixed"),
Version::ZERO,
compressed,
)?,
@@ -130,13 +130,18 @@ impl Vecs {
Version::ZERO,
compressed,
)?,
txindex_to_last_txinindex: EagerVec::forced_import(
&path.join("txindex_to_last_txinindex"),
txindex_to_height: EagerVec::forced_import(
&path.join("txindex_to_height"),
Version::ZERO,
compressed,
)?,
txindex_to_last_txoutindex: EagerVec::forced_import(
&path.join("txindex_to_last_txoutindex"),
txindex_to_last_inputindex: EagerVec::forced_import(
&path.join("txindex_to_last_inputindex"),
Version::ZERO,
compressed,
)?,
txindex_to_last_outputindex: EagerVec::forced_import(
&path.join("txindex_to_last_outputindex"),
Version::ZERO,
compressed,
)?,
@@ -295,8 +300,8 @@ impl Vecs {
Version::ZERO,
compressed,
)?,
height_to_fixed_timestamp: EagerVec::forced_import(
&path.join("height_to_fixed_timestamp"),
height_to_timestamp_fixed: EagerVec::forced_import(
&path.join("height_to_timestamp_fixed"),
Version::ZERO,
compressed,
)?,
@@ -365,18 +370,18 @@ impl Vecs {
Version::ZERO,
compressed,
)?,
txinindex_to_txinindex: EagerVec::forced_import(
&path.join("txinindex_to_txinindex"),
inputindex_to_inputindex: EagerVec::forced_import(
&path.join("inputindex_to_inputindex"),
Version::ZERO,
compressed,
)?,
emptyindex_to_emptyindex: EagerVec::forced_import(
&path.join("emptyindex_to_emptyindex"),
emptyoutputindex_to_emptyoutputindex: EagerVec::forced_import(
&path.join("emptyoutputindex_to_emptyoutputindex"),
Version::ZERO,
compressed,
)?,
multisigindex_to_multisigindex: EagerVec::forced_import(
&path.join("multisigindex_to_multisigindex"),
p2msindex_to_p2msindex: EagerVec::forced_import(
&path.join("p2msindex_to_p2msindex"),
Version::ZERO,
compressed,
)?,
@@ -385,23 +390,18 @@ impl Vecs {
Version::ZERO,
compressed,
)?,
pushonlyindex_to_pushonlyindex: EagerVec::forced_import(
&path.join("pushonlyindex_to_pushonlyindex"),
p2aindex_to_p2aindex: EagerVec::forced_import(
&path.join("p2aindex_to_p2aindex"),
Version::ZERO,
compressed,
)?,
unknownindex_to_unknownindex: EagerVec::forced_import(
&path.join("unknownindex_to_unknownindex"),
unknownoutputindex_to_unknownoutputindex: EagerVec::forced_import(
&path.join("unknownoutputindex_to_unknownoutputindex"),
Version::ZERO,
compressed,
)?,
addressindex_to_addressindex: EagerVec::forced_import(
&path.join("addressindex_to_addressindex"),
Version::ZERO,
compressed,
)?,
txoutindex_to_txoutindex: EagerVec::forced_import(
&path.join("txoutindex_to_txoutindex"),
outputindex_to_outputindex: EagerVec::forced_import(
&path.join("outputindex_to_outputindex"),
Version::ZERO,
compressed,
)?,
@@ -418,8 +418,8 @@ impl Vecs {
let height_count = indexer_vecs.height_to_total_size.len();
let txindexes_count = indexer_vecs.txindex_to_txid.len();
let txinindexes_count = indexer_vecs.txinindex_to_txoutindex.len();
let txoutindexes_count = indexer_vecs.txoutindex_to_addressindex.len();
let inputindexes_count = indexer_vecs.inputindex_to_outputindex.len();
let outputindexes_count = indexer_vecs.outputindex_to_value.len();
self.height_to_height.compute_range(
starting_indexes.height,
@@ -428,14 +428,14 @@ impl Vecs {
exit,
)?;
self.height_to_real_date.compute_transform(
self.height_to_date.compute_transform(
starting_indexes.height,
indexer_vecs.height_to_timestamp.mut_vec(),
|(h, t, ..)| (h, Date::from(t)),
exit,
)?;
self.height_to_fixed_timestamp.compute_transform(
self.height_to_timestamp_fixed.compute_transform(
starting_indexes.height,
indexer_vecs.height_to_timestamp.mut_vec(),
|(h, timestamp, s, ..)| {
@@ -448,9 +448,9 @@ impl Vecs {
exit,
)?;
self.height_to_fixed_date.compute_transform(
self.height_to_date_fixed.compute_transform(
starting_indexes.height,
self.height_to_fixed_timestamp.mut_vec(),
self.height_to_timestamp_fixed.mut_vec(),
|(h, t, ..)| (h, Date::from(t)),
exit,
)?;
@@ -464,8 +464,8 @@ impl Vecs {
self.height_to_dateindex.compute_transform(
starting_indexes.height,
self.height_to_fixed_date.mut_vec(),
|(h, d, ..)| (h, Dateindex::try_from(d).unwrap()),
self.height_to_date_fixed.mut_vec(),
|(h, d, ..)| (h, DateIndex::try_from(d).unwrap()),
exit,
)?;
@@ -516,19 +516,19 @@ impl Vecs {
exit,
)?;
self.txindex_to_last_txinindex
self.txindex_to_last_inputindex
.compute_last_index_from_first(
starting_indexes.txindex,
indexer_vecs.txindex_to_first_txinindex.mut_vec(),
txinindexes_count,
indexer_vecs.txindex_to_first_inputindex.mut_vec(),
inputindexes_count,
exit,
)?;
self.txindex_to_last_txoutindex
self.txindex_to_last_outputindex
.compute_last_index_from_first(
starting_indexes.txindex,
indexer_vecs.txindex_to_first_txoutindex.mut_vec(),
txoutindexes_count,
indexer_vecs.txindex_to_first_outputindex.mut_vec(),
outputindexes_count,
exit,
)?;
@@ -549,7 +549,7 @@ impl Vecs {
self.dateindex_to_weekindex.compute_range(
starting_dateindex,
self.dateindex_to_dateindex.mut_vec(),
|di| (di, Weekindex::from(di)),
|di| (di, WeekIndex::from(di)),
exit,
)?;
@@ -592,7 +592,7 @@ impl Vecs {
self.dateindex_to_monthindex.compute_range(
starting_dateindex,
self.dateindex_to_dateindex.mut_vec(),
|di| (di, Monthindex::from(di)),
|di| (di, MonthIndex::from(di)),
exit,
)?;
@@ -637,7 +637,7 @@ impl Vecs {
self.monthindex_to_quarterindex.compute_range(
starting_monthindex,
self.monthindex_to_monthindex.mut_vec(),
|mi| (mi, Quarterindex::from(mi)),
|mi| (mi, QuarterIndex::from(mi)),
exit,
)?;
@@ -682,7 +682,7 @@ impl Vecs {
self.monthindex_to_yearindex.compute_range(
starting_monthindex,
self.monthindex_to_monthindex.mut_vec(),
|i| (i, Yearindex::from(i)),
|i| (i, YearIndex::from(i)),
exit,
)?;
@@ -727,7 +727,7 @@ impl Vecs {
self.yearindex_to_decadeindex.compute_range(
starting_yearindex,
self.yearindex_to_yearindex.mut_vec(),
|i| (i, Decadeindex::from(i)),
|i| (i, DecadeIndex::from(i)),
exit,
)?;
@@ -770,7 +770,7 @@ impl Vecs {
self.height_to_difficultyepoch.compute_range(
starting_indexes.height,
self.height_to_height.mut_vec(),
|h| (h, Difficultyepoch::from(h)),
|h| (h, DifficultyEpoch::from(h)),
exit,
)?;
@@ -818,7 +818,7 @@ impl Vecs {
self.height_to_halvingepoch.compute_range(
starting_indexes.height,
self.height_to_height.mut_vec(),
|h| (h, Halvingepoch::from(h)),
|h| (h, HalvingEpoch::from(h)),
exit,
)?;
@@ -858,102 +858,97 @@ impl Vecs {
// ---
self.addressindex_to_addressindex.compute_range(
starting_indexes.addressindex,
indexer_vecs.addressindex_to_height.mut_vec(),
|i| (i, i),
exit,
)?;
self.txoutindex_to_txoutindex.compute_range(
starting_indexes.txoutindex,
indexer_vecs.txoutindex_to_height.mut_vec(),
self.outputindex_to_outputindex.compute_range(
starting_indexes.outputindex,
indexer_vecs.outputindex_to_value.mut_vec(),
|i| (i, i),
exit,
)?;
self.p2pk33index_to_p2pk33index.compute_range(
starting_indexes.p2pk33index,
indexer_vecs.p2pk33index_to_height.mut_vec(),
indexer_vecs.p2pk33index_to_p2pk33bytes.mut_vec(),
|i| (i, i),
exit,
)?;
self.p2pk65index_to_p2pk65index.compute_range(
starting_indexes.p2pk65index,
indexer_vecs.p2pk65index_to_height.mut_vec(),
indexer_vecs.p2pk65index_to_p2pk65bytes.mut_vec(),
|i| (i, i),
exit,
)?;
self.p2pkhindex_to_p2pkhindex.compute_range(
starting_indexes.p2pkhindex,
indexer_vecs.p2pkhindex_to_height.mut_vec(),
indexer_vecs.p2pkhindex_to_p2pkhbytes.mut_vec(),
|i| (i, i),
exit,
)?;
self.p2shindex_to_p2shindex.compute_range(
starting_indexes.p2shindex,
indexer_vecs.p2shindex_to_height.mut_vec(),
indexer_vecs.p2shindex_to_p2shbytes.mut_vec(),
|i| (i, i),
exit,
)?;
self.p2trindex_to_p2trindex.compute_range(
starting_indexes.p2trindex,
indexer_vecs.p2trindex_to_height.mut_vec(),
indexer_vecs.p2trindex_to_p2trbytes.mut_vec(),
|i| (i, i),
exit,
)?;
self.p2wpkhindex_to_p2wpkhindex.compute_range(
starting_indexes.p2wpkhindex,
indexer_vecs.p2wpkhindex_to_height.mut_vec(),
indexer_vecs.p2wpkhindex_to_p2wpkhbytes.mut_vec(),
|i| (i, i),
exit,
)?;
self.p2wshindex_to_p2wshindex.compute_range(
starting_indexes.p2wshindex,
indexer_vecs.p2wshindex_to_height.mut_vec(),
indexer_vecs.p2wshindex_to_p2wshbytes.mut_vec(),
|i| (i, i),
exit,
)?;
self.txindex_to_txindex.compute_range(
starting_indexes.txindex,
indexer_vecs.txindex_to_height.mut_vec(),
self.txindex_to_height.mut_vec(),
|i| (i, i),
exit,
)?;
self.txinindex_to_txinindex.compute_range(
starting_indexes.txinindex,
indexer_vecs.txinindex_to_height.mut_vec(),
self.inputindex_to_inputindex.compute_range(
starting_indexes.inputindex,
indexer_vecs.inputindex_to_outputindex.mut_vec(),
|i| (i, i),
exit,
)?;
self.emptyindex_to_emptyindex.compute_range(
starting_indexes.emptyindex,
indexer_vecs.emptyindex_to_height.mut_vec(),
self.emptyoutputindex_to_emptyoutputindex.compute_range(
starting_indexes.emptyoutputindex,
indexer_vecs.emptyoutputindex_to_txindex.mut_vec(),
|i| (i, i),
exit,
)?;
self.multisigindex_to_multisigindex.compute_range(
starting_indexes.multisigindex,
indexer_vecs.multisigindex_to_height.mut_vec(),
self.p2msindex_to_p2msindex.compute_range(
starting_indexes.p2msindex,
indexer_vecs.p2msindex_to_txindex.mut_vec(),
|i| (i, i),
exit,
)?;
self.opreturnindex_to_opreturnindex.compute_range(
starting_indexes.opreturnindex,
indexer_vecs.opreturnindex_to_height.mut_vec(),
indexer_vecs.opreturnindex_to_txindex.mut_vec(),
|i| (i, i),
exit,
)?;
self.pushonlyindex_to_pushonlyindex.compute_range(
starting_indexes.pushonlyindex,
indexer_vecs.pushonlyindex_to_height.mut_vec(),
|i| (i, i),
exit,
)?;
self.unknownindex_to_unknownindex.compute_range(
starting_indexes.unknownindex,
indexer_vecs.unknownindex_to_height.mut_vec(),
self.p2aindex_to_p2aindex.compute_range(
starting_indexes.p2aindex,
indexer_vecs.p2aindex_to_p2abytes.mut_vec(),
|i| (i, i),
exit,
)?;
self.unknownoutputindex_to_unknownoutputindex
.compute_range(
starting_indexes.unknownoutputindex,
indexer_vecs.unknownoutputindex_to_txindex.mut_vec(),
|i| (i, i),
exit,
)?;
Ok(Indexes {
indexes: starting_indexes,
@@ -975,12 +970,12 @@ impl Vecs {
self.dateindex_to_first_height.any_vec(),
self.dateindex_to_last_height.any_vec(),
self.height_to_dateindex.any_vec(),
self.height_to_fixed_date.any_vec(),
self.height_to_date_fixed.any_vec(),
self.height_to_height.any_vec(),
self.height_to_last_txindex.any_vec(),
self.height_to_real_date.any_vec(),
self.txindex_to_last_txinindex.any_vec(),
self.txindex_to_last_txoutindex.any_vec(),
self.height_to_date.any_vec(),
self.txindex_to_last_inputindex.any_vec(),
self.txindex_to_last_outputindex.any_vec(),
self.difficultyepoch_to_first_height.any_vec(),
self.difficultyepoch_to_last_height.any_vec(),
self.halvingepoch_to_first_height.any_vec(),
@@ -1012,7 +1007,7 @@ impl Vecs {
self.monthindex_to_timestamp.any_vec(),
self.weekindex_to_timestamp.any_vec(),
self.yearindex_to_timestamp.any_vec(),
self.height_to_fixed_timestamp.any_vec(),
self.height_to_timestamp_fixed.any_vec(),
self.monthindex_to_quarterindex.any_vec(),
self.quarterindex_to_first_monthindex.any_vec(),
self.quarterindex_to_last_monthindex.any_vec(),
@@ -1026,28 +1021,27 @@ impl Vecs {
self.p2wpkhindex_to_p2wpkhindex.any_vec(),
self.p2wshindex_to_p2wshindex.any_vec(),
self.txindex_to_txindex.any_vec(),
self.txinindex_to_txinindex.any_vec(),
self.emptyindex_to_emptyindex.any_vec(),
self.multisigindex_to_multisigindex.any_vec(),
self.inputindex_to_inputindex.any_vec(),
self.emptyoutputindex_to_emptyoutputindex.any_vec(),
self.p2msindex_to_p2msindex.any_vec(),
self.opreturnindex_to_opreturnindex.any_vec(),
self.pushonlyindex_to_pushonlyindex.any_vec(),
self.unknownindex_to_unknownindex.any_vec(),
self.addressindex_to_addressindex.any_vec(),
self.txoutindex_to_txoutindex.any_vec(),
self.p2aindex_to_p2aindex.any_vec(),
self.unknownoutputindex_to_unknownoutputindex.any_vec(),
self.outputindex_to_outputindex.any_vec(),
]
}
}
pub struct Indexes {
indexes: brk_indexer::Indexes,
pub dateindex: Dateindex,
pub weekindex: Weekindex,
pub monthindex: Monthindex,
pub quarterindex: Quarterindex,
pub yearindex: Yearindex,
pub decadeindex: Decadeindex,
pub difficultyepoch: Difficultyepoch,
pub halvingepoch: Halvingepoch,
pub dateindex: DateIndex,
pub weekindex: WeekIndex,
pub monthindex: MonthIndex,
pub quarterindex: QuarterIndex,
pub yearindex: YearIndex,
pub decadeindex: DecadeIndex,
pub difficultyepoch: DifficultyEpoch,
pub halvingepoch: HalvingEpoch,
}
impl Deref for Indexes {
@@ -1,8 +1,8 @@
use std::{fs, path::Path};
use brk_core::{
Cents, Close, Dateindex, Decadeindex, Difficultyepoch, Dollars, Height, High, Low, Monthindex,
OHLCCents, OHLCDollars, OHLCSats, Open, Quarterindex, Sats, Weekindex, Yearindex,
Cents, Close, DateIndex, DecadeIndex, DifficultyEpoch, Dollars, Height, High, Low, MonthIndex,
OHLCCents, OHLCDollars, OHLCSats, Open, QuarterIndex, Sats, WeekIndex, YearIndex,
};
use brk_exit::Exit;
use brk_fetcher::Fetcher;
@@ -19,13 +19,13 @@ use super::{
#[derive(Clone)]
pub struct Vecs {
pub dateindex_to_close_in_cents: EagerVec<Dateindex, Close<Cents>>,
pub dateindex_to_high_in_cents: EagerVec<Dateindex, High<Cents>>,
pub dateindex_to_low_in_cents: EagerVec<Dateindex, Low<Cents>>,
pub dateindex_to_ohlc: EagerVec<Dateindex, OHLCDollars>,
pub dateindex_to_ohlc_in_sats: EagerVec<Dateindex, OHLCSats>,
pub dateindex_to_ohlc_in_cents: EagerVec<Dateindex, OHLCCents>,
pub dateindex_to_open_in_cents: EagerVec<Dateindex, Open<Cents>>,
pub dateindex_to_close_in_cents: EagerVec<DateIndex, Close<Cents>>,
pub dateindex_to_high_in_cents: EagerVec<DateIndex, High<Cents>>,
pub dateindex_to_low_in_cents: EagerVec<DateIndex, Low<Cents>>,
pub dateindex_to_ohlc: EagerVec<DateIndex, OHLCDollars>,
pub dateindex_to_ohlc_in_sats: EagerVec<DateIndex, OHLCSats>,
pub dateindex_to_ohlc_in_cents: EagerVec<DateIndex, OHLCCents>,
pub dateindex_to_open_in_cents: EagerVec<DateIndex, Open<Cents>>,
pub height_to_close_in_cents: EagerVec<Height, Close<Cents>>,
pub height_to_high_in_cents: EagerVec<Height, High<Cents>>,
pub height_to_low_in_cents: EagerVec<Height, Low<Cents>>,
@@ -49,20 +49,20 @@ pub struct Vecs {
pub chainindexes_to_high_in_sats: ComputedVecsFromHeightStrict<High<Sats>>,
pub chainindexes_to_low_in_sats: ComputedVecsFromHeightStrict<Low<Sats>>,
pub chainindexes_to_close_in_sats: ComputedVecsFromHeightStrict<Close<Sats>>,
pub weekindex_to_ohlc: EagerVec<Weekindex, OHLCDollars>,
pub weekindex_to_ohlc_in_sats: EagerVec<Weekindex, OHLCSats>,
pub difficultyepoch_to_ohlc: EagerVec<Difficultyepoch, OHLCDollars>,
pub difficultyepoch_to_ohlc_in_sats: EagerVec<Difficultyepoch, OHLCSats>,
pub monthindex_to_ohlc: EagerVec<Monthindex, OHLCDollars>,
pub monthindex_to_ohlc_in_sats: EagerVec<Monthindex, OHLCSats>,
pub quarterindex_to_ohlc: EagerVec<Quarterindex, OHLCDollars>,
pub quarterindex_to_ohlc_in_sats: EagerVec<Quarterindex, OHLCSats>,
pub yearindex_to_ohlc: EagerVec<Yearindex, OHLCDollars>,
pub yearindex_to_ohlc_in_sats: EagerVec<Yearindex, OHLCSats>,
pub weekindex_to_ohlc: EagerVec<WeekIndex, OHLCDollars>,
pub weekindex_to_ohlc_in_sats: EagerVec<WeekIndex, OHLCSats>,
pub difficultyepoch_to_ohlc: EagerVec<DifficultyEpoch, OHLCDollars>,
pub difficultyepoch_to_ohlc_in_sats: EagerVec<DifficultyEpoch, OHLCSats>,
pub monthindex_to_ohlc: EagerVec<MonthIndex, OHLCDollars>,
pub monthindex_to_ohlc_in_sats: EagerVec<MonthIndex, OHLCSats>,
pub quarterindex_to_ohlc: EagerVec<QuarterIndex, OHLCDollars>,
pub quarterindex_to_ohlc_in_sats: EagerVec<QuarterIndex, OHLCSats>,
pub yearindex_to_ohlc: EagerVec<YearIndex, OHLCDollars>,
pub yearindex_to_ohlc_in_sats: EagerVec<YearIndex, OHLCSats>,
// pub halvingepoch_to_ohlc: StorableVec<Halvingepoch, OHLCDollars>,
// pub halvingepoch_to_ohlc_in_sats: StorableVec<Halvingepoch, OHLCSats>,
pub decadeindex_to_ohlc: EagerVec<Decadeindex, OHLCDollars>,
pub decadeindex_to_ohlc_in_sats: EagerVec<Decadeindex, OHLCSats>,
pub decadeindex_to_ohlc: EagerVec<DecadeIndex, OHLCDollars>,
pub decadeindex_to_ohlc_in_sats: EagerVec<DecadeIndex, OHLCSats>,
}
const VERSION: Version = Version::ZERO;
@@ -1,8 +1,8 @@
use std::{fs, path::Path};
use brk_core::{
CheckedSub, Feerate, Sats, StoredU32, StoredU64, StoredUsize, TxVersion, Txindex, Txinindex,
Txoutindex, Weight,
CheckedSub, Feerate, InputIndex, OutputIndex, Sats, StoredU32, StoredU64, StoredUsize, TxIndex,
TxVersion, Weight,
};
use brk_exit::Exit;
use brk_indexer::Indexer;
@@ -34,12 +34,12 @@ pub struct Vecs {
pub indexes_to_tx_vsize: ComputedVecsFromTxindex<StoredUsize>,
pub indexes_to_tx_weight: ComputedVecsFromTxindex<Weight>,
pub txindex_to_input_count: ComputedVecsFromTxindex<StoredU64>,
pub txindex_to_is_coinbase: EagerVec<Txindex, bool>,
pub txindex_to_is_coinbase: EagerVec<TxIndex, bool>,
pub txindex_to_output_count: ComputedVecsFromTxindex<StoredU64>,
pub txindex_to_vsize: EagerVec<Txindex, StoredUsize>,
pub txindex_to_weight: EagerVec<Txindex, Weight>,
pub txindex_to_vsize: EagerVec<TxIndex, StoredUsize>,
pub txindex_to_weight: EagerVec<TxIndex, Weight>,
/// Value == 0 when Coinbase
pub txinindex_to_value: EagerVec<Txinindex, Sats>,
pub inputindex_to_value: EagerVec<InputIndex, Sats>,
pub indexes_to_subsidy: ComputedValueVecsFromHeight,
pub indexes_to_coinbase: ComputedValueVecsFromHeight,
}
@@ -98,8 +98,8 @@ impl Vecs {
.add_sum()
.add_total(),
)?,
txinindex_to_value: EagerVec::forced_import(
&path.join("txinindex_to_value"),
inputindex_to_value: EagerVec::forced_import(
&path.join("inputindex_to_value"),
Version::ZERO,
compressed,
)?,
@@ -268,8 +268,8 @@ impl Vecs {
|v, indexer, indexes, starting_indexes, exit| {
v.compute_count_from_indexes(
starting_indexes.txindex,
indexer.mut_vecs().txindex_to_first_txinindex.mut_vec(),
indexes.txindex_to_last_txinindex.mut_vec(),
indexer.mut_vecs().txindex_to_first_inputindex.mut_vec(),
indexes.txindex_to_last_inputindex.mut_vec(),
exit,
)
},
@@ -283,8 +283,8 @@ impl Vecs {
|v, indexer, indexes, starting_indexes, exit| {
v.compute_count_from_indexes(
starting_indexes.txindex,
indexer.mut_vecs().txindex_to_first_txoutindex.mut_vec(),
indexes.txindex_to_last_txoutindex.mut_vec(),
indexer.mut_vecs().txindex_to_first_outputindex.mut_vec(),
indexes.txindex_to_last_outputindex.mut_vec(),
exit,
)
},
@@ -322,7 +322,7 @@ impl Vecs {
self.txindex_to_is_coinbase.compute_is_first_ordered(
starting_indexes.txindex,
indexer_vecs.txindex_to_height.mut_vec(),
indexes.txindex_to_height.mut_vec(),
indexer_vecs.height_to_first_txindex.mut_vec(),
exit,
)?;
@@ -337,7 +337,7 @@ impl Vecs {
.double_unwrap_cached_get(txindex);
// This is the exact definition of a weight unit, as defined by BIP-141 (quote above).
let wu = base_size * 3 + total_size;
let wu = usize::from(base_size) * 3 + usize::from(total_size);
let weight = Weight::from(bitcoin::Weight::from_wu_usize(wu));
(txindex, weight)
@@ -356,23 +356,23 @@ impl Vecs {
exit,
)?;
self.txinindex_to_value.compute_transform(
starting_indexes.txinindex,
indexer_vecs.txinindex_to_txoutindex.mut_vec(),
|(txinindex, txoutindex, slf, other)| {
let value = if txoutindex == Txoutindex::COINBASE {
self.inputindex_to_value.compute_transform(
starting_indexes.inputindex,
indexer_vecs.inputindex_to_outputindex.mut_vec(),
|(inputindex, outputindex, slf, other)| {
let value = if outputindex == OutputIndex::COINBASE {
Sats::ZERO
} else if let Some(value) = indexer_vecs
.txoutindex_to_value
.outputindex_to_value
.mut_vec()
.unwrap_cached_get(txoutindex)
.unwrap_cached_get(outputindex)
{
value
} else {
dbg!(txinindex, txoutindex, slf.len(), other.len());
dbg!(inputindex, outputindex, slf.len(), other.len());
panic!()
};
(txinindex, value)
(inputindex, value)
},
exit,
)?;
@@ -386,9 +386,9 @@ impl Vecs {
let indexer_vecs = indexer.mut_vecs();
vec.compute_sum_from_indexes(
starting_indexes.txindex,
indexer_vecs.txindex_to_first_txoutindex.mut_vec(),
indexes.txindex_to_last_txoutindex.mut_vec(),
indexer_vecs.txoutindex_to_value.mut_vec(),
indexer_vecs.txindex_to_first_outputindex.mut_vec(),
indexes.txindex_to_last_outputindex.mut_vec(),
indexer_vecs.outputindex_to_value.mut_vec(),
exit,
)
},
@@ -403,9 +403,9 @@ impl Vecs {
let indexer_vecs = indexer.mut_vecs();
vec.compute_sum_from_indexes(
starting_indexes.txindex,
indexer_vecs.txindex_to_first_txinindex.mut_vec(),
indexes.txindex_to_last_txinindex.mut_vec(),
self.txinindex_to_value.mut_vec(),
indexer_vecs.txindex_to_first_inputindex.mut_vec(),
indexes.txindex_to_last_inputindex.mut_vec(),
self.inputindex_to_value.mut_vec(),
exit,
)
},
@@ -495,20 +495,20 @@ impl Vecs {
starting_indexes.height,
indexer_vecs.height_to_first_txindex.mut_vec(),
|(height, txindex, ..)| {
let first_txoutindex = indexer_vecs
.txindex_to_first_txoutindex
let first_outputindex = indexer_vecs
.txindex_to_first_outputindex
.double_unwrap_cached_get(txindex)
.unwrap_to_usize();
let last_txoutindex = indexes
.txindex_to_last_txoutindex
let last_outputindex = indexes
.txindex_to_last_outputindex
.mut_vec()
.double_unwrap_cached_get(txindex)
.unwrap_to_usize();
let mut sats = Sats::ZERO;
(first_txoutindex..=last_txoutindex).for_each(|txoutindex| {
(first_outputindex..=last_outputindex).for_each(|outputindex| {
sats += indexer_vecs
.txoutindex_to_value
.double_unwrap_cached_get(Txoutindex::from(txoutindex));
.outputindex_to_value
.double_unwrap_cached_get(OutputIndex::from(outputindex));
});
(height, sats)
},
@@ -554,7 +554,7 @@ impl Vecs {
[
vec![
self.txindex_to_is_coinbase.any_vec(),
self.txinindex_to_value.any_vec(),
self.inputindex_to_value.any_vec(),
self.txindex_to_weight.any_vec(),
self.txindex_to_vsize.any_vec(),
],
@@ -6,7 +6,7 @@ use std::{
path::{Path, PathBuf},
};
use brk_core::{Bitcoin, CheckedSub, Close, Dollars, Height, Sats, Txindex};
use brk_core::{Bitcoin, CheckedSub, Close, Dollars, Height, Sats, TxIndex};
use brk_exit::Exit;
use brk_vec::{
Compressed, DynamicVec, Error, GenericVec, Result, StoredIndex, StoredType, StoredVec, Version,
@@ -490,12 +490,12 @@ impl EagerVec<Height, Dollars> {
}
}
impl EagerVec<Txindex, Dollars> {
impl EagerVec<TxIndex, Dollars> {
pub fn compute_from_bitcoin(
&mut self,
max_from: Txindex,
bitcoin: &mut StoredVec<Txindex, Bitcoin>,
i_to_height: &mut StoredVec<Txindex, Height>,
max_from: TxIndex,
bitcoin: &mut StoredVec<TxIndex, Bitcoin>,
i_to_height: &mut StoredVec<TxIndex, Height>,
price: &mut StoredVec<Height, Close<Dollars>>,
exit: &Exit,
) -> Result<()> {
@@ -503,7 +503,7 @@ impl EagerVec<Txindex, Dollars> {
Version::ZERO + self.version() + bitcoin.version(),
)?;
let index = max_from.min(Txindex::from(self.len()));
let index = max_from.min(TxIndex::from(self.len()));
bitcoin.iter_from(index, |(i, bitcoin, ..)| {
let height = i_to_height.double_unwrap_cached_get(i);
let dollars = price.double_unwrap_cached_get(height);