mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
global: rename outputindex and inputindex to txoutindex and txinindex
This commit is contained in:
@@ -4,7 +4,7 @@ use brk_computer::Computer;
|
||||
use brk_error::Result;
|
||||
use brk_fetcher::Fetcher;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_structs::{Address, AddressBytes, OutputIndex, OutputType, pools};
|
||||
use brk_structs::{Address, AddressBytes, TxOutIndex, OutputType, pools};
|
||||
use vecdb::{AnyIterableVec, Exit, VecIterator};
|
||||
|
||||
fn main() -> Result<()> {
|
||||
@@ -32,10 +32,10 @@ fn main() -> Result<()> {
|
||||
let stores = indexer.stores;
|
||||
|
||||
let mut height_to_first_txindex_iter = vecs.height_to_first_txindex.iter();
|
||||
let mut txindex_to_first_outputindex_iter = vecs.txindex_to_first_outputindex.iter();
|
||||
let mut txindex_to_first_txoutindex_iter = vecs.txindex_to_first_txoutindex.iter();
|
||||
let mut txindex_to_output_count_iter = computer.indexes.txindex_to_output_count.iter();
|
||||
let mut outputindex_to_outputtype_iter = vecs.outputindex_to_outputtype.iter();
|
||||
let mut outputindex_to_typeindex_iter = vecs.outputindex_to_typeindex.iter();
|
||||
let mut txoutindex_to_outputtype_iter = vecs.txoutindex_to_outputtype.iter();
|
||||
let mut txoutindex_to_typeindex_iter = vecs.txoutindex_to_typeindex.iter();
|
||||
let mut p2pk65addressindex_to_p2pk65bytes_iter =
|
||||
vecs.p2pk65addressindex_to_p2pk65bytes.iter();
|
||||
let mut p2pk33addressindex_to_p2pk33bytes_iter =
|
||||
@@ -57,16 +57,16 @@ fn main() -> Result<()> {
|
||||
.iter()
|
||||
.for_each(|(height, coinbase_tag)| {
|
||||
let txindex = height_to_first_txindex_iter.unwrap_get_inner(height);
|
||||
let outputindex = txindex_to_first_outputindex_iter.unwrap_get_inner(txindex);
|
||||
let txoutindex = txindex_to_first_txoutindex_iter.unwrap_get_inner(txindex);
|
||||
let outputcount = txindex_to_output_count_iter.unwrap_get_inner(txindex);
|
||||
|
||||
let pool = (*outputindex..(*outputindex + *outputcount))
|
||||
.map(OutputIndex::from)
|
||||
.find_map(|outputindex| {
|
||||
let pool = (*txoutindex..(*txoutindex + *outputcount))
|
||||
.map(TxOutIndex::from)
|
||||
.find_map(|txoutindex| {
|
||||
let outputtype =
|
||||
outputindex_to_outputtype_iter.unwrap_get_inner(outputindex);
|
||||
txoutindex_to_outputtype_iter.unwrap_get_inner(txoutindex);
|
||||
let typeindex =
|
||||
outputindex_to_typeindex_iter.unwrap_get_inner(outputindex);
|
||||
txoutindex_to_typeindex_iter.unwrap_get_inner(txoutindex);
|
||||
|
||||
match outputtype {
|
||||
OutputType::P2PK65 => Some(AddressBytes::from(
|
||||
|
||||
@@ -5,7 +5,7 @@ use brk_error::Result;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_structs::{
|
||||
Bitcoin, CheckedSub, DateIndex, DecadeIndex, DifficultyEpoch, Dollars, FeeRate, HalvingEpoch,
|
||||
Height, InputIndex, MonthIndex, ONE_DAY_IN_SEC_F64, OutputIndex, QuarterIndex, Sats,
|
||||
Height, TxInIndex, MonthIndex, ONE_DAY_IN_SEC_F64, TxOutIndex, QuarterIndex, Sats,
|
||||
SemesterIndex, StoredBool, StoredF32, StoredF64, StoredU32, StoredU64, Timestamp, TxIndex,
|
||||
TxVersion, Version, WeekIndex, Weight, YearIndex,
|
||||
};
|
||||
@@ -73,12 +73,12 @@ pub struct Vecs {
|
||||
pub indexes_to_fee_rate: ComputedVecsFromTxindex<FeeRate>,
|
||||
/// Value == 0 when Coinbase
|
||||
pub txindex_to_input_value:
|
||||
LazyVecFrom3<TxIndex, Sats, TxIndex, InputIndex, TxIndex, StoredU64, InputIndex, Sats>,
|
||||
LazyVecFrom3<TxIndex, Sats, TxIndex, TxInIndex, TxIndex, StoredU64, TxInIndex, 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:
|
||||
LazyVecFrom3<TxIndex, Sats, TxIndex, OutputIndex, TxIndex, StoredU64, OutputIndex, Sats>,
|
||||
LazyVecFrom3<TxIndex, Sats, TxIndex, TxOutIndex, TxIndex, StoredU64, TxOutIndex, Sats>,
|
||||
// pub indexes_to_output_value: ComputedVecsFromTxindex<Sats>,
|
||||
pub indexes_to_p2a_count: ComputedVecsFromHeight<StoredU64>,
|
||||
pub indexes_to_p2ms_count: ComputedVecsFromHeight<StoredU64>,
|
||||
@@ -98,8 +98,8 @@ 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 inputindex_to_value:
|
||||
LazyVecFrom2<InputIndex, Sats, InputIndex, OutputIndex, OutputIndex, Sats>,
|
||||
pub txinindex_to_value:
|
||||
LazyVecFrom2<TxInIndex, Sats, TxInIndex, TxOutIndex, TxOutIndex, 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>,
|
||||
@@ -159,24 +159,24 @@ impl Vecs {
|
||||
|
||||
let compute_dollars = price.is_some();
|
||||
|
||||
let inputindex_to_value = LazyVecFrom2::init(
|
||||
let txinindex_to_value = LazyVecFrom2::init(
|
||||
"value",
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.inputindex_to_outputindex.boxed_clone(),
|
||||
indexer.vecs.outputindex_to_value.boxed_clone(),
|
||||
|index: InputIndex, inputindex_to_outputindex_iter, outputindex_to_value_iter| {
|
||||
inputindex_to_outputindex_iter
|
||||
indexer.vecs.txinindex_to_txoutindex.boxed_clone(),
|
||||
indexer.vecs.txoutindex_to_value.boxed_clone(),
|
||||
|index: TxInIndex, txinindex_to_txoutindex_iter, txoutindex_to_value_iter| {
|
||||
txinindex_to_txoutindex_iter
|
||||
.next_at(index.unwrap_to_usize())
|
||||
.map(|(inputindex, outputindex)| {
|
||||
let outputindex = outputindex.into_owned();
|
||||
if outputindex == OutputIndex::COINBASE {
|
||||
.map(|(txinindex, txoutindex)| {
|
||||
let txoutindex = txoutindex.into_owned();
|
||||
if txoutindex == TxOutIndex::COINBASE {
|
||||
Sats::ZERO
|
||||
} else if let Some((_, value)) =
|
||||
outputindex_to_value_iter.next_at(outputindex.unwrap_to_usize())
|
||||
txoutindex_to_value_iter.next_at(txoutindex.unwrap_to_usize())
|
||||
{
|
||||
value.into_owned()
|
||||
} else {
|
||||
dbg!(inputindex, outputindex);
|
||||
dbg!(txinindex, txoutindex);
|
||||
panic!()
|
||||
}
|
||||
})
|
||||
@@ -245,15 +245,15 @@ impl Vecs {
|
||||
let txindex_to_input_value = LazyVecFrom3::init(
|
||||
"input_value",
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.txindex_to_first_inputindex.boxed_clone(),
|
||||
indexer.vecs.txindex_to_first_txinindex.boxed_clone(),
|
||||
indexes.txindex_to_input_count.boxed_clone(),
|
||||
inputindex_to_value.boxed_clone(),
|
||||
txinindex_to_value.boxed_clone(),
|
||||
|index: TxIndex,
|
||||
txindex_to_first_inputindex_iter,
|
||||
txindex_to_first_txinindex_iter,
|
||||
txindex_to_input_count_iter,
|
||||
inputindex_to_value_iter| {
|
||||
txinindex_to_value_iter| {
|
||||
let txindex = index.unwrap_to_usize();
|
||||
txindex_to_first_inputindex_iter
|
||||
txindex_to_first_txinindex_iter
|
||||
.next_at(txindex)
|
||||
.map(|(_, first_index)| {
|
||||
let first_index = usize::from(first_index.into_owned());
|
||||
@@ -263,10 +263,10 @@ impl Vecs {
|
||||
.1
|
||||
.into_owned();
|
||||
let range = first_index..first_index + count as usize;
|
||||
range.into_iter().fold(Sats::ZERO, |total, inputindex| {
|
||||
range.into_iter().fold(Sats::ZERO, |total, txinindex| {
|
||||
total
|
||||
+ inputindex_to_value_iter
|
||||
.next_at(inputindex)
|
||||
+ txinindex_to_value_iter
|
||||
.next_at(txinindex)
|
||||
.unwrap()
|
||||
.1
|
||||
.into_owned()
|
||||
@@ -292,15 +292,15 @@ impl Vecs {
|
||||
let txindex_to_output_value = LazyVecFrom3::init(
|
||||
"output_value",
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.txindex_to_first_outputindex.boxed_clone(),
|
||||
indexer.vecs.txindex_to_first_txoutindex.boxed_clone(),
|
||||
indexes.txindex_to_output_count.boxed_clone(),
|
||||
indexer.vecs.outputindex_to_value.boxed_clone(),
|
||||
indexer.vecs.txoutindex_to_value.boxed_clone(),
|
||||
|index: TxIndex,
|
||||
txindex_to_first_outputindex_iter,
|
||||
txindex_to_first_txoutindex_iter,
|
||||
txindex_to_output_count_iter,
|
||||
outputindex_to_value_iter| {
|
||||
txoutindex_to_value_iter| {
|
||||
let txindex = index.unwrap_to_usize();
|
||||
txindex_to_first_outputindex_iter
|
||||
txindex_to_first_txoutindex_iter
|
||||
.next_at(txindex)
|
||||
.map(|(_, first_index)| {
|
||||
let first_index = usize::from(first_index.into_owned());
|
||||
@@ -310,9 +310,9 @@ impl Vecs {
|
||||
.1
|
||||
.into_owned();
|
||||
let range = first_index..first_index + count as usize;
|
||||
range.into_iter().fold(Sats::ZERO, |total, outputindex| {
|
||||
let v = outputindex_to_value_iter
|
||||
.next_at(outputindex)
|
||||
range.into_iter().fold(Sats::ZERO, |total, txoutindex| {
|
||||
let v = txoutindex_to_value_iter
|
||||
.next_at(txoutindex)
|
||||
.unwrap()
|
||||
.1
|
||||
.into_owned();
|
||||
@@ -1139,7 +1139,7 @@ impl Vecs {
|
||||
)?,
|
||||
|
||||
txindex_to_is_coinbase,
|
||||
inputindex_to_value,
|
||||
txinindex_to_value,
|
||||
// indexes_to_input_value,
|
||||
// indexes_to_output_value,
|
||||
txindex_to_input_value,
|
||||
@@ -1432,9 +1432,9 @@ impl Vecs {
|
||||
// |vec| {
|
||||
// vec.compute_sum_from_indexes(
|
||||
// starting_indexes.txindex,
|
||||
// &indexer.vecs.txindex_to_first_outputindex,
|
||||
// &indexer.vecs.txindex_to_first_txoutindex,
|
||||
// self.indexes_to_output_count.txindex.as_ref().unwrap(),
|
||||
// &indexer.vecs.outputindex_to_value,
|
||||
// &indexer.vecs.txoutindex_to_value,
|
||||
// exit,
|
||||
// )
|
||||
// },
|
||||
@@ -1448,9 +1448,9 @@ impl Vecs {
|
||||
// |vec| {
|
||||
// vec.compute_sum_from_indexes(
|
||||
// starting_indexes.txindex,
|
||||
// &indexer.vecs.txindex_to_first_inputindex,
|
||||
// &indexer.vecs.txindex_to_first_txinindex,
|
||||
// self.indexes_to_input_count.txindex.as_ref().unwrap(),
|
||||
// &self.inputindex_to_value,
|
||||
// &self.txinindex_to_value,
|
||||
// exit,
|
||||
// )
|
||||
// },
|
||||
@@ -1529,23 +1529,23 @@ impl Vecs {
|
||||
|
||||
self.indexes_to_coinbase
|
||||
.compute_all(indexes, price, starting_indexes, exit, |vec| {
|
||||
let mut txindex_to_first_outputindex_iter =
|
||||
indexer.vecs.txindex_to_first_outputindex.iter();
|
||||
let mut txindex_to_first_txoutindex_iter =
|
||||
indexer.vecs.txindex_to_first_txoutindex.iter();
|
||||
let mut txindex_to_output_count_iter = indexes.txindex_to_output_count.iter();
|
||||
let mut outputindex_to_value_iter = indexer.vecs.outputindex_to_value.iter();
|
||||
let mut txoutindex_to_value_iter = indexer.vecs.txoutindex_to_value.iter();
|
||||
vec.compute_transform(
|
||||
starting_indexes.height,
|
||||
&indexer.vecs.height_to_first_txindex,
|
||||
|(height, txindex, ..)| {
|
||||
let first_outputindex = txindex_to_first_outputindex_iter
|
||||
let first_txoutindex = txindex_to_first_txoutindex_iter
|
||||
.unwrap_get_inner(txindex)
|
||||
.unwrap_to_usize();
|
||||
let output_count = txindex_to_output_count_iter.unwrap_get_inner(txindex);
|
||||
let mut sats = Sats::ZERO;
|
||||
(first_outputindex..first_outputindex + usize::from(output_count))
|
||||
.for_each(|outputindex| {
|
||||
sats += outputindex_to_value_iter
|
||||
.unwrap_get_inner(OutputIndex::from(outputindex));
|
||||
(first_txoutindex..first_txoutindex + usize::from(output_count))
|
||||
.for_each(|txoutindex| {
|
||||
sats += txoutindex_to_value_iter
|
||||
.unwrap_get_inner(TxOutIndex::from(txoutindex));
|
||||
});
|
||||
(height, sats)
|
||||
},
|
||||
|
||||
@@ -4,7 +4,7 @@ use brk_error::Result;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_structs::{
|
||||
Date, DateIndex, DecadeIndex, DifficultyEpoch, EmptyOutputIndex, HalvingEpoch, Height,
|
||||
InputIndex, MonthIndex, OpReturnIndex, OutputIndex, P2AAddressIndex, P2ABytes, P2MSOutputIndex,
|
||||
TxInIndex, MonthIndex, OpReturnIndex, TxOutIndex, P2AAddressIndex, P2ABytes, P2MSOutputIndex,
|
||||
P2PK33AddressIndex, P2PK33Bytes, P2PK65AddressIndex, P2PK65Bytes, P2PKHAddressIndex,
|
||||
P2PKHBytes, P2SHAddressIndex, P2SHBytes, P2TRAddressIndex, P2TRBytes, P2WPKHAddressIndex,
|
||||
P2WPKHBytes, P2WSHAddressIndex, P2WSHBytes, QuarterIndex, Sats, SemesterIndex, StoredU64,
|
||||
@@ -46,7 +46,7 @@ pub struct Vecs {
|
||||
pub height_to_height: EagerVec<Height, Height>,
|
||||
pub height_to_timestamp_fixed: EagerVec<Height, Timestamp>,
|
||||
pub height_to_txindex_count: EagerVec<Height, StoredU64>,
|
||||
pub inputindex_to_inputindex: LazyVecFrom1<InputIndex, InputIndex, InputIndex, OutputIndex>,
|
||||
pub txinindex_to_txinindex: LazyVecFrom1<TxInIndex, TxInIndex, TxInIndex, TxOutIndex>,
|
||||
pub monthindex_to_dateindex_count: EagerVec<MonthIndex, StoredU64>,
|
||||
pub monthindex_to_first_dateindex: EagerVec<MonthIndex, DateIndex>,
|
||||
pub monthindex_to_monthindex: EagerVec<MonthIndex, MonthIndex>,
|
||||
@@ -55,8 +55,8 @@ pub struct Vecs {
|
||||
pub monthindex_to_yearindex: EagerVec<MonthIndex, YearIndex>,
|
||||
pub opreturnindex_to_opreturnindex:
|
||||
LazyVecFrom1<OpReturnIndex, OpReturnIndex, OpReturnIndex, TxIndex>,
|
||||
pub outputindex_to_outputindex: LazyVecFrom1<OutputIndex, OutputIndex, OutputIndex, Sats>,
|
||||
pub outputindex_to_txindex: EagerVec<OutputIndex, TxIndex>,
|
||||
pub txoutindex_to_txoutindex: LazyVecFrom1<TxOutIndex, TxOutIndex, TxOutIndex, Sats>,
|
||||
pub txoutindex_to_txindex: EagerVec<TxOutIndex, TxIndex>,
|
||||
pub p2aaddressindex_to_p2aaddressindex:
|
||||
LazyVecFrom1<P2AAddressIndex, P2AAddressIndex, P2AAddressIndex, P2ABytes>,
|
||||
pub p2msoutputindex_to_p2msoutputindex:
|
||||
@@ -83,9 +83,9 @@ pub struct Vecs {
|
||||
pub semesterindex_to_semesterindex: EagerVec<SemesterIndex, SemesterIndex>,
|
||||
pub txindex_to_height: EagerVec<TxIndex, Height>,
|
||||
pub txindex_to_input_count:
|
||||
LazyVecFrom2<TxIndex, StoredU64, TxIndex, InputIndex, InputIndex, OutputIndex>,
|
||||
LazyVecFrom2<TxIndex, StoredU64, TxIndex, TxInIndex, TxInIndex, TxOutIndex>,
|
||||
pub txindex_to_output_count:
|
||||
LazyVecFrom2<TxIndex, StoredU64, TxIndex, OutputIndex, OutputIndex, Sats>,
|
||||
LazyVecFrom2<TxIndex, StoredU64, TxIndex, TxOutIndex, TxOutIndex, Sats>,
|
||||
pub txindex_to_txindex: LazyVecFrom1<TxIndex, TxIndex, TxIndex, Txid>,
|
||||
pub unknownoutputindex_to_unknownoutputindex:
|
||||
LazyVecFrom1<UnknownOutputIndex, UnknownOutputIndex, UnknownOutputIndex, TxIndex>,
|
||||
@@ -103,17 +103,17 @@ impl Vecs {
|
||||
let db = Database::open(&parent.join("indexes"))?;
|
||||
db.set_min_len(PAGE_SIZE * 10_000_000)?;
|
||||
|
||||
let outputindex_to_outputindex = LazyVecFrom1::init(
|
||||
"outputindex",
|
||||
let txoutindex_to_txoutindex = LazyVecFrom1::init(
|
||||
"txoutindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
indexer.vecs.outputindex_to_value.boxed_clone(),
|
||||
indexer.vecs.txoutindex_to_value.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
);
|
||||
|
||||
let inputindex_to_inputindex = LazyVecFrom1::init(
|
||||
"inputindex",
|
||||
let txinindex_to_txinindex = LazyVecFrom1::init(
|
||||
"txinindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
indexer.vecs.inputindex_to_outputindex.boxed_clone(),
|
||||
indexer.vecs.txinindex_to_txoutindex.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
);
|
||||
|
||||
@@ -127,18 +127,18 @@ impl Vecs {
|
||||
let txindex_to_input_count = LazyVecFrom2::init(
|
||||
"input_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
indexer.vecs.txindex_to_first_inputindex.boxed_clone(),
|
||||
indexer.vecs.inputindex_to_outputindex.boxed_clone(),
|
||||
|index: TxIndex, txindex_to_first_inputindex_iter, inputindex_to_outputindex_iter| {
|
||||
indexer.vecs.txindex_to_first_txinindex.boxed_clone(),
|
||||
indexer.vecs.txinindex_to_txoutindex.boxed_clone(),
|
||||
|index: TxIndex, txindex_to_first_txinindex_iter, txinindex_to_txoutindex_iter| {
|
||||
let txindex = index.unwrap_to_usize();
|
||||
txindex_to_first_inputindex_iter
|
||||
txindex_to_first_txinindex_iter
|
||||
.next_at(txindex)
|
||||
.map(|(_, start)| {
|
||||
let start = usize::from(start.into_owned());
|
||||
let end = txindex_to_first_inputindex_iter
|
||||
let end = txindex_to_first_txinindex_iter
|
||||
.next_at(txindex + 1)
|
||||
.map(|(_, v)| usize::from(v.into_owned()))
|
||||
.unwrap_or_else(|| inputindex_to_outputindex_iter.len());
|
||||
.unwrap_or_else(|| txinindex_to_txoutindex_iter.len());
|
||||
StoredU64::from((start..end).count())
|
||||
})
|
||||
},
|
||||
@@ -147,18 +147,18 @@ impl Vecs {
|
||||
let txindex_to_output_count = LazyVecFrom2::init(
|
||||
"output_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
indexer.vecs.txindex_to_first_outputindex.boxed_clone(),
|
||||
indexer.vecs.outputindex_to_value.boxed_clone(),
|
||||
|index: TxIndex, txindex_to_first_outputindex_iter, outputindex_to_value_iter| {
|
||||
indexer.vecs.txindex_to_first_txoutindex.boxed_clone(),
|
||||
indexer.vecs.txoutindex_to_value.boxed_clone(),
|
||||
|index: TxIndex, txindex_to_first_txoutindex_iter, txoutindex_to_value_iter| {
|
||||
let txindex = index.unwrap_to_usize();
|
||||
txindex_to_first_outputindex_iter
|
||||
txindex_to_first_txoutindex_iter
|
||||
.next_at(txindex)
|
||||
.map(|(_, start)| {
|
||||
let start = usize::from(start.into_owned());
|
||||
let end = txindex_to_first_outputindex_iter
|
||||
let end = txindex_to_first_txoutindex_iter
|
||||
.next_at(txindex + 1)
|
||||
.map(|(_, v)| usize::from(v.into_owned()))
|
||||
.unwrap_or_else(|| outputindex_to_value_iter.len());
|
||||
.unwrap_or_else(|| txoutindex_to_value_iter.len());
|
||||
StoredU64::from((start..end).count())
|
||||
})
|
||||
},
|
||||
@@ -239,9 +239,9 @@ impl Vecs {
|
||||
|
||||
let this = Self {
|
||||
emptyoutputindex_to_emptyoutputindex,
|
||||
inputindex_to_inputindex,
|
||||
txinindex_to_txinindex,
|
||||
opreturnindex_to_opreturnindex,
|
||||
outputindex_to_outputindex,
|
||||
txoutindex_to_txoutindex,
|
||||
p2aaddressindex_to_p2aaddressindex,
|
||||
p2msoutputindex_to_p2msoutputindex,
|
||||
p2pk33addressindex_to_p2pk33addressindex,
|
||||
@@ -466,7 +466,7 @@ impl Vecs {
|
||||
"yearindex_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
)?,
|
||||
outputindex_to_txindex: EagerVec::forced_import_compressed(
|
||||
txoutindex_to_txindex: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"txindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -502,12 +502,12 @@ impl Vecs {
|
||||
exit: &Exit,
|
||||
) -> Result<Indexes> {
|
||||
// ---
|
||||
// OutputIndex
|
||||
// TxOutIndex
|
||||
// ---
|
||||
|
||||
self.outputindex_to_txindex.compute_inverse_less_to_more(
|
||||
self.txoutindex_to_txindex.compute_inverse_less_to_more(
|
||||
starting_indexes.txindex,
|
||||
&indexer.vecs.txindex_to_first_outputindex,
|
||||
&indexer.vecs.txindex_to_first_txoutindex,
|
||||
&self.txindex_to_output_count,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -4,7 +4,7 @@ use allocative::Allocative;
|
||||
use brk_error::Result;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_store::AnyStore;
|
||||
use brk_structs::{Address, AddressBytes, Height, OutputIndex, OutputType, PoolId, Pools, pools};
|
||||
use brk_structs::{Address, AddressBytes, Height, TxOutIndex, OutputType, PoolId, Pools, pools};
|
||||
use brk_traversable::Traversable;
|
||||
use rayon::prelude::*;
|
||||
use vecdb::{
|
||||
@@ -122,11 +122,11 @@ impl Vecs {
|
||||
)?;
|
||||
|
||||
let mut height_to_first_txindex_iter = indexer.vecs.height_to_first_txindex.iter();
|
||||
let mut txindex_to_first_outputindex_iter =
|
||||
indexer.vecs.txindex_to_first_outputindex.iter();
|
||||
let mut txindex_to_first_txoutindex_iter =
|
||||
indexer.vecs.txindex_to_first_txoutindex.iter();
|
||||
let mut txindex_to_output_count_iter = indexes.txindex_to_output_count.iter();
|
||||
let mut outputindex_to_outputtype_iter = indexer.vecs.outputindex_to_outputtype.iter();
|
||||
let mut outputindex_to_typeindex_iter = indexer.vecs.outputindex_to_typeindex.iter();
|
||||
let mut txoutindex_to_outputtype_iter = indexer.vecs.txoutindex_to_outputtype.iter();
|
||||
let mut txoutindex_to_typeindex_iter = indexer.vecs.txoutindex_to_typeindex.iter();
|
||||
let mut p2pk65addressindex_to_p2pk65bytes_iter =
|
||||
indexer.vecs.p2pk65addressindex_to_p2pk65bytes.iter();
|
||||
let mut p2pk33addressindex_to_p2pk33bytes_iter =
|
||||
@@ -157,15 +157,15 @@ impl Vecs {
|
||||
.skip(min)
|
||||
.try_for_each(|(height, coinbase_tag)| -> Result<()> {
|
||||
let txindex = height_to_first_txindex_iter.unwrap_get_inner(height);
|
||||
let outputindex = txindex_to_first_outputindex_iter.unwrap_get_inner(txindex);
|
||||
let txoutindex = txindex_to_first_txoutindex_iter.unwrap_get_inner(txindex);
|
||||
let outputcount = txindex_to_output_count_iter.unwrap_get_inner(txindex);
|
||||
|
||||
let pool = (*outputindex..(*outputindex + *outputcount))
|
||||
.map(OutputIndex::from)
|
||||
.find_map(|outputindex| {
|
||||
let pool = (*txoutindex..(*txoutindex + *outputcount))
|
||||
.map(TxOutIndex::from)
|
||||
.find_map(|txoutindex| {
|
||||
let outputtype =
|
||||
outputindex_to_outputtype_iter.unwrap_get_inner(outputindex);
|
||||
let typeindex = outputindex_to_typeindex_iter.unwrap_get_inner(outputindex);
|
||||
txoutindex_to_outputtype_iter.unwrap_get_inner(txoutindex);
|
||||
let typeindex = txoutindex_to_typeindex_iter.unwrap_get_inner(txoutindex);
|
||||
|
||||
match outputtype {
|
||||
OutputType::P2PK65 => Some(AddressBytes::from(
|
||||
|
||||
@@ -11,7 +11,7 @@ use brk_grouper::{ByAddressType, ByAnyAddress, Filtered};
|
||||
use brk_indexer::Indexer;
|
||||
use brk_structs::{
|
||||
AnyAddressDataIndexEnum, AnyAddressIndex, CheckedSub, DateIndex, Dollars, EmptyAddressData,
|
||||
EmptyAddressIndex, Height, InputIndex, LoadedAddressData, LoadedAddressIndex, OutputIndex,
|
||||
EmptyAddressIndex, Height, TxInIndex, LoadedAddressData, LoadedAddressIndex, TxOutIndex,
|
||||
OutputType, P2AAddressIndex, P2PK33AddressIndex, P2PK65AddressIndex, P2PKHAddressIndex,
|
||||
P2SHAddressIndex, P2TRAddressIndex, P2WPKHAddressIndex, P2WSHAddressIndex, Sats, StoredU64,
|
||||
Timestamp, TypeIndex, Version,
|
||||
@@ -530,8 +530,8 @@ impl Vecs {
|
||||
starting_indexes: &mut Indexes,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
let height_to_first_outputindex = &indexer.vecs.height_to_first_outputindex;
|
||||
let height_to_first_inputindex = &indexer.vecs.height_to_first_inputindex;
|
||||
let height_to_first_txoutindex = &indexer.vecs.height_to_first_txoutindex;
|
||||
let height_to_first_txinindex = &indexer.vecs.height_to_first_txinindex;
|
||||
let height_to_first_p2aaddressindex = &indexer.vecs.height_to_first_p2aaddressindex;
|
||||
let height_to_first_p2pk33addressindex = &indexer.vecs.height_to_first_p2pk33addressindex;
|
||||
let height_to_first_p2pk65addressindex = &indexer.vecs.height_to_first_p2pk65addressindex;
|
||||
@@ -542,13 +542,13 @@ impl Vecs {
|
||||
let height_to_first_p2wshaddressindex = &indexer.vecs.height_to_first_p2wshaddressindex;
|
||||
let height_to_output_count = chain.indexes_to_output_count.height.unwrap_sum();
|
||||
let height_to_input_count = chain.indexes_to_input_count.height.unwrap_sum();
|
||||
let inputindex_to_outputindex = &indexer.vecs.inputindex_to_outputindex;
|
||||
let outputindex_to_value = &indexer.vecs.outputindex_to_value;
|
||||
let txinindex_to_txoutindex = &indexer.vecs.txinindex_to_txoutindex;
|
||||
let txoutindex_to_value = &indexer.vecs.txoutindex_to_value;
|
||||
let txindex_to_height = &indexes.txindex_to_height;
|
||||
let height_to_timestamp_fixed = &indexes.height_to_timestamp_fixed;
|
||||
let outputindex_to_txindex = &indexes.outputindex_to_txindex;
|
||||
let outputindex_to_outputtype = &indexer.vecs.outputindex_to_outputtype;
|
||||
let outputindex_to_typeindex = &indexer.vecs.outputindex_to_typeindex;
|
||||
let txoutindex_to_txindex = &indexes.txoutindex_to_txindex;
|
||||
let txoutindex_to_outputtype = &indexer.vecs.txoutindex_to_outputtype;
|
||||
let txoutindex_to_typeindex = &indexer.vecs.txoutindex_to_typeindex;
|
||||
let height_to_unclaimed_rewards = chain
|
||||
.indexes_to_unclaimed_rewards
|
||||
.sats
|
||||
@@ -569,8 +569,8 @@ impl Vecs {
|
||||
let mut height_to_timestamp_fixed_iter = height_to_timestamp_fixed.into_iter();
|
||||
|
||||
let base_version = Version::ZERO
|
||||
+ height_to_first_outputindex.version()
|
||||
+ height_to_first_inputindex.version()
|
||||
+ height_to_first_txoutindex.version()
|
||||
+ height_to_first_txinindex.version()
|
||||
+ height_to_first_p2aaddressindex.version()
|
||||
+ height_to_first_p2pk33addressindex.version()
|
||||
+ height_to_first_p2pk65addressindex.version()
|
||||
@@ -582,12 +582,12 @@ impl Vecs {
|
||||
+ height_to_timestamp_fixed.version()
|
||||
+ height_to_output_count.version()
|
||||
+ height_to_input_count.version()
|
||||
+ inputindex_to_outputindex.version()
|
||||
+ outputindex_to_value.version()
|
||||
+ txinindex_to_txoutindex.version()
|
||||
+ txoutindex_to_value.version()
|
||||
+ txindex_to_height.version()
|
||||
+ outputindex_to_txindex.version()
|
||||
+ outputindex_to_outputtype.version()
|
||||
+ outputindex_to_typeindex.version()
|
||||
+ txoutindex_to_txindex.version()
|
||||
+ txoutindex_to_outputtype.version()
|
||||
+ txoutindex_to_typeindex.version()
|
||||
+ height_to_unclaimed_rewards.version()
|
||||
+ height_to_price_close
|
||||
.as_ref()
|
||||
@@ -790,13 +790,13 @@ impl Vecs {
|
||||
|
||||
starting_indexes.update_from_height(starting_height, indexes);
|
||||
|
||||
let inputindex_to_outputindex_reader = inputindex_to_outputindex.create_reader();
|
||||
let outputindex_to_value_reader = outputindex_to_value.create_reader();
|
||||
let outputindex_to_outputtype_reader = outputindex_to_outputtype.create_reader();
|
||||
let outputindex_to_typeindex_reader = outputindex_to_typeindex.create_reader();
|
||||
let txinindex_to_txoutindex_reader = txinindex_to_txoutindex.create_reader();
|
||||
let txoutindex_to_value_reader = txoutindex_to_value.create_reader();
|
||||
let txoutindex_to_outputtype_reader = txoutindex_to_outputtype.create_reader();
|
||||
let txoutindex_to_typeindex_reader = txoutindex_to_typeindex.create_reader();
|
||||
|
||||
let mut height_to_first_outputindex_iter = height_to_first_outputindex.into_iter();
|
||||
let mut height_to_first_inputindex_iter = height_to_first_inputindex.into_iter();
|
||||
let mut height_to_first_txoutindex_iter = height_to_first_txoutindex.into_iter();
|
||||
let mut height_to_first_txinindex_iter = height_to_first_txinindex.into_iter();
|
||||
let mut height_to_first_p2aaddressindex_iter =
|
||||
height_to_first_p2aaddressindex.into_iter();
|
||||
let mut height_to_first_p2pk33addressindex_iter =
|
||||
@@ -826,7 +826,7 @@ impl Vecs {
|
||||
height_to_price_close.map(|height_to_price_close| height_to_price_close.collect());
|
||||
|
||||
let height_to_timestamp_fixed_vec = height_to_timestamp_fixed.collect();
|
||||
let outputindex_range_to_height = RangeMap::from(height_to_first_outputindex);
|
||||
let txoutindex_range_to_height = RangeMap::from(height_to_first_txoutindex);
|
||||
|
||||
let mut unspendable_supply = if let Some(prev_height) = starting_height.decremented() {
|
||||
self.height_to_unspendable_supply
|
||||
@@ -893,10 +893,10 @@ impl Vecs {
|
||||
let price = height_to_price_close_iter
|
||||
.as_mut()
|
||||
.map(|i| *i.unwrap_get_inner(height));
|
||||
let first_outputindex = height_to_first_outputindex_iter
|
||||
let first_txoutindex = height_to_first_txoutindex_iter
|
||||
.unwrap_get_inner(height)
|
||||
.unwrap_to_usize();
|
||||
let first_inputindex = height_to_first_inputindex_iter
|
||||
let first_txinindex = height_to_first_txinindex_iter
|
||||
.unwrap_get_inner(height)
|
||||
.unwrap_to_usize();
|
||||
let output_count = height_to_output_count_iter.unwrap_get_inner(height);
|
||||
@@ -941,22 +941,22 @@ impl Vecs {
|
||||
.tick_tock_next_block(&chain_state, timestamp);
|
||||
});
|
||||
|
||||
let (transacted, addresstype_to_typedindex_to_received_data, receiving_addresstype_to_typeindex_to_addressdatawithsource) = (first_outputindex..first_outputindex + usize::from(output_count))
|
||||
let (transacted, addresstype_to_typedindex_to_received_data, receiving_addresstype_to_typeindex_to_addressdatawithsource) = (first_txoutindex..first_txoutindex + usize::from(output_count))
|
||||
.into_par_iter()
|
||||
.map(OutputIndex::from)
|
||||
.map(|outputindex| {
|
||||
let value = outputindex_to_value
|
||||
.unwrap_read(outputindex, &outputindex_to_value_reader);
|
||||
.map(TxOutIndex::from)
|
||||
.map(|txoutindex| {
|
||||
let value = txoutindex_to_value
|
||||
.unwrap_read(txoutindex, &txoutindex_to_value_reader);
|
||||
|
||||
let output_type = outputindex_to_outputtype
|
||||
.unwrap_read(outputindex, &outputindex_to_outputtype_reader);
|
||||
let output_type = txoutindex_to_outputtype
|
||||
.unwrap_read(txoutindex, &txoutindex_to_outputtype_reader);
|
||||
|
||||
if output_type.is_not_address() {
|
||||
return (value, output_type, None);
|
||||
}
|
||||
|
||||
let typeindex = outputindex_to_typeindex
|
||||
.unwrap_read(outputindex, &outputindex_to_typeindex_reader);
|
||||
let typeindex = txoutindex_to_typeindex
|
||||
.unwrap_read(txoutindex, &txoutindex_to_typeindex_reader);
|
||||
|
||||
let addressdata_opt = Self::get_addressdatawithsource(
|
||||
output_type,
|
||||
@@ -1025,28 +1025,28 @@ impl Vecs {
|
||||
);
|
||||
|
||||
// Skip coinbase
|
||||
let (height_to_sent, addresstype_to_typedindex_to_sent_data, sending_addresstype_to_typeindex_to_addressdatawithsource) = (first_inputindex + 1..first_inputindex + usize::from(input_count))
|
||||
let (height_to_sent, addresstype_to_typedindex_to_sent_data, sending_addresstype_to_typeindex_to_addressdatawithsource) = (first_txinindex + 1..first_txinindex + usize::from(input_count))
|
||||
.into_par_iter()
|
||||
.map(InputIndex::from)
|
||||
.map(|inputindex| {
|
||||
let outputindex =
|
||||
inputindex_to_outputindex.unwrap_read(inputindex, &inputindex_to_outputindex_reader);
|
||||
.map(TxInIndex::from)
|
||||
.map(|txinindex| {
|
||||
let txoutindex =
|
||||
txinindex_to_txoutindex.unwrap_read(txinindex, &txinindex_to_txoutindex_reader);
|
||||
|
||||
let value = outputindex_to_value
|
||||
.unwrap_read(outputindex, &outputindex_to_value_reader);
|
||||
let value = txoutindex_to_value
|
||||
.unwrap_read(txoutindex, &txoutindex_to_value_reader);
|
||||
|
||||
let input_type = outputindex_to_outputtype
|
||||
.unwrap_read(outputindex, &outputindex_to_outputtype_reader);
|
||||
let input_type = txoutindex_to_outputtype
|
||||
.unwrap_read(txoutindex, &txoutindex_to_outputtype_reader);
|
||||
|
||||
let prev_height =
|
||||
*outputindex_range_to_height.get(outputindex).unwrap();
|
||||
*txoutindex_range_to_height.get(txoutindex).unwrap();
|
||||
|
||||
if input_type.is_not_address() {
|
||||
return (prev_height, value, input_type, None);
|
||||
}
|
||||
|
||||
let typeindex = outputindex_to_typeindex
|
||||
.unwrap_read(outputindex, &outputindex_to_typeindex_reader);
|
||||
let typeindex = txoutindex_to_typeindex
|
||||
.unwrap_read(txoutindex, &txoutindex_to_typeindex_reader);
|
||||
|
||||
let addressdata_opt = Self::get_addressdatawithsource(
|
||||
input_type,
|
||||
|
||||
@@ -83,15 +83,15 @@ Main indexing function processing blocks from parser with collision detection.
|
||||
|
||||
- `height_to_*`: Block-level data (hash, timestamp, difficulty, size, weight)
|
||||
- `txindex_to_*`: Transaction data (ID, version, locktime, size, RBF flag)
|
||||
- `outputindex_to_*`: Output data (value, type, address mapping)
|
||||
- `inputindex_to_outputindex`: Input-to-output relationship mapping
|
||||
- `txoutindex_to_*`: Output data (value, type, address mapping)
|
||||
- `txinindex_to_txoutindex`: Input-to-output relationship mapping
|
||||
|
||||
**Key-Value Stores:**
|
||||
|
||||
- `addressbyteshash_to_typeindex`: Address hash to internal index mapping
|
||||
- `blockhashprefix_to_height`: Block hash prefix to height lookup
|
||||
- `txidprefix_to_txindex`: Transaction ID prefix to internal index
|
||||
- `addresstype_to_typeindex_with_outputindex`: Address type to output mappings
|
||||
- `addresstype_to_typeindex_with_txoutindex`: Address type to output mappings
|
||||
|
||||
### Address Type Support
|
||||
|
||||
@@ -189,7 +189,7 @@ let indexer = Indexer::forced_import("./blockchain_index")?;
|
||||
|
||||
// Analyze address distribution by type
|
||||
for output_type in OutputType::as_vec() {
|
||||
let count = indexer.vecs.outputindex_to_outputtype
|
||||
let count = indexer.vecs.txoutindex_to_outputtype
|
||||
.iter()
|
||||
.filter(|&ot| ot == output_type)
|
||||
.count();
|
||||
@@ -198,7 +198,7 @@ for output_type in OutputType::as_vec() {
|
||||
}
|
||||
|
||||
// Query specific address type data
|
||||
let p2pkh_store = &indexer.stores.addresstype_to_typeindex_with_outputindex
|
||||
let p2pkh_store = &indexer.stores.addresstype_to_typeindex_with_txoutindex
|
||||
.p2pkh;
|
||||
|
||||
println!("P2PKH addresses: {}", p2pkh_store.len());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use bitcoincore_rpc::Client;
|
||||
use brk_error::{Error, Result};
|
||||
use brk_structs::{
|
||||
BlockHash, CheckedSub, EmptyOutputIndex, Height, InputIndex, OpReturnIndex, OutputIndex,
|
||||
BlockHash, CheckedSub, EmptyOutputIndex, Height, TxInIndex, OpReturnIndex, TxOutIndex,
|
||||
OutputType, P2AAddressIndex, P2MSOutputIndex, P2PK33AddressIndex, P2PK65AddressIndex,
|
||||
P2PKHAddressIndex, P2SHAddressIndex, P2TRAddressIndex, P2WPKHAddressIndex, P2WSHAddressIndex,
|
||||
TxIndex, TypeIndex, UnknownOutputIndex,
|
||||
@@ -29,8 +29,8 @@ pub struct Indexes {
|
||||
pub p2wshaddressindex: P2WSHAddressIndex,
|
||||
pub p2aaddressindex: P2AAddressIndex,
|
||||
pub txindex: TxIndex,
|
||||
pub inputindex: InputIndex,
|
||||
pub outputindex: OutputIndex,
|
||||
pub txinindex: TxInIndex,
|
||||
pub txoutindex: TxOutIndex,
|
||||
pub unknownoutputindex: UnknownOutputIndex,
|
||||
}
|
||||
|
||||
@@ -57,10 +57,10 @@ impl Indexes {
|
||||
let height = self.height;
|
||||
vecs.height_to_first_txindex
|
||||
.push_if_needed(height, self.txindex)?;
|
||||
vecs.height_to_first_inputindex
|
||||
.push_if_needed(height, self.inputindex)?;
|
||||
vecs.height_to_first_outputindex
|
||||
.push_if_needed(height, self.outputindex)?;
|
||||
vecs.height_to_first_txinindex
|
||||
.push_if_needed(height, self.txinindex)?;
|
||||
vecs.height_to_first_txoutindex
|
||||
.push_if_needed(height, self.txoutindex)?;
|
||||
vecs.height_to_first_emptyoutputindex
|
||||
.push_if_needed(height, self.emptyoutputindex)?;
|
||||
vecs.height_to_first_p2msoutputindex
|
||||
@@ -232,23 +232,23 @@ impl TryFrom<(&mut Vecs, &Stores, &Client)> for Indexes {
|
||||
|
||||
// dbg!(txindex);
|
||||
|
||||
let inputindex = starting_index(
|
||||
&vecs.height_to_first_inputindex,
|
||||
&vecs.inputindex_to_outputindex,
|
||||
let txinindex = starting_index(
|
||||
&vecs.height_to_first_txinindex,
|
||||
&vecs.txinindex_to_txoutindex,
|
||||
height,
|
||||
)
|
||||
.ok_or(Error::Str(""))?;
|
||||
|
||||
// dbg!(inputindex);
|
||||
// dbg!(txinindex);
|
||||
|
||||
let outputindex = starting_index(
|
||||
&vecs.height_to_first_outputindex,
|
||||
&vecs.outputindex_to_value,
|
||||
let txoutindex = starting_index(
|
||||
&vecs.height_to_first_txoutindex,
|
||||
&vecs.txoutindex_to_value,
|
||||
height,
|
||||
)
|
||||
.ok_or(Error::Str(""))?;
|
||||
|
||||
// dbg!(outputindex);
|
||||
// dbg!(txoutindex);
|
||||
|
||||
let unknownoutputindex = starting_index(
|
||||
&vecs.height_to_first_unknownoutputindex,
|
||||
@@ -273,8 +273,8 @@ impl TryFrom<(&mut Vecs, &Stores, &Client)> for Indexes {
|
||||
p2wshaddressindex,
|
||||
p2aaddressindex,
|
||||
txindex,
|
||||
inputindex,
|
||||
outputindex,
|
||||
txinindex,
|
||||
txoutindex,
|
||||
unknownoutputindex,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ use bitcoin::{Transaction, TxIn, TxOut};
|
||||
use brk_error::{Error, Result};
|
||||
use brk_store::AnyStore;
|
||||
use brk_structs::{
|
||||
AddressBytes, AddressBytesHash, BlockHashPrefix, Height, InputIndex, OutputIndex, OutputType,
|
||||
Sats, StoredBool, Timestamp, TxIndex, Txid, TxidPrefix, TypeIndex, TypeIndexWithOutputindex,
|
||||
Unit, Version, Vin, Vout,
|
||||
AddressBytes, AddressBytesHash, BlockHashPrefix, Height, OutputType, Sats, StoredBool,
|
||||
Timestamp, TxInIndex, TxIndex, TxOutIndex, Txid, TxidPrefix, TypeIndex,
|
||||
TypeIndexWithOutputindex, Unit, Version, Vin, Vout,
|
||||
};
|
||||
use log::{error, info};
|
||||
use rayon::prelude::*;
|
||||
@@ -23,7 +23,7 @@ pub use vecs::*;
|
||||
|
||||
// One version for all data sources
|
||||
// Increment on **change _OR_ addition**
|
||||
const VERSION: Version = Version::new(21);
|
||||
const VERSION: Version = Version::new(22);
|
||||
const SNAPSHOT_BLOCK_RANGE: usize = 1_000;
|
||||
const COLLISIONS_CHECKED_UP_TO: Height = Height::new(909_150);
|
||||
|
||||
@@ -102,7 +102,7 @@ impl Indexer {
|
||||
Ok(())
|
||||
};
|
||||
|
||||
let mut txindex_to_first_outputindex_reader_opt = None;
|
||||
let mut txindex_to_first_txoutindex_reader_opt = None;
|
||||
let mut p2pk65addressindex_to_p2pk65bytes_reader_opt = None;
|
||||
let mut p2pk33addressindex_to_p2pk33bytes_reader_opt = None;
|
||||
let mut p2pkhaddressindex_to_p2pkhbytes_reader_opt = None;
|
||||
@@ -114,7 +114,7 @@ impl Indexer {
|
||||
|
||||
let reset_readers =
|
||||
|vecs: &mut Vecs,
|
||||
txindex_to_first_outputindex_reader_opt: &mut Option<Reader<'static>>,
|
||||
txindex_to_first_txoutindex_reader_opt: &mut Option<Reader<'static>>,
|
||||
p2pk65addressindex_to_p2pk65bytes_reader_opt: &mut Option<Reader<'static>>,
|
||||
p2pk33addressindex_to_p2pk33bytes_reader_opt: &mut Option<Reader<'static>>,
|
||||
p2pkhaddressindex_to_p2pkhbytes_reader_opt: &mut Option<Reader<'static>>,
|
||||
@@ -123,8 +123,8 @@ impl Indexer {
|
||||
p2wshaddressindex_to_p2wshbytes_reader_opt: &mut Option<Reader<'static>>,
|
||||
p2traddressindex_to_p2trbytes_reader_opt: &mut Option<Reader<'static>>,
|
||||
p2aaddressindex_to_p2abytes_reader_opt: &mut Option<Reader<'static>>| {
|
||||
txindex_to_first_outputindex_reader_opt
|
||||
.replace(vecs.txindex_to_first_outputindex.create_static_reader());
|
||||
txindex_to_first_txoutindex_reader_opt
|
||||
.replace(vecs.txindex_to_first_txoutindex.create_static_reader());
|
||||
p2pk65addressindex_to_p2pk65bytes_reader_opt.replace(
|
||||
vecs.p2pk65addressindex_to_p2pk65bytes
|
||||
.create_static_reader(),
|
||||
@@ -151,7 +151,7 @@ impl Indexer {
|
||||
|
||||
reset_readers(
|
||||
vecs,
|
||||
&mut txindex_to_first_outputindex_reader_opt,
|
||||
&mut txindex_to_first_txoutindex_reader_opt,
|
||||
&mut p2pk65addressindex_to_p2pk65bytes_reader_opt,
|
||||
&mut p2pk33addressindex_to_p2pk33bytes_reader_opt,
|
||||
&mut p2pkhaddressindex_to_p2pkhbytes_reader_opt,
|
||||
@@ -171,7 +171,7 @@ impl Indexer {
|
||||
|
||||
idxs.height = height;
|
||||
|
||||
let txindex_to_first_outputindex_reader = txindex_to_first_outputindex_reader_opt.as_ref().unwrap();
|
||||
let txindex_to_first_txoutindex_reader = txindex_to_first_txoutindex_reader_opt.as_ref().unwrap();
|
||||
let p2pk65addressindex_to_p2pk65bytes_reader = p2pk65addressindex_to_p2pk65bytes_reader_opt.as_ref().unwrap();
|
||||
let p2pk33addressindex_to_p2pk33bytes_reader = p2pk33addressindex_to_p2pk33bytes_reader_opt.as_ref().unwrap();
|
||||
let p2pkhaddressindex_to_p2pkhbytes_reader = p2pkhaddressindex_to_p2pkhbytes_reader_opt.as_ref().unwrap();
|
||||
@@ -249,15 +249,15 @@ impl Indexer {
|
||||
let input_source_vec = inputs
|
||||
.into_par_iter()
|
||||
.enumerate()
|
||||
.map(|(block_inputindex, (block_txindex, vin, txin, tx))| -> Result<(InputIndex, InputSource)> {
|
||||
.map(|(block_txinindex, (block_txindex, vin, txin, tx))| -> Result<(TxInIndex, InputSource)> {
|
||||
let txindex = idxs.txindex + block_txindex;
|
||||
let inputindex = idxs.inputindex + InputIndex::from(block_inputindex);
|
||||
let txinindex = idxs.txinindex + TxInIndex::from(block_txinindex);
|
||||
|
||||
let outpoint = txin.previous_output;
|
||||
let txid = Txid::from(outpoint.txid);
|
||||
|
||||
if tx.is_coinbase() {
|
||||
return Ok((inputindex, InputSource::SameBlock((tx, txindex, txin, vin))));
|
||||
return Ok((txinindex, InputSource::SameBlock((tx, txindex, txin, vin))));
|
||||
}
|
||||
|
||||
let prev_txindex = if let Some(txindex) = stores
|
||||
@@ -271,22 +271,22 @@ impl Indexer {
|
||||
txindex
|
||||
} else {
|
||||
// dbg!(indexes.txindex + block_txindex, txindex, txin, vin);
|
||||
return Ok((inputindex, InputSource::SameBlock((tx, txindex, txin, vin))));
|
||||
return Ok((txinindex, InputSource::SameBlock((tx, txindex, txin, vin))));
|
||||
};
|
||||
|
||||
let vout = Vout::from(outpoint.vout);
|
||||
|
||||
let outputindex = vecs.txindex_to_first_outputindex.get_or_read(prev_txindex, txindex_to_first_outputindex_reader)?
|
||||
.ok_or(Error::Str("Expect outputindex to not be none"))
|
||||
let txoutindex = vecs.txindex_to_first_txoutindex.get_or_read(prev_txindex, txindex_to_first_txoutindex_reader)?
|
||||
.ok_or(Error::Str("Expect txoutindex to not be none"))
|
||||
.inspect_err(|_| {
|
||||
dbg!(outpoint.txid, prev_txindex, vout);
|
||||
})?.into_owned()
|
||||
+ vout;
|
||||
|
||||
Ok((inputindex, InputSource::PreviousBlock((
|
||||
Ok((txinindex, InputSource::PreviousBlock((
|
||||
vin,
|
||||
txindex,
|
||||
outputindex,
|
||||
txoutindex,
|
||||
))))
|
||||
})
|
||||
.try_fold(BTreeMap::new, |mut map, tuple| -> Result<_> {
|
||||
@@ -315,12 +315,12 @@ impl Indexer {
|
||||
.map(move |(vout, txout)| (TxIndex::from(index), Vout::from(vout), txout, tx))
|
||||
}).collect::<Vec<_>>();
|
||||
|
||||
let outputindex_to_txout_outputtype_addressbytes_res_addressindex_opt = outputs.into_par_iter()
|
||||
let txoutindex_to_txout_outputtype_addressbytes_res_addressindex_opt = outputs.into_par_iter()
|
||||
.enumerate()
|
||||
.map(
|
||||
#[allow(clippy::type_complexity)]
|
||||
|(block_outputindex, (block_txindex, vout, txout, tx))| -> Result<(
|
||||
OutputIndex,
|
||||
|(block_txoutindex, (block_txindex, vout, txout, tx))| -> Result<(
|
||||
TxOutIndex,
|
||||
(
|
||||
&TxOut,
|
||||
TxIndex,
|
||||
@@ -332,7 +332,7 @@ impl Indexer {
|
||||
),
|
||||
)> {
|
||||
let txindex = idxs.txindex + block_txindex;
|
||||
let outputindex = idxs.outputindex + OutputIndex::from(block_outputindex);
|
||||
let txoutindex = idxs.txoutindex + TxOutIndex::from(block_txoutindex);
|
||||
|
||||
let script = &txout.script_pubkey;
|
||||
|
||||
@@ -421,7 +421,7 @@ impl Indexer {
|
||||
}
|
||||
|
||||
Ok((
|
||||
outputindex,
|
||||
txoutindex,
|
||||
(
|
||||
txout,
|
||||
txindex,
|
||||
@@ -449,35 +449,35 @@ impl Indexer {
|
||||
}
|
||||
})?;
|
||||
|
||||
let outputs_len = outputindex_to_txout_outputtype_addressbytes_res_addressindex_opt.len();
|
||||
let outputs_len = txoutindex_to_txout_outputtype_addressbytes_res_addressindex_opt.len();
|
||||
let inputs_len = input_source_vec.len();
|
||||
let tx_len = block.txdata.len();
|
||||
|
||||
let mut new_txindexvout_to_outputindex: BTreeMap<
|
||||
let mut new_txindexvout_to_txoutindex: BTreeMap<
|
||||
(TxIndex, Vout),
|
||||
OutputIndex,
|
||||
TxOutIndex,
|
||||
> = BTreeMap::new();
|
||||
|
||||
let mut already_added_addressbyteshash: BTreeMap<AddressBytesHash, TypeIndex> = BTreeMap::new();
|
||||
|
||||
outputindex_to_txout_outputtype_addressbytes_res_addressindex_opt
|
||||
txoutindex_to_txout_outputtype_addressbytes_res_addressindex_opt
|
||||
.into_iter()
|
||||
.try_for_each(
|
||||
|(
|
||||
outputindex,
|
||||
txoutindex,
|
||||
(txout, txindex, vout, outputtype, addressbytes_res, typeindex_opt, _tx),
|
||||
)|
|
||||
-> Result<()> {
|
||||
let sats = Sats::from(txout.value);
|
||||
|
||||
if vout.is_zero() {
|
||||
vecs.txindex_to_first_outputindex.push_if_needed(txindex, outputindex)?;
|
||||
vecs.txindex_to_first_txoutindex.push_if_needed(txindex, txoutindex)?;
|
||||
}
|
||||
|
||||
vecs.outputindex_to_value.push_if_needed(outputindex, sats)?;
|
||||
vecs.txoutindex_to_value.push_if_needed(txoutindex, sats)?;
|
||||
|
||||
vecs.outputindex_to_outputtype
|
||||
.push_if_needed(outputindex, outputtype)?;
|
||||
vecs.txoutindex_to_outputtype
|
||||
.push_if_needed(txoutindex, outputtype)?;
|
||||
|
||||
let mut addressbyteshash = None;
|
||||
|
||||
@@ -556,14 +556,14 @@ impl Indexer {
|
||||
}
|
||||
}
|
||||
|
||||
vecs.outputindex_to_typeindex
|
||||
.push_if_needed(outputindex, typeindex)?;
|
||||
vecs.txoutindex_to_typeindex
|
||||
.push_if_needed(txoutindex, typeindex)?;
|
||||
|
||||
new_txindexvout_to_outputindex
|
||||
.insert((txindex, vout), outputindex);
|
||||
new_txindexvout_to_txoutindex
|
||||
.insert((txindex, vout), txoutindex);
|
||||
|
||||
if outputtype.is_address() {
|
||||
stores.addresstype_to_typeindex_with_outputindex.get_mut(outputtype).unwrap().insert_if_needed(TypeIndexWithOutputindex::from((typeindex, outputindex)), Unit, height);
|
||||
stores.addresstype_to_typeindex_with_txoutindex.get_mut(outputtype).unwrap().insert_if_needed(TypeIndexWithOutputindex::from((typeindex, txoutindex)), Unit, height);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -576,14 +576,14 @@ impl Indexer {
|
||||
.into_iter()
|
||||
.map(
|
||||
#[allow(clippy::type_complexity)]
|
||||
|(inputindex, input_source)| -> Result<(
|
||||
InputIndex, Vin, TxIndex, OutputIndex
|
||||
|(txinindex, input_source)| -> Result<(
|
||||
TxInIndex, Vin, TxIndex, TxOutIndex
|
||||
)> {
|
||||
match input_source {
|
||||
InputSource::PreviousBlock((vin, txindex, outputindex)) => Ok((inputindex, vin, txindex, outputindex)),
|
||||
InputSource::PreviousBlock((vin, txindex, txoutindex)) => Ok((txinindex, vin, txindex, txoutindex)),
|
||||
InputSource::SameBlock((tx, txindex, txin, vin)) => {
|
||||
if tx.is_coinbase() {
|
||||
return Ok((inputindex, vin, txindex, OutputIndex::COINBASE));
|
||||
return Ok((txinindex, vin, txindex, TxOutIndex::COINBASE));
|
||||
}
|
||||
|
||||
let outpoint = txin.previous_output;
|
||||
@@ -599,31 +599,31 @@ impl Indexer {
|
||||
.2;
|
||||
let prev_txindex = idxs.txindex + block_txindex;
|
||||
|
||||
let prev_outputindex = new_txindexvout_to_outputindex
|
||||
let prev_txoutindex = new_txindexvout_to_txoutindex
|
||||
.remove(&(prev_txindex, vout))
|
||||
.ok_or(Error::Str("should have found addressindex from same block"))
|
||||
.inspect_err(|_| {
|
||||
dbg!(&new_txindexvout_to_outputindex, txin, prev_txindex, vout, txid);
|
||||
dbg!(&new_txindexvout_to_txoutindex, txin, prev_txindex, vout, txid);
|
||||
})?;
|
||||
|
||||
Ok((inputindex, vin, txindex, prev_outputindex))
|
||||
Ok((txinindex, vin, txindex, prev_txoutindex))
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
.try_for_each(|res| -> Result<()> {
|
||||
let (inputindex, vin, txindex, outputindex) = res?;
|
||||
let (txinindex, vin, txindex, txoutindex) = res?;
|
||||
|
||||
if vin.is_zero() {
|
||||
vecs.txindex_to_first_inputindex.push_if_needed(txindex, inputindex)?;
|
||||
vecs.txindex_to_first_txinindex.push_if_needed(txindex, txinindex)?;
|
||||
}
|
||||
|
||||
vecs.inputindex_to_outputindex.push_if_needed(inputindex, outputindex)?;
|
||||
vecs.txinindex_to_txoutindex.push_if_needed(txinindex, txoutindex)?;
|
||||
|
||||
Ok(())
|
||||
})?;
|
||||
|
||||
drop(new_txindexvout_to_outputindex);
|
||||
drop(new_txindexvout_to_txoutindex);
|
||||
|
||||
let mut txindex_to_tx_and_txid: BTreeMap<TxIndex, (&Transaction, Txid)> = BTreeMap::default();
|
||||
|
||||
@@ -708,11 +708,11 @@ impl Indexer {
|
||||
})?;
|
||||
|
||||
idxs.txindex += TxIndex::from(tx_len);
|
||||
idxs.inputindex += InputIndex::from(inputs_len);
|
||||
idxs.outputindex += OutputIndex::from(outputs_len);
|
||||
idxs.txinindex += TxInIndex::from(inputs_len);
|
||||
idxs.txoutindex += TxOutIndex::from(outputs_len);
|
||||
|
||||
if should_export(height, false) {
|
||||
txindex_to_first_outputindex_reader_opt.take();
|
||||
txindex_to_first_txoutindex_reader_opt.take();
|
||||
p2pk65addressindex_to_p2pk65bytes_reader_opt.take();
|
||||
p2pk33addressindex_to_p2pk33bytes_reader_opt.take();
|
||||
p2pkhaddressindex_to_p2pkhbytes_reader_opt.take();
|
||||
@@ -726,7 +726,7 @@ impl Indexer {
|
||||
|
||||
reset_readers(
|
||||
vecs,
|
||||
&mut txindex_to_first_outputindex_reader_opt,
|
||||
&mut txindex_to_first_txoutindex_reader_opt,
|
||||
&mut p2pk65addressindex_to_p2pk65bytes_reader_opt,
|
||||
&mut p2pk33addressindex_to_p2pk33bytes_reader_opt,
|
||||
&mut p2pkhaddressindex_to_p2pkhbytes_reader_opt,
|
||||
@@ -742,7 +742,7 @@ impl Indexer {
|
||||
},
|
||||
)?;
|
||||
|
||||
txindex_to_first_outputindex_reader_opt.take();
|
||||
txindex_to_first_txoutindex_reader_opt.take();
|
||||
p2pk65addressindex_to_p2pk65bytes_reader_opt.take();
|
||||
p2pk33addressindex_to_p2pk33bytes_reader_opt.take();
|
||||
p2pkhaddressindex_to_p2pkhbytes_reader_opt.take();
|
||||
@@ -770,6 +770,6 @@ impl Indexer {
|
||||
|
||||
#[derive(Debug)]
|
||||
enum InputSource<'a> {
|
||||
PreviousBlock((Vin, TxIndex, OutputIndex)),
|
||||
PreviousBlock((Vin, TxIndex, TxOutIndex)),
|
||||
SameBlock((&'a Transaction, TxIndex, &'a TxIn, Vin)),
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ use brk_error::Result;
|
||||
use brk_grouper::ByAddressType;
|
||||
use brk_store::{AnyStore, Store};
|
||||
use brk_structs::{
|
||||
AddressBytes, AddressBytesHash, BlockHashPrefix, Height, OutputIndex, OutputType, StoredString,
|
||||
TxIndex, TxidPrefix, TypeIndex, TypeIndexWithOutputindex, Unit, Version,
|
||||
AddressBytes, AddressBytesHash, BlockHashPrefix, Height, OutputType, StoredString, TxIndex,
|
||||
TxOutIndex, TxidPrefix, TypeIndex, TypeIndexWithOutputindex, Unit, Version,
|
||||
};
|
||||
use fjall::{PersistMode, TransactionalKeyspace};
|
||||
use rayon::prelude::*;
|
||||
@@ -23,7 +23,9 @@ pub struct Stores {
|
||||
pub blockhashprefix_to_height: Store<BlockHashPrefix, Height>,
|
||||
pub height_to_coinbase_tag: Store<Height, StoredString>,
|
||||
pub txidprefix_to_txindex: Store<TxidPrefix, TxIndex>,
|
||||
pub addresstype_to_typeindex_with_outputindex:
|
||||
// Do address_type_to_typeindex_with_txindex_to_vin_and_vout_instead ?
|
||||
// and should vin be txoutindex or txinindex?
|
||||
pub addresstype_to_typeindex_with_txoutindex:
|
||||
ByAddressType<Store<TypeIndexWithOutputindex, Unit>>,
|
||||
}
|
||||
|
||||
@@ -56,74 +58,74 @@ impl Stores {
|
||||
});
|
||||
let txidprefix_to_txindex = scope
|
||||
.spawn(|| Store::import(&keyspace, &path, "txidprefix_to_txindex", version, None));
|
||||
let p2aaddressindex_with_outputindex = scope.spawn(|| {
|
||||
let p2aaddressindex_with_txoutindex = scope.spawn(|| {
|
||||
Store::import(
|
||||
&keyspace,
|
||||
&path,
|
||||
"p2aaddressindex_with_outputindex",
|
||||
"p2aaddressindex_with_txoutindex",
|
||||
version,
|
||||
Some(false),
|
||||
)
|
||||
});
|
||||
let p2pk33addressindex_with_outputindex = scope.spawn(|| {
|
||||
let p2pk33addressindex_with_txoutindex = scope.spawn(|| {
|
||||
Store::import(
|
||||
&keyspace,
|
||||
&path,
|
||||
"p2pk33addressindex_with_outputindex",
|
||||
"p2pk33addressindex_with_txoutindex",
|
||||
version,
|
||||
Some(false),
|
||||
)
|
||||
});
|
||||
let p2pk65addressindex_with_outputindex = scope.spawn(|| {
|
||||
let p2pk65addressindex_with_txoutindex = scope.spawn(|| {
|
||||
Store::import(
|
||||
&keyspace,
|
||||
&path,
|
||||
"p2pk65addressindex_with_outputindex",
|
||||
"p2pk65addressindex_with_txoutindex",
|
||||
version,
|
||||
Some(false),
|
||||
)
|
||||
});
|
||||
let p2pkhaddressindex_with_outputindex = scope.spawn(|| {
|
||||
let p2pkhaddressindex_with_txoutindex = scope.spawn(|| {
|
||||
Store::import(
|
||||
&keyspace,
|
||||
&path,
|
||||
"p2pkhaddressindex_with_outputindex",
|
||||
"p2pkhaddressindex_with_txoutindex",
|
||||
version,
|
||||
Some(false),
|
||||
)
|
||||
});
|
||||
let p2shaddressindex_with_outputindex = scope.spawn(|| {
|
||||
let p2shaddressindex_with_txoutindex = scope.spawn(|| {
|
||||
Store::import(
|
||||
&keyspace,
|
||||
&path,
|
||||
"p2shaddressindex_with_outputindex",
|
||||
"p2shaddressindex_with_txoutindex",
|
||||
version,
|
||||
Some(false),
|
||||
)
|
||||
});
|
||||
let p2traddressindex_with_outputindex = scope.spawn(|| {
|
||||
let p2traddressindex_with_txoutindex = scope.spawn(|| {
|
||||
Store::import(
|
||||
&keyspace,
|
||||
&path,
|
||||
"p2traddressindex_with_outputindex",
|
||||
"p2traddressindex_with_txoutindex",
|
||||
version,
|
||||
Some(false),
|
||||
)
|
||||
});
|
||||
let p2wpkhaddressindex_with_outputindex = scope.spawn(|| {
|
||||
let p2wpkhaddressindex_with_txoutindex = scope.spawn(|| {
|
||||
Store::import(
|
||||
&keyspace,
|
||||
&path,
|
||||
"p2wpkhaddressindex_with_outputindex",
|
||||
"p2wpkhaddressindex_with_txoutindex",
|
||||
version,
|
||||
Some(false),
|
||||
)
|
||||
});
|
||||
let p2wshaddressindex_with_outputindex = scope.spawn(|| {
|
||||
let p2wshaddressindex_with_txoutindex = scope.spawn(|| {
|
||||
Store::import(
|
||||
&keyspace,
|
||||
&path,
|
||||
"p2wshaddressindex_with_outputindex",
|
||||
"p2wshaddressindex_with_txoutindex",
|
||||
version,
|
||||
Some(false),
|
||||
)
|
||||
@@ -139,15 +141,15 @@ impl Stores {
|
||||
addressbyteshash_to_typeindex: addressbyteshash_to_typeindex.join().unwrap()?,
|
||||
blockhashprefix_to_height: blockhashprefix_to_height.join().unwrap()?,
|
||||
txidprefix_to_txindex: txidprefix_to_txindex.join().unwrap()?,
|
||||
addresstype_to_typeindex_with_outputindex: ByAddressType {
|
||||
p2pk65: p2pk65addressindex_with_outputindex.join().unwrap()?,
|
||||
p2pk33: p2pk33addressindex_with_outputindex.join().unwrap()?,
|
||||
p2pkh: p2pkhaddressindex_with_outputindex.join().unwrap()?,
|
||||
p2sh: p2shaddressindex_with_outputindex.join().unwrap()?,
|
||||
p2wpkh: p2wpkhaddressindex_with_outputindex.join().unwrap()?,
|
||||
p2wsh: p2wshaddressindex_with_outputindex.join().unwrap()?,
|
||||
p2tr: p2traddressindex_with_outputindex.join().unwrap()?,
|
||||
p2a: p2aaddressindex_with_outputindex.join().unwrap()?,
|
||||
addresstype_to_typeindex_with_txoutindex: ByAddressType {
|
||||
p2pk65: p2pk65addressindex_with_txoutindex.join().unwrap()?,
|
||||
p2pk33: p2pk33addressindex_with_txoutindex.join().unwrap()?,
|
||||
p2pkh: p2pkhaddressindex_with_txoutindex.join().unwrap()?,
|
||||
p2sh: p2shaddressindex_with_txoutindex.join().unwrap()?,
|
||||
p2wpkh: p2wpkhaddressindex_with_txoutindex.join().unwrap()?,
|
||||
p2wsh: p2wshaddressindex_with_txoutindex.join().unwrap()?,
|
||||
p2tr: p2traddressindex_with_txoutindex.join().unwrap()?,
|
||||
p2a: p2aaddressindex_with_txoutindex.join().unwrap()?,
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -178,14 +180,14 @@ impl Stores {
|
||||
fn as_slice(&self) -> [&(dyn AnyStore + Send + Sync); 12] {
|
||||
[
|
||||
&self.addressbyteshash_to_typeindex,
|
||||
&self.addresstype_to_typeindex_with_outputindex.p2a,
|
||||
&self.addresstype_to_typeindex_with_outputindex.p2pk33,
|
||||
&self.addresstype_to_typeindex_with_outputindex.p2pk65,
|
||||
&self.addresstype_to_typeindex_with_outputindex.p2pkh,
|
||||
&self.addresstype_to_typeindex_with_outputindex.p2sh,
|
||||
&self.addresstype_to_typeindex_with_outputindex.p2tr,
|
||||
&self.addresstype_to_typeindex_with_outputindex.p2wpkh,
|
||||
&self.addresstype_to_typeindex_with_outputindex.p2wsh,
|
||||
&self.addresstype_to_typeindex_with_txoutindex.p2a,
|
||||
&self.addresstype_to_typeindex_with_txoutindex.p2pk33,
|
||||
&self.addresstype_to_typeindex_with_txoutindex.p2pk65,
|
||||
&self.addresstype_to_typeindex_with_txoutindex.p2pkh,
|
||||
&self.addresstype_to_typeindex_with_txoutindex.p2sh,
|
||||
&self.addresstype_to_typeindex_with_txoutindex.p2tr,
|
||||
&self.addresstype_to_typeindex_with_txoutindex.p2wpkh,
|
||||
&self.addresstype_to_typeindex_with_txoutindex.p2wsh,
|
||||
&self.blockhashprefix_to_height,
|
||||
&self.height_to_coinbase_tag,
|
||||
&self.txidprefix_to_txindex,
|
||||
@@ -195,14 +197,14 @@ impl Stores {
|
||||
fn as_mut_slice(&mut self) -> [&mut (dyn AnyStore + Send + Sync); 12] {
|
||||
[
|
||||
&mut self.addressbyteshash_to_typeindex,
|
||||
&mut self.addresstype_to_typeindex_with_outputindex.p2a,
|
||||
&mut self.addresstype_to_typeindex_with_outputindex.p2pk33,
|
||||
&mut self.addresstype_to_typeindex_with_outputindex.p2pk65,
|
||||
&mut self.addresstype_to_typeindex_with_outputindex.p2pkh,
|
||||
&mut self.addresstype_to_typeindex_with_outputindex.p2sh,
|
||||
&mut self.addresstype_to_typeindex_with_outputindex.p2tr,
|
||||
&mut self.addresstype_to_typeindex_with_outputindex.p2wpkh,
|
||||
&mut self.addresstype_to_typeindex_with_outputindex.p2wsh,
|
||||
&mut self.addresstype_to_typeindex_with_txoutindex.p2a,
|
||||
&mut self.addresstype_to_typeindex_with_txoutindex.p2pk33,
|
||||
&mut self.addresstype_to_typeindex_with_txoutindex.p2pk65,
|
||||
&mut self.addresstype_to_typeindex_with_txoutindex.p2pkh,
|
||||
&mut self.addresstype_to_typeindex_with_txoutindex.p2sh,
|
||||
&mut self.addresstype_to_typeindex_with_txoutindex.p2tr,
|
||||
&mut self.addresstype_to_typeindex_with_txoutindex.p2wpkh,
|
||||
&mut self.addresstype_to_typeindex_with_txoutindex.p2wsh,
|
||||
&mut self.blockhashprefix_to_height,
|
||||
&mut self.height_to_coinbase_tag,
|
||||
&mut self.txidprefix_to_txindex,
|
||||
@@ -219,35 +221,35 @@ impl Stores {
|
||||
&& self.txidprefix_to_txindex.is_empty()?
|
||||
&& self.height_to_coinbase_tag.is_empty()?
|
||||
&& self
|
||||
.addresstype_to_typeindex_with_outputindex
|
||||
.addresstype_to_typeindex_with_txoutindex
|
||||
.p2a
|
||||
.is_empty()?
|
||||
&& self
|
||||
.addresstype_to_typeindex_with_outputindex
|
||||
.addresstype_to_typeindex_with_txoutindex
|
||||
.p2pk33
|
||||
.is_empty()?
|
||||
&& self
|
||||
.addresstype_to_typeindex_with_outputindex
|
||||
.addresstype_to_typeindex_with_txoutindex
|
||||
.p2pk65
|
||||
.is_empty()?
|
||||
&& self
|
||||
.addresstype_to_typeindex_with_outputindex
|
||||
.addresstype_to_typeindex_with_txoutindex
|
||||
.p2pkh
|
||||
.is_empty()?
|
||||
&& self
|
||||
.addresstype_to_typeindex_with_outputindex
|
||||
.addresstype_to_typeindex_with_txoutindex
|
||||
.p2sh
|
||||
.is_empty()?
|
||||
&& self
|
||||
.addresstype_to_typeindex_with_outputindex
|
||||
.addresstype_to_typeindex_with_txoutindex
|
||||
.p2tr
|
||||
.is_empty()?
|
||||
&& self
|
||||
.addresstype_to_typeindex_with_outputindex
|
||||
.addresstype_to_typeindex_with_txoutindex
|
||||
.p2wpkh
|
||||
.is_empty()?
|
||||
&& self
|
||||
.addresstype_to_typeindex_with_outputindex
|
||||
.addresstype_to_typeindex_with_txoutindex
|
||||
.p2wsh
|
||||
.is_empty()?
|
||||
{
|
||||
@@ -453,42 +455,38 @@ impl Stores {
|
||||
self.txidprefix_to_txindex.reset()?;
|
||||
}
|
||||
|
||||
if starting_indexes.outputindex != OutputIndex::ZERO {
|
||||
let mut outputindex_to_typeindex_iter = vecs.outputindex_to_typeindex.into_iter();
|
||||
vecs.outputindex_to_outputtype
|
||||
.iter_at(starting_indexes.outputindex)
|
||||
if starting_indexes.txoutindex != TxOutIndex::ZERO {
|
||||
let mut txoutindex_to_typeindex_iter = vecs.txoutindex_to_typeindex.into_iter();
|
||||
vecs.txoutindex_to_outputtype
|
||||
.iter_at(starting_indexes.txoutindex)
|
||||
.filter(|(_, outputtype)| outputtype.is_address())
|
||||
.for_each(|(outputindex, outputtype)| {
|
||||
.for_each(|(txoutindex, outputtype)| {
|
||||
let outputtype = outputtype.into_owned();
|
||||
|
||||
let typeindex = outputindex_to_typeindex_iter.unwrap_get_inner(outputindex);
|
||||
let typeindex = txoutindex_to_typeindex_iter.unwrap_get_inner(txoutindex);
|
||||
|
||||
self.addresstype_to_typeindex_with_outputindex
|
||||
self.addresstype_to_typeindex_with_txoutindex
|
||||
.get_mut(outputtype)
|
||||
.unwrap()
|
||||
.remove(TypeIndexWithOutputindex::from((typeindex, outputindex)));
|
||||
.remove(TypeIndexWithOutputindex::from((typeindex, txoutindex)));
|
||||
});
|
||||
} else {
|
||||
self.addresstype_to_typeindex_with_outputindex.p2a.reset()?;
|
||||
self.addresstype_to_typeindex_with_outputindex
|
||||
self.addresstype_to_typeindex_with_txoutindex.p2a.reset()?;
|
||||
self.addresstype_to_typeindex_with_txoutindex
|
||||
.p2pk33
|
||||
.reset()?;
|
||||
self.addresstype_to_typeindex_with_outputindex
|
||||
self.addresstype_to_typeindex_with_txoutindex
|
||||
.p2pk65
|
||||
.reset()?;
|
||||
self.addresstype_to_typeindex_with_outputindex
|
||||
self.addresstype_to_typeindex_with_txoutindex
|
||||
.p2pkh
|
||||
.reset()?;
|
||||
self.addresstype_to_typeindex_with_outputindex
|
||||
.p2sh
|
||||
.reset()?;
|
||||
self.addresstype_to_typeindex_with_outputindex
|
||||
.p2tr
|
||||
.reset()?;
|
||||
self.addresstype_to_typeindex_with_outputindex
|
||||
self.addresstype_to_typeindex_with_txoutindex.p2sh.reset()?;
|
||||
self.addresstype_to_typeindex_with_txoutindex.p2tr.reset()?;
|
||||
self.addresstype_to_typeindex_with_txoutindex
|
||||
.p2wpkh
|
||||
.reset()?;
|
||||
self.addresstype_to_typeindex_with_outputindex
|
||||
self.addresstype_to_typeindex_with_txoutindex
|
||||
.p2wsh
|
||||
.reset()?;
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@ use std::path::Path;
|
||||
|
||||
use brk_error::Result;
|
||||
use brk_structs::{
|
||||
AddressBytes, BlockHash, EmptyOutputIndex, Height, InputIndex, OpReturnIndex, OutputIndex,
|
||||
OutputType, P2AAddressIndex, P2ABytes, P2MSOutputIndex, P2PK33AddressIndex, P2PK33Bytes,
|
||||
P2PK65AddressIndex, P2PK65Bytes, P2PKHAddressIndex, P2PKHBytes, P2SHAddressIndex, P2SHBytes,
|
||||
P2TRAddressIndex, P2TRBytes, P2WPKHAddressIndex, P2WPKHBytes, P2WSHAddressIndex, P2WSHBytes,
|
||||
RawLockTime, Sats, StoredBool, StoredF64, StoredU32, StoredU64, Timestamp, TxIndex, TxVersion,
|
||||
Txid, TypeIndex, UnknownOutputIndex, Version, Weight,
|
||||
AddressBytes, BlockHash, EmptyOutputIndex, Height, OpReturnIndex, OutputType, P2AAddressIndex,
|
||||
P2ABytes, P2MSOutputIndex, P2PK33AddressIndex, P2PK33Bytes, P2PK65AddressIndex, P2PK65Bytes,
|
||||
P2PKHAddressIndex, P2PKHBytes, P2SHAddressIndex, P2SHBytes, P2TRAddressIndex, P2TRBytes,
|
||||
P2WPKHAddressIndex, P2WPKHBytes, P2WSHAddressIndex, P2WSHBytes, RawLockTime, Sats, StoredBool,
|
||||
StoredF64, StoredU32, StoredU64, Timestamp, TxInIndex, TxIndex, TxOutIndex, TxVersion, Txid,
|
||||
TypeIndex, UnknownOutputIndex, Version, Weight,
|
||||
};
|
||||
use brk_traversable::Traversable;
|
||||
use rayon::prelude::*;
|
||||
@@ -22,9 +22,9 @@ pub struct Vecs {
|
||||
pub height_to_blockhash: RawVec<Height, BlockHash>,
|
||||
pub height_to_difficulty: CompressedVec<Height, StoredF64>,
|
||||
pub height_to_first_emptyoutputindex: CompressedVec<Height, EmptyOutputIndex>,
|
||||
pub height_to_first_inputindex: CompressedVec<Height, InputIndex>,
|
||||
pub height_to_first_txinindex: CompressedVec<Height, TxInIndex>,
|
||||
pub height_to_first_opreturnindex: CompressedVec<Height, OpReturnIndex>,
|
||||
pub height_to_first_outputindex: CompressedVec<Height, OutputIndex>,
|
||||
pub height_to_first_txoutindex: CompressedVec<Height, TxOutIndex>,
|
||||
pub height_to_first_p2aaddressindex: CompressedVec<Height, P2AAddressIndex>,
|
||||
pub height_to_first_p2msoutputindex: CompressedVec<Height, P2MSOutputIndex>,
|
||||
pub height_to_first_p2pk33addressindex: CompressedVec<Height, P2PK33AddressIndex>,
|
||||
@@ -40,12 +40,12 @@ pub struct Vecs {
|
||||
pub height_to_timestamp: CompressedVec<Height, Timestamp>,
|
||||
pub height_to_total_size: CompressedVec<Height, StoredU64>,
|
||||
pub height_to_weight: CompressedVec<Height, Weight>,
|
||||
/// If outputindex == Outputindex::MAX then it's coinbase
|
||||
pub inputindex_to_outputindex: RawVec<InputIndex, OutputIndex>,
|
||||
/// If txoutindex == TxOutIndex::MAX then it's coinbase
|
||||
pub txinindex_to_txoutindex: RawVec<TxInIndex, TxOutIndex>,
|
||||
pub opreturnindex_to_txindex: CompressedVec<OpReturnIndex, TxIndex>,
|
||||
pub outputindex_to_outputtype: RawVec<OutputIndex, OutputType>,
|
||||
pub outputindex_to_typeindex: RawVec<OutputIndex, TypeIndex>,
|
||||
pub outputindex_to_value: RawVec<OutputIndex, Sats>,
|
||||
pub txoutindex_to_outputtype: RawVec<TxOutIndex, OutputType>,
|
||||
pub txoutindex_to_typeindex: RawVec<TxOutIndex, TypeIndex>,
|
||||
pub txoutindex_to_value: RawVec<TxOutIndex, Sats>,
|
||||
pub p2aaddressindex_to_p2abytes: RawVec<P2AAddressIndex, P2ABytes>,
|
||||
pub p2msoutputindex_to_txindex: CompressedVec<P2MSOutputIndex, TxIndex>,
|
||||
pub p2pk33addressindex_to_p2pk33bytes: RawVec<P2PK33AddressIndex, P2PK33Bytes>,
|
||||
@@ -56,8 +56,8 @@ pub struct Vecs {
|
||||
pub p2wpkhaddressindex_to_p2wpkhbytes: RawVec<P2WPKHAddressIndex, P2WPKHBytes>,
|
||||
pub p2wshaddressindex_to_p2wshbytes: RawVec<P2WSHAddressIndex, P2WSHBytes>,
|
||||
pub txindex_to_base_size: CompressedVec<TxIndex, StoredU32>,
|
||||
pub txindex_to_first_inputindex: CompressedVec<TxIndex, InputIndex>,
|
||||
pub txindex_to_first_outputindex: CompressedVec<TxIndex, OutputIndex>,
|
||||
pub txindex_to_first_txinindex: CompressedVec<TxIndex, TxInIndex>,
|
||||
pub txindex_to_first_txoutindex: CompressedVec<TxIndex, TxOutIndex>,
|
||||
pub txindex_to_is_explicitly_rbf: CompressedVec<TxIndex, StoredBool>,
|
||||
pub txindex_to_rawlocktime: CompressedVec<TxIndex, RawLockTime>,
|
||||
pub txindex_to_total_size: CompressedVec<TxIndex, StoredU32>,
|
||||
@@ -83,9 +83,9 @@ impl Vecs {
|
||||
"first_emptyoutputindex",
|
||||
version,
|
||||
)?,
|
||||
height_to_first_inputindex: CompressedVec::forced_import(
|
||||
height_to_first_txinindex: CompressedVec::forced_import(
|
||||
&db,
|
||||
"first_inputindex",
|
||||
"first_txinindex",
|
||||
version,
|
||||
)?,
|
||||
height_to_first_opreturnindex: CompressedVec::forced_import(
|
||||
@@ -93,9 +93,9 @@ impl Vecs {
|
||||
"first_opreturnindex",
|
||||
version,
|
||||
)?,
|
||||
height_to_first_outputindex: CompressedVec::forced_import(
|
||||
height_to_first_txoutindex: CompressedVec::forced_import(
|
||||
&db,
|
||||
"first_outputindex",
|
||||
"first_txoutindex",
|
||||
version,
|
||||
)?,
|
||||
height_to_first_p2aaddressindex: CompressedVec::forced_import(
|
||||
@@ -152,11 +152,11 @@ impl Vecs {
|
||||
height_to_timestamp: CompressedVec::forced_import(&db, "timestamp", version)?,
|
||||
height_to_total_size: CompressedVec::forced_import(&db, "total_size", version)?,
|
||||
height_to_weight: CompressedVec::forced_import(&db, "weight", version)?,
|
||||
inputindex_to_outputindex: RawVec::forced_import(&db, "outputindex", version)?,
|
||||
txinindex_to_txoutindex: RawVec::forced_import(&db, "txoutindex", version)?,
|
||||
opreturnindex_to_txindex: CompressedVec::forced_import(&db, "txindex", version)?,
|
||||
outputindex_to_outputtype: RawVec::forced_import(&db, "outputtype", version)?,
|
||||
outputindex_to_typeindex: RawVec::forced_import(&db, "typeindex", version)?,
|
||||
outputindex_to_value: RawVec::forced_import(&db, "value", version)?,
|
||||
txoutindex_to_outputtype: RawVec::forced_import(&db, "outputtype", version)?,
|
||||
txoutindex_to_typeindex: RawVec::forced_import(&db, "typeindex", version)?,
|
||||
txoutindex_to_value: RawVec::forced_import(&db, "value", version)?,
|
||||
p2aaddressindex_to_p2abytes: RawVec::forced_import(&db, "p2abytes", version)?,
|
||||
p2msoutputindex_to_txindex: CompressedVec::forced_import(&db, "txindex", version)?,
|
||||
p2pk33addressindex_to_p2pk33bytes: RawVec::forced_import(&db, "p2pk33bytes", version)?,
|
||||
@@ -167,14 +167,14 @@ impl Vecs {
|
||||
p2wpkhaddressindex_to_p2wpkhbytes: RawVec::forced_import(&db, "p2wpkhbytes", version)?,
|
||||
p2wshaddressindex_to_p2wshbytes: RawVec::forced_import(&db, "p2wshbytes", version)?,
|
||||
txindex_to_base_size: CompressedVec::forced_import(&db, "base_size", version)?,
|
||||
txindex_to_first_inputindex: CompressedVec::forced_import(
|
||||
txindex_to_first_txinindex: CompressedVec::forced_import(
|
||||
&db,
|
||||
"first_inputindex",
|
||||
"first_txinindex",
|
||||
version,
|
||||
)?,
|
||||
txindex_to_first_outputindex: CompressedVec::forced_import(
|
||||
txindex_to_first_txoutindex: CompressedVec::forced_import(
|
||||
&db,
|
||||
"first_outputindex",
|
||||
"first_txoutindex",
|
||||
version,
|
||||
)?,
|
||||
txindex_to_is_explicitly_rbf: CompressedVec::forced_import(
|
||||
@@ -206,9 +206,9 @@ impl Vecs {
|
||||
let &Indexes {
|
||||
emptyoutputindex,
|
||||
height,
|
||||
inputindex,
|
||||
txinindex,
|
||||
opreturnindex,
|
||||
outputindex,
|
||||
txoutindex,
|
||||
p2aaddressindex,
|
||||
p2msoutputindex,
|
||||
p2pk33addressindex,
|
||||
@@ -232,11 +232,11 @@ impl Vecs {
|
||||
.truncate_if_needed_with_stamp(height, stamp)?;
|
||||
self.height_to_first_emptyoutputindex
|
||||
.truncate_if_needed_with_stamp(height, stamp)?;
|
||||
self.height_to_first_inputindex
|
||||
self.height_to_first_txinindex
|
||||
.truncate_if_needed_with_stamp(height, stamp)?;
|
||||
self.height_to_first_opreturnindex
|
||||
.truncate_if_needed_with_stamp(height, stamp)?;
|
||||
self.height_to_first_outputindex
|
||||
self.height_to_first_txoutindex
|
||||
.truncate_if_needed_with_stamp(height, stamp)?;
|
||||
self.height_to_first_p2aaddressindex
|
||||
.truncate_if_needed_with_stamp(height, stamp)?;
|
||||
@@ -266,16 +266,16 @@ impl Vecs {
|
||||
.truncate_if_needed_with_stamp(height, stamp)?;
|
||||
self.height_to_weight
|
||||
.truncate_if_needed_with_stamp(height, stamp)?;
|
||||
self.inputindex_to_outputindex
|
||||
.truncate_if_needed_with_stamp(inputindex, stamp)?;
|
||||
self.txinindex_to_txoutindex
|
||||
.truncate_if_needed_with_stamp(txinindex, stamp)?;
|
||||
self.opreturnindex_to_txindex
|
||||
.truncate_if_needed_with_stamp(opreturnindex, stamp)?;
|
||||
self.outputindex_to_outputtype
|
||||
.truncate_if_needed_with_stamp(outputindex, stamp)?;
|
||||
self.outputindex_to_typeindex
|
||||
.truncate_if_needed_with_stamp(outputindex, stamp)?;
|
||||
self.outputindex_to_value
|
||||
.truncate_if_needed_with_stamp(outputindex, stamp)?;
|
||||
self.txoutindex_to_outputtype
|
||||
.truncate_if_needed_with_stamp(txoutindex, stamp)?;
|
||||
self.txoutindex_to_typeindex
|
||||
.truncate_if_needed_with_stamp(txoutindex, stamp)?;
|
||||
self.txoutindex_to_value
|
||||
.truncate_if_needed_with_stamp(txoutindex, stamp)?;
|
||||
self.p2aaddressindex_to_p2abytes
|
||||
.truncate_if_needed_with_stamp(p2aaddressindex, stamp)?;
|
||||
self.p2msoutputindex_to_txindex
|
||||
@@ -296,9 +296,9 @@ impl Vecs {
|
||||
.truncate_if_needed_with_stamp(p2wshaddressindex, stamp)?;
|
||||
self.txindex_to_base_size
|
||||
.truncate_if_needed_with_stamp(txindex, stamp)?;
|
||||
self.txindex_to_first_inputindex
|
||||
self.txindex_to_first_txinindex
|
||||
.truncate_if_needed_with_stamp(txindex, stamp)?;
|
||||
self.txindex_to_first_outputindex
|
||||
self.txindex_to_first_txoutindex
|
||||
.truncate_if_needed_with_stamp(txindex, stamp)?;
|
||||
self.txindex_to_is_explicitly_rbf
|
||||
.truncate_if_needed_with_stamp(txindex, stamp)?;
|
||||
@@ -375,9 +375,9 @@ impl Vecs {
|
||||
// &self.height_to_blockhash,
|
||||
// &self.height_to_difficulty,
|
||||
// &self.height_to_first_emptyoutputindex,
|
||||
// &self.height_to_first_inputindex,
|
||||
// &self.height_to_first_txinindex,
|
||||
// &self.height_to_first_opreturnindex,
|
||||
// &self.height_to_first_outputindex,
|
||||
// &self.height_to_first_txoutindex,
|
||||
// &self.height_to_first_p2aaddressindex,
|
||||
// &self.height_to_first_p2msoutputindex,
|
||||
// &self.height_to_first_p2pk33addressindex,
|
||||
@@ -392,11 +392,11 @@ impl Vecs {
|
||||
// &self.height_to_timestamp,
|
||||
// &self.height_to_total_size,
|
||||
// &self.height_to_weight,
|
||||
// &self.inputindex_to_outputindex,
|
||||
// &self.txinindex_to_txoutindex,
|
||||
// &self.opreturnindex_to_txindex,
|
||||
// &self.outputindex_to_outputtype,
|
||||
// &self.outputindex_to_typeindex,
|
||||
// &self.outputindex_to_value,
|
||||
// &self.txoutindex_to_outputtype,
|
||||
// &self.txoutindex_to_typeindex,
|
||||
// &self.txoutindex_to_value,
|
||||
// &self.p2aaddressindex_to_p2abytes,
|
||||
// &self.p2msoutputindex_to_txindex,
|
||||
// &self.p2pk33addressindex_to_p2pk33bytes,
|
||||
@@ -407,8 +407,8 @@ impl Vecs {
|
||||
// &self.p2wpkhaddressindex_to_p2wpkhbytes,
|
||||
// &self.p2wshaddressindex_to_p2wshbytes,
|
||||
// &self.txindex_to_base_size,
|
||||
// &self.txindex_to_first_inputindex,
|
||||
// &self.txindex_to_first_outputindex,
|
||||
// &self.txindex_to_first_txinindex,
|
||||
// &self.txindex_to_first_txoutindex,
|
||||
// &self.txindex_to_is_explicitly_rbf,
|
||||
// &self.txindex_to_rawlocktime,
|
||||
// &self.txindex_to_total_size,
|
||||
@@ -425,9 +425,9 @@ impl Vecs {
|
||||
&mut self.height_to_blockhash,
|
||||
&mut self.height_to_difficulty,
|
||||
&mut self.height_to_first_emptyoutputindex,
|
||||
&mut self.height_to_first_inputindex,
|
||||
&mut self.height_to_first_txinindex,
|
||||
&mut self.height_to_first_opreturnindex,
|
||||
&mut self.height_to_first_outputindex,
|
||||
&mut self.height_to_first_txoutindex,
|
||||
&mut self.height_to_first_p2aaddressindex,
|
||||
&mut self.height_to_first_p2msoutputindex,
|
||||
&mut self.height_to_first_p2pk33addressindex,
|
||||
@@ -442,11 +442,11 @@ impl Vecs {
|
||||
&mut self.height_to_timestamp,
|
||||
&mut self.height_to_total_size,
|
||||
&mut self.height_to_weight,
|
||||
&mut self.inputindex_to_outputindex,
|
||||
&mut self.txinindex_to_txoutindex,
|
||||
&mut self.opreturnindex_to_txindex,
|
||||
&mut self.outputindex_to_outputtype,
|
||||
&mut self.outputindex_to_typeindex,
|
||||
&mut self.outputindex_to_value,
|
||||
&mut self.txoutindex_to_outputtype,
|
||||
&mut self.txoutindex_to_typeindex,
|
||||
&mut self.txoutindex_to_value,
|
||||
&mut self.p2aaddressindex_to_p2abytes,
|
||||
&mut self.p2msoutputindex_to_txindex,
|
||||
&mut self.p2pk33addressindex_to_p2pk33bytes,
|
||||
@@ -457,8 +457,8 @@ impl Vecs {
|
||||
&mut self.p2wpkhaddressindex_to_p2wpkhbytes,
|
||||
&mut self.p2wshaddressindex_to_p2wshbytes,
|
||||
&mut self.txindex_to_base_size,
|
||||
&mut self.txindex_to_first_inputindex,
|
||||
&mut self.txindex_to_first_outputindex,
|
||||
&mut self.txindex_to_first_txinindex,
|
||||
&mut self.txindex_to_first_txoutindex,
|
||||
&mut self.txindex_to_is_explicitly_rbf,
|
||||
&mut self.txindex_to_rawlocktime,
|
||||
&mut self.txindex_to_total_size,
|
||||
|
||||
@@ -7,7 +7,7 @@ use vecdb::PrintableIndex;
|
||||
|
||||
use super::{
|
||||
DateIndex, DecadeIndex, DifficultyEpoch, EmptyAddressIndex, EmptyOutputIndex, HalvingEpoch,
|
||||
Height, InputIndex, LoadedAddressIndex, MonthIndex, OpReturnIndex, OutputIndex,
|
||||
Height, TxInIndex, LoadedAddressIndex, MonthIndex, OpReturnIndex, TxOutIndex,
|
||||
P2AAddressIndex, P2MSOutputIndex, P2PK33AddressIndex, P2PK65AddressIndex, P2PKHAddressIndex,
|
||||
P2SHAddressIndex, P2TRAddressIndex, P2WPKHAddressIndex, P2WSHAddressIndex, QuarterIndex,
|
||||
SemesterIndex, TxIndex, UnknownOutputIndex, WeekIndex, YearIndex,
|
||||
@@ -31,13 +31,13 @@ pub enum Index {
|
||||
/// Height/block index
|
||||
Height,
|
||||
/// Transaction input index (based on total)
|
||||
InputIndex,
|
||||
TxInIndex,
|
||||
/// Month index
|
||||
MonthIndex,
|
||||
/// Op return index
|
||||
OpReturnIndex,
|
||||
/// Transaction output index (based on total)
|
||||
OutputIndex,
|
||||
TxOutIndex,
|
||||
/// Index of P2A address
|
||||
P2AAddressIndex,
|
||||
/// Index of P2MS output
|
||||
@@ -83,10 +83,10 @@ impl Index {
|
||||
Self::EmptyOutputIndex,
|
||||
Self::HalvingEpoch,
|
||||
Self::Height,
|
||||
Self::InputIndex,
|
||||
Self::TxInIndex,
|
||||
Self::MonthIndex,
|
||||
Self::OpReturnIndex,
|
||||
Self::OutputIndex,
|
||||
Self::TxOutIndex,
|
||||
Self::P2AAddressIndex,
|
||||
Self::P2MSOutputIndex,
|
||||
Self::P2PK33AddressIndex,
|
||||
@@ -115,10 +115,10 @@ impl Index {
|
||||
Self::EmptyOutputIndex => EmptyOutputIndex::to_possible_strings(),
|
||||
Self::HalvingEpoch => HalvingEpoch::to_possible_strings(),
|
||||
Self::Height => Height::to_possible_strings(),
|
||||
Self::InputIndex => InputIndex::to_possible_strings(),
|
||||
Self::TxInIndex => TxInIndex::to_possible_strings(),
|
||||
Self::MonthIndex => MonthIndex::to_possible_strings(),
|
||||
Self::OpReturnIndex => OpReturnIndex::to_possible_strings(),
|
||||
Self::OutputIndex => OutputIndex::to_possible_strings(),
|
||||
Self::TxOutIndex => TxOutIndex::to_possible_strings(),
|
||||
Self::P2AAddressIndex => P2AAddressIndex::to_possible_strings(),
|
||||
Self::P2MSOutputIndex => P2MSOutputIndex::to_possible_strings(),
|
||||
Self::P2PK33AddressIndex => P2PK33AddressIndex::to_possible_strings(),
|
||||
@@ -168,10 +168,10 @@ impl TryFrom<&str> for Index {
|
||||
v if (Self::EmptyOutputIndex).possible_values().contains(&v) => Self::EmptyOutputIndex,
|
||||
v if (Self::HalvingEpoch).possible_values().contains(&v) => Self::HalvingEpoch,
|
||||
v if (Self::Height).possible_values().contains(&v) => Self::Height,
|
||||
v if (Self::InputIndex).possible_values().contains(&v) => Self::InputIndex,
|
||||
v if (Self::TxInIndex).possible_values().contains(&v) => Self::TxInIndex,
|
||||
v if (Self::MonthIndex).possible_values().contains(&v) => Self::MonthIndex,
|
||||
v if (Self::OpReturnIndex).possible_values().contains(&v) => Self::OpReturnIndex,
|
||||
v if (Self::OutputIndex).possible_values().contains(&v) => Self::OutputIndex,
|
||||
v if (Self::TxOutIndex).possible_values().contains(&v) => Self::TxOutIndex,
|
||||
v if (Self::P2AAddressIndex).possible_values().contains(&v) => Self::P2AAddressIndex,
|
||||
v if (Self::P2MSOutputIndex).possible_values().contains(&v) => Self::P2MSOutputIndex,
|
||||
v if (Self::P2PK33AddressIndex).possible_values().contains(&v) => {
|
||||
|
||||
@@ -34,7 +34,6 @@ mod health;
|
||||
mod height;
|
||||
mod index;
|
||||
mod indexinfo;
|
||||
mod inputindex;
|
||||
mod limit;
|
||||
mod loadedaddressdata;
|
||||
mod loadedaddressindex;
|
||||
@@ -44,7 +43,6 @@ mod metrics;
|
||||
mod monthindex;
|
||||
mod ohlc;
|
||||
mod opreturnindex;
|
||||
mod outputindex;
|
||||
mod outputtype;
|
||||
mod p2aaddressindex;
|
||||
mod p2abytes;
|
||||
@@ -87,11 +85,13 @@ mod txidpath;
|
||||
mod txidprefix;
|
||||
mod txin;
|
||||
mod txindex;
|
||||
mod txinindex;
|
||||
mod txout;
|
||||
mod txoutindex;
|
||||
mod txstatus;
|
||||
mod txversion;
|
||||
mod typeindex;
|
||||
mod typeindex_with_outputindex;
|
||||
mod typeindex_with_txoutindex;
|
||||
mod unit;
|
||||
mod unknownoutputindex;
|
||||
mod vin;
|
||||
@@ -130,7 +130,6 @@ pub use health::*;
|
||||
pub use height::*;
|
||||
pub use index::*;
|
||||
pub use indexinfo::*;
|
||||
pub use inputindex::*;
|
||||
pub use limit::*;
|
||||
pub use loadedaddressdata::*;
|
||||
pub use loadedaddressindex::*;
|
||||
@@ -140,7 +139,6 @@ pub use metrics::*;
|
||||
pub use monthindex::*;
|
||||
pub use ohlc::*;
|
||||
pub use opreturnindex::*;
|
||||
pub use outputindex::*;
|
||||
pub use outputtype::*;
|
||||
pub use p2aaddressindex::*;
|
||||
pub use p2abytes::*;
|
||||
@@ -183,11 +181,13 @@ pub use txidpath::*;
|
||||
pub use txidprefix::*;
|
||||
pub use txin::*;
|
||||
pub use txindex::*;
|
||||
pub use txinindex::*;
|
||||
pub use txout::*;
|
||||
pub use txoutindex::*;
|
||||
pub use txstatus::*;
|
||||
pub use txversion::*;
|
||||
pub use typeindex::*;
|
||||
pub use typeindex_with_outputindex::*;
|
||||
pub use typeindex_with_txoutindex::*;
|
||||
pub use unit::*;
|
||||
pub use unknownoutputindex::*;
|
||||
pub use vin::*;
|
||||
|
||||
@@ -7,7 +7,7 @@ use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use super::{
|
||||
DateIndex, EmptyOutputIndex, Height, InputIndex, MonthIndex, OpReturnIndex, OutputIndex,
|
||||
DateIndex, EmptyOutputIndex, Height, TxInIndex, MonthIndex, OpReturnIndex, TxOutIndex,
|
||||
P2AAddressIndex, P2MSOutputIndex, P2PK33AddressIndex, P2PK65AddressIndex, P2PKHAddressIndex,
|
||||
P2SHAddressIndex, P2TRAddressIndex, P2WPKHAddressIndex, P2WSHAddressIndex, TxIndex,
|
||||
UnknownOutputIndex, YearIndex,
|
||||
@@ -112,8 +112,8 @@ impl From<TxIndex> for StoredU64 {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<InputIndex> for StoredU64 {
|
||||
fn from(value: InputIndex) -> Self {
|
||||
impl From<TxInIndex> for StoredU64 {
|
||||
fn from(value: TxInIndex) -> Self {
|
||||
Self(*value)
|
||||
}
|
||||
}
|
||||
@@ -124,8 +124,8 @@ impl From<Height> for StoredU64 {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<OutputIndex> for StoredU64 {
|
||||
fn from(value: OutputIndex) -> Self {
|
||||
impl From<TxOutIndex> for StoredU64 {
|
||||
fn from(value: TxOutIndex) -> Self {
|
||||
Self(*value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,49 +27,49 @@ use super::Vin;
|
||||
StoredCompressed,
|
||||
Allocative,
|
||||
)]
|
||||
pub struct InputIndex(u64);
|
||||
pub struct TxInIndex(u64);
|
||||
|
||||
impl InputIndex {
|
||||
impl TxInIndex {
|
||||
pub fn incremented(self) -> Self {
|
||||
Self(*self + 1)
|
||||
}
|
||||
}
|
||||
|
||||
impl Add<InputIndex> for InputIndex {
|
||||
impl Add<TxInIndex> for TxInIndex {
|
||||
type Output = Self;
|
||||
fn add(self, rhs: InputIndex) -> Self::Output {
|
||||
fn add(self, rhs: TxInIndex) -> Self::Output {
|
||||
Self(self.0 + rhs.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl Add<Vin> for InputIndex {
|
||||
impl Add<Vin> for TxInIndex {
|
||||
type Output = Self;
|
||||
fn add(self, rhs: Vin) -> Self::Output {
|
||||
Self(self.0 + u64::from(rhs))
|
||||
}
|
||||
}
|
||||
|
||||
impl Add<usize> for InputIndex {
|
||||
impl Add<usize> for TxInIndex {
|
||||
type Output = Self;
|
||||
fn add(self, rhs: usize) -> Self::Output {
|
||||
Self(self.0 + rhs as u64)
|
||||
}
|
||||
}
|
||||
|
||||
impl AddAssign<InputIndex> for InputIndex {
|
||||
fn add_assign(&mut self, rhs: InputIndex) {
|
||||
impl AddAssign<TxInIndex> for TxInIndex {
|
||||
fn add_assign(&mut self, rhs: TxInIndex) {
|
||||
self.0 += rhs.0
|
||||
}
|
||||
}
|
||||
|
||||
impl CheckedSub<InputIndex> for InputIndex {
|
||||
impl CheckedSub<TxInIndex> for TxInIndex {
|
||||
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
||||
self.0.checked_sub(rhs.0).map(Self::from)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<InputIndex> for u32 {
|
||||
fn from(value: InputIndex) -> Self {
|
||||
impl From<TxInIndex> for u32 {
|
||||
fn from(value: TxInIndex) -> Self {
|
||||
if value.0 > u32::MAX as u64 {
|
||||
panic!()
|
||||
}
|
||||
@@ -77,39 +77,39 @@ impl From<InputIndex> for u32 {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u64> for InputIndex {
|
||||
impl From<u64> for TxInIndex {
|
||||
fn from(value: u64) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
impl From<InputIndex> for u64 {
|
||||
fn from(value: InputIndex) -> Self {
|
||||
impl From<TxInIndex> for u64 {
|
||||
fn from(value: TxInIndex) -> Self {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<usize> for InputIndex {
|
||||
impl From<usize> for TxInIndex {
|
||||
fn from(value: usize) -> Self {
|
||||
Self(value as u64)
|
||||
}
|
||||
}
|
||||
impl From<InputIndex> for usize {
|
||||
fn from(value: InputIndex) -> Self {
|
||||
impl From<TxInIndex> for usize {
|
||||
fn from(value: TxInIndex) -> Self {
|
||||
value.0 as usize
|
||||
}
|
||||
}
|
||||
|
||||
impl PrintableIndex for InputIndex {
|
||||
impl PrintableIndex for TxInIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"inputindex"
|
||||
"txinindex"
|
||||
}
|
||||
|
||||
fn to_possible_strings() -> &'static [&'static str] {
|
||||
&["in", "inputindex"]
|
||||
&["in", "txinindex"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for InputIndex {
|
||||
impl std::fmt::Display for TxInIndex {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let mut buf = itoa::Buffer::new();
|
||||
let str = buf.format(self.0);
|
||||
@@ -29,9 +29,9 @@ use super::Vout;
|
||||
StoredCompressed,
|
||||
Allocative,
|
||||
)]
|
||||
pub struct OutputIndex(u64);
|
||||
pub struct TxOutIndex(u64);
|
||||
|
||||
impl OutputIndex {
|
||||
impl TxOutIndex {
|
||||
pub const ZERO: Self = Self(0);
|
||||
|
||||
pub const COINBASE: Self = Self(u64::MAX);
|
||||
@@ -45,41 +45,41 @@ impl OutputIndex {
|
||||
}
|
||||
}
|
||||
|
||||
impl Add<OutputIndex> for OutputIndex {
|
||||
impl Add<TxOutIndex> for TxOutIndex {
|
||||
type Output = Self;
|
||||
fn add(self, rhs: OutputIndex) -> Self::Output {
|
||||
fn add(self, rhs: TxOutIndex) -> Self::Output {
|
||||
Self(self.0 + rhs.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl Add<Vout> for OutputIndex {
|
||||
impl Add<Vout> for TxOutIndex {
|
||||
type Output = Self;
|
||||
fn add(self, rhs: Vout) -> Self::Output {
|
||||
Self(self.0 + u64::from(rhs))
|
||||
}
|
||||
}
|
||||
|
||||
impl Add<usize> for OutputIndex {
|
||||
impl Add<usize> for TxOutIndex {
|
||||
type Output = Self;
|
||||
fn add(self, rhs: usize) -> Self::Output {
|
||||
Self(self.0 + rhs as u64)
|
||||
}
|
||||
}
|
||||
|
||||
impl AddAssign<OutputIndex> for OutputIndex {
|
||||
fn add_assign(&mut self, rhs: OutputIndex) {
|
||||
impl AddAssign<TxOutIndex> for TxOutIndex {
|
||||
fn add_assign(&mut self, rhs: TxOutIndex) {
|
||||
self.0 += rhs.0
|
||||
}
|
||||
}
|
||||
|
||||
impl CheckedSub<OutputIndex> for OutputIndex {
|
||||
impl CheckedSub<TxOutIndex> for TxOutIndex {
|
||||
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
||||
self.0.checked_sub(rhs.0).map(Self::from)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<OutputIndex> for u32 {
|
||||
fn from(value: OutputIndex) -> Self {
|
||||
impl From<TxOutIndex> for u32 {
|
||||
fn from(value: TxOutIndex) -> Self {
|
||||
if value.0 > u32::MAX as u64 {
|
||||
panic!()
|
||||
}
|
||||
@@ -87,45 +87,45 @@ impl From<OutputIndex> for u32 {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u64> for OutputIndex {
|
||||
impl From<u64> for TxOutIndex {
|
||||
fn from(value: u64) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
impl From<OutputIndex> for u64 {
|
||||
fn from(value: OutputIndex) -> Self {
|
||||
impl From<TxOutIndex> for u64 {
|
||||
fn from(value: TxOutIndex) -> Self {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<usize> for OutputIndex {
|
||||
impl From<usize> for TxOutIndex {
|
||||
fn from(value: usize) -> Self {
|
||||
Self(value as u64)
|
||||
}
|
||||
}
|
||||
impl From<OutputIndex> for usize {
|
||||
fn from(value: OutputIndex) -> Self {
|
||||
impl From<TxOutIndex> for usize {
|
||||
fn from(value: TxOutIndex) -> Self {
|
||||
value.0 as usize
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&[u8]> for OutputIndex {
|
||||
impl From<&[u8]> for TxOutIndex {
|
||||
fn from(value: &[u8]) -> Self {
|
||||
Self(u64::from_be_bytes(copy_first_8bytes(value).unwrap()))
|
||||
}
|
||||
}
|
||||
|
||||
impl PrintableIndex for OutputIndex {
|
||||
impl PrintableIndex for TxOutIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"outputindex"
|
||||
"txoutindex"
|
||||
}
|
||||
|
||||
fn to_possible_strings() -> &'static [&'static str] {
|
||||
&["out", "outputindex"]
|
||||
&["out", "txoutindex"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for OutputIndex {
|
||||
impl std::fmt::Display for TxOutIndex {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let mut buf = itoa::Buffer::new();
|
||||
let str = buf.format(self.0);
|
||||
@@ -1,19 +1,19 @@
|
||||
use byteview::ByteView;
|
||||
use serde::Serialize;
|
||||
|
||||
use super::{OutputIndex, TypeIndex};
|
||||
use super::{TxOutIndex, TypeIndex};
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Default, Serialize)]
|
||||
pub struct TypeIndexWithOutputindex {
|
||||
typeindex: TypeIndex,
|
||||
outputindex: OutputIndex,
|
||||
txoutindex: TxOutIndex,
|
||||
}
|
||||
|
||||
impl From<(TypeIndex, OutputIndex)> for TypeIndexWithOutputindex {
|
||||
fn from(value: (TypeIndex, OutputIndex)) -> Self {
|
||||
impl From<(TypeIndex, TxOutIndex)> for TypeIndexWithOutputindex {
|
||||
fn from(value: (TypeIndex, TxOutIndex)) -> Self {
|
||||
Self {
|
||||
typeindex: value.0,
|
||||
outputindex: value.1,
|
||||
txoutindex: value.1,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,10 +21,10 @@ impl From<(TypeIndex, OutputIndex)> for TypeIndexWithOutputindex {
|
||||
impl From<ByteView> for TypeIndexWithOutputindex {
|
||||
fn from(value: ByteView) -> Self {
|
||||
let typeindex = TypeIndex::from(&value[0..4]);
|
||||
let outputindex = OutputIndex::from(&value[4..12]);
|
||||
let txoutindex = TxOutIndex::from(&value[4..12]);
|
||||
Self {
|
||||
typeindex,
|
||||
outputindex,
|
||||
txoutindex,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ impl From<&TypeIndexWithOutputindex> for ByteView {
|
||||
ByteView::from(
|
||||
[
|
||||
u32::from(value.typeindex).to_be_bytes().as_slice(),
|
||||
u64::from(value.outputindex).to_be_bytes().as_slice(),
|
||||
u64::from(value.txoutindex).to_be_bytes().as_slice(),
|
||||
]
|
||||
.concat(),
|
||||
)
|
||||
Reference in New Issue
Block a user