global: snapshot

This commit is contained in:
nym21
2025-11-25 17:21:07 +01:00
parent c644781d18
commit dc86514329
87 changed files with 335 additions and 1436 deletions
+22 -30
View File
@@ -756,47 +756,39 @@ enum InputSource<'a> {
}
struct Readers {
txindex_to_first_txoutindex: Reader<'static>,
txoutindex_to_outputtype: Reader<'static>,
txoutindex_to_typeindex: Reader<'static>,
p2pk65addressindex_to_p2pk65bytes: Reader<'static>,
p2pk33addressindex_to_p2pk33bytes: Reader<'static>,
p2pkhaddressindex_to_p2pkhbytes: Reader<'static>,
p2shaddressindex_to_p2shbytes: Reader<'static>,
p2wpkhaddressindex_to_p2wpkhbytes: Reader<'static>,
p2wshaddressindex_to_p2wshbytes: Reader<'static>,
p2traddressindex_to_p2trbytes: Reader<'static>,
p2aaddressindex_to_p2abytes: Reader<'static>,
txindex_to_first_txoutindex: Reader,
txoutindex_to_outputtype: Reader,
txoutindex_to_typeindex: Reader,
p2pk65addressindex_to_p2pk65bytes: Reader,
p2pk33addressindex_to_p2pk33bytes: Reader,
p2pkhaddressindex_to_p2pkhbytes: Reader,
p2shaddressindex_to_p2shbytes: Reader,
p2wpkhaddressindex_to_p2wpkhbytes: Reader,
p2wshaddressindex_to_p2wshbytes: Reader,
p2traddressindex_to_p2trbytes: Reader,
p2aaddressindex_to_p2abytes: Reader,
}
impl Readers {
fn new(vecs: &Vecs) -> Self {
Self {
txindex_to_first_txoutindex: vecs.txindex_to_first_txoutindex.create_static_reader(),
txoutindex_to_outputtype: vecs.txoutindex_to_outputtype.create_static_reader(),
txoutindex_to_typeindex: vecs.txoutindex_to_typeindex.create_static_reader(),
txindex_to_first_txoutindex: vecs.txindex_to_first_txoutindex.create_reader(),
txoutindex_to_outputtype: vecs.txoutindex_to_outputtype.create_reader(),
txoutindex_to_typeindex: vecs.txoutindex_to_typeindex.create_reader(),
p2pk65addressindex_to_p2pk65bytes: vecs
.p2pk65addressindex_to_p2pk65bytes
.create_static_reader(),
.create_reader(),
p2pk33addressindex_to_p2pk33bytes: vecs
.p2pk33addressindex_to_p2pk33bytes
.create_static_reader(),
p2pkhaddressindex_to_p2pkhbytes: vecs
.p2pkhaddressindex_to_p2pkhbytes
.create_static_reader(),
p2shaddressindex_to_p2shbytes: vecs
.p2shaddressindex_to_p2shbytes
.create_static_reader(),
.create_reader(),
p2pkhaddressindex_to_p2pkhbytes: vecs.p2pkhaddressindex_to_p2pkhbytes.create_reader(),
p2shaddressindex_to_p2shbytes: vecs.p2shaddressindex_to_p2shbytes.create_reader(),
p2wpkhaddressindex_to_p2wpkhbytes: vecs
.p2wpkhaddressindex_to_p2wpkhbytes
.create_static_reader(),
p2wshaddressindex_to_p2wshbytes: vecs
.p2wshaddressindex_to_p2wshbytes
.create_static_reader(),
p2traddressindex_to_p2trbytes: vecs
.p2traddressindex_to_p2trbytes
.create_static_reader(),
p2aaddressindex_to_p2abytes: vecs.p2aaddressindex_to_p2abytes.create_static_reader(),
.create_reader(),
p2wshaddressindex_to_p2wshbytes: vecs.p2wshaddressindex_to_p2wshbytes.create_reader(),
p2traddressindex_to_p2trbytes: vecs.p2traddressindex_to_p2trbytes.create_reader(),
p2aaddressindex_to_p2abytes: vecs.p2aaddressindex_to_p2abytes.create_reader(),
}
}
}
+101 -103
View File
@@ -11,7 +11,9 @@ use brk_types::{
TxOutIndex, TxVersion, Txid, TypeIndex, UnknownOutputIndex, Version, Weight,
};
use rayon::prelude::*;
use vecdb::{AnyStoredVec, CompressedVec, Database, GenericStoredVec, PAGE_SIZE, RawVec, Stamp};
use vecdb::{
AnyStoredVec, BytesVec, Database, GenericStoredVec, Importable, PAGE_SIZE, PcoVec, Stamp,
};
use crate::Indexes;
@@ -19,53 +21,53 @@ use crate::Indexes;
pub struct Vecs {
db: Database,
pub emptyoutputindex_to_txindex: CompressedVec<EmptyOutputIndex, TxIndex>,
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_opreturnindex: CompressedVec<Height, OpReturnIndex>,
pub height_to_first_p2aaddressindex: CompressedVec<Height, P2AAddressIndex>,
pub height_to_first_p2msoutputindex: CompressedVec<Height, P2MSOutputIndex>,
pub height_to_first_p2pk33addressindex: CompressedVec<Height, P2PK33AddressIndex>,
pub height_to_first_p2pk65addressindex: CompressedVec<Height, P2PK65AddressIndex>,
pub height_to_first_p2pkhaddressindex: CompressedVec<Height, P2PKHAddressIndex>,
pub height_to_first_p2shaddressindex: CompressedVec<Height, P2SHAddressIndex>,
pub height_to_first_p2traddressindex: CompressedVec<Height, P2TRAddressIndex>,
pub height_to_first_p2wpkhaddressindex: CompressedVec<Height, P2WPKHAddressIndex>,
pub height_to_first_p2wshaddressindex: CompressedVec<Height, P2WSHAddressIndex>,
pub height_to_first_txindex: CompressedVec<Height, TxIndex>,
pub height_to_first_txinindex: CompressedVec<Height, TxInIndex>,
pub height_to_first_txoutindex: CompressedVec<Height, TxOutIndex>,
pub height_to_first_unknownoutputindex: CompressedVec<Height, UnknownOutputIndex>,
pub emptyoutputindex_to_txindex: PcoVec<EmptyOutputIndex, TxIndex>,
pub height_to_blockhash: BytesVec<Height, BlockHash>,
pub height_to_difficulty: PcoVec<Height, StoredF64>,
pub height_to_first_emptyoutputindex: PcoVec<Height, EmptyOutputIndex>,
pub height_to_first_opreturnindex: PcoVec<Height, OpReturnIndex>,
pub height_to_first_p2aaddressindex: PcoVec<Height, P2AAddressIndex>,
pub height_to_first_p2msoutputindex: PcoVec<Height, P2MSOutputIndex>,
pub height_to_first_p2pk33addressindex: PcoVec<Height, P2PK33AddressIndex>,
pub height_to_first_p2pk65addressindex: PcoVec<Height, P2PK65AddressIndex>,
pub height_to_first_p2pkhaddressindex: PcoVec<Height, P2PKHAddressIndex>,
pub height_to_first_p2shaddressindex: PcoVec<Height, P2SHAddressIndex>,
pub height_to_first_p2traddressindex: PcoVec<Height, P2TRAddressIndex>,
pub height_to_first_p2wpkhaddressindex: PcoVec<Height, P2WPKHAddressIndex>,
pub height_to_first_p2wshaddressindex: PcoVec<Height, P2WSHAddressIndex>,
pub height_to_first_txindex: PcoVec<Height, TxIndex>,
pub height_to_first_txinindex: PcoVec<Height, TxInIndex>,
pub height_to_first_txoutindex: PcoVec<Height, TxOutIndex>,
pub height_to_first_unknownoutputindex: PcoVec<Height, UnknownOutputIndex>,
/// Doesn't guarantee continuity due to possible reorgs and more generally the nature of mining
pub height_to_timestamp: CompressedVec<Height, Timestamp>,
pub height_to_total_size: CompressedVec<Height, StoredU64>,
pub height_to_weight: CompressedVec<Height, Weight>,
pub opreturnindex_to_txindex: CompressedVec<OpReturnIndex, TxIndex>,
pub p2aaddressindex_to_p2abytes: RawVec<P2AAddressIndex, P2ABytes>,
pub p2msoutputindex_to_txindex: CompressedVec<P2MSOutputIndex, TxIndex>,
pub p2pk33addressindex_to_p2pk33bytes: RawVec<P2PK33AddressIndex, P2PK33Bytes>,
pub p2pk65addressindex_to_p2pk65bytes: RawVec<P2PK65AddressIndex, P2PK65Bytes>,
pub p2pkhaddressindex_to_p2pkhbytes: RawVec<P2PKHAddressIndex, P2PKHBytes>,
pub p2shaddressindex_to_p2shbytes: RawVec<P2SHAddressIndex, P2SHBytes>,
pub p2traddressindex_to_p2trbytes: RawVec<P2TRAddressIndex, P2TRBytes>,
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_txinindex: CompressedVec<TxIndex, TxInIndex>,
pub txindex_to_first_txoutindex: RawVec<TxIndex, TxOutIndex>,
pub txindex_to_height: CompressedVec<TxIndex, Height>,
pub txindex_to_is_explicitly_rbf: CompressedVec<TxIndex, StoredBool>,
pub txindex_to_rawlocktime: CompressedVec<TxIndex, RawLockTime>,
pub txindex_to_total_size: CompressedVec<TxIndex, StoredU32>,
pub txindex_to_txid: RawVec<TxIndex, Txid>,
pub txindex_to_txversion: CompressedVec<TxIndex, TxVersion>,
pub txinindex_to_outpoint: CompressedVec<TxInIndex, OutPoint>,
pub txoutindex_to_outputtype: RawVec<TxOutIndex, OutputType>,
pub txoutindex_to_txindex: CompressedVec<TxOutIndex, TxIndex>,
pub txoutindex_to_typeindex: RawVec<TxOutIndex, TypeIndex>,
pub txoutindex_to_value: RawVec<TxOutIndex, Sats>,
pub unknownoutputindex_to_txindex: CompressedVec<UnknownOutputIndex, TxIndex>,
pub height_to_timestamp: PcoVec<Height, Timestamp>,
pub height_to_total_size: PcoVec<Height, StoredU64>,
pub height_to_weight: PcoVec<Height, Weight>,
pub opreturnindex_to_txindex: PcoVec<OpReturnIndex, TxIndex>,
pub p2aaddressindex_to_p2abytes: BytesVec<P2AAddressIndex, P2ABytes>,
pub p2msoutputindex_to_txindex: PcoVec<P2MSOutputIndex, TxIndex>,
pub p2pk33addressindex_to_p2pk33bytes: BytesVec<P2PK33AddressIndex, P2PK33Bytes>,
pub p2pk65addressindex_to_p2pk65bytes: BytesVec<P2PK65AddressIndex, P2PK65Bytes>,
pub p2pkhaddressindex_to_p2pkhbytes: BytesVec<P2PKHAddressIndex, P2PKHBytes>,
pub p2shaddressindex_to_p2shbytes: BytesVec<P2SHAddressIndex, P2SHBytes>,
pub p2traddressindex_to_p2trbytes: BytesVec<P2TRAddressIndex, P2TRBytes>,
pub p2wpkhaddressindex_to_p2wpkhbytes: BytesVec<P2WPKHAddressIndex, P2WPKHBytes>,
pub p2wshaddressindex_to_p2wshbytes: BytesVec<P2WSHAddressIndex, P2WSHBytes>,
pub txindex_to_base_size: PcoVec<TxIndex, StoredU32>,
pub txindex_to_first_txinindex: PcoVec<TxIndex, TxInIndex>,
pub txindex_to_first_txoutindex: BytesVec<TxIndex, TxOutIndex>,
pub txindex_to_height: PcoVec<TxIndex, Height>,
pub txindex_to_is_explicitly_rbf: PcoVec<TxIndex, StoredBool>,
pub txindex_to_rawlocktime: PcoVec<TxIndex, RawLockTime>,
pub txindex_to_total_size: PcoVec<TxIndex, StoredU32>,
pub txindex_to_txid: BytesVec<TxIndex, Txid>,
pub txindex_to_txversion: PcoVec<TxIndex, TxVersion>,
pub txinindex_to_outpoint: PcoVec<TxInIndex, OutPoint>,
pub txoutindex_to_outputtype: BytesVec<TxOutIndex, OutputType>,
pub txoutindex_to_txindex: PcoVec<TxOutIndex, TxIndex>,
pub txoutindex_to_typeindex: BytesVec<TxOutIndex, TypeIndex>,
pub txoutindex_to_value: BytesVec<TxOutIndex, Sats>,
pub unknownoutputindex_to_txindex: PcoVec<UnknownOutputIndex, TxIndex>,
}
impl Vecs {
@@ -74,116 +76,112 @@ impl Vecs {
db.set_min_len(PAGE_SIZE * 50_000_000)?;
let this = Self {
emptyoutputindex_to_txindex: CompressedVec::forced_import(&db, "txindex", version)?,
height_to_blockhash: RawVec::forced_import(&db, "blockhash", version)?,
height_to_difficulty: CompressedVec::forced_import(&db, "difficulty", version)?,
height_to_first_emptyoutputindex: CompressedVec::forced_import(
emptyoutputindex_to_txindex: PcoVec::forced_import(&db, "txindex", version)?,
height_to_blockhash: BytesVec::forced_import(&db, "blockhash", version)?,
height_to_difficulty: PcoVec::forced_import(&db, "difficulty", version)?,
height_to_first_emptyoutputindex: PcoVec::forced_import(
&db,
"first_emptyoutputindex",
version,
)?,
height_to_first_txinindex: CompressedVec::forced_import(
&db,
"first_txinindex",
version,
)?,
height_to_first_opreturnindex: CompressedVec::forced_import(
height_to_first_txinindex: PcoVec::forced_import(&db, "first_txinindex", version)?,
height_to_first_opreturnindex: PcoVec::forced_import(
&db,
"first_opreturnindex",
version,
)?,
height_to_first_txoutindex: CompressedVec::forced_import(
&db,
"first_txoutindex",
version,
)?,
height_to_first_p2aaddressindex: CompressedVec::forced_import(
height_to_first_txoutindex: PcoVec::forced_import(&db, "first_txoutindex", version)?,
height_to_first_p2aaddressindex: PcoVec::forced_import(
&db,
"first_p2aaddressindex",
version,
)?,
height_to_first_p2msoutputindex: CompressedVec::forced_import(
height_to_first_p2msoutputindex: PcoVec::forced_import(
&db,
"first_p2msoutputindex",
version,
)?,
height_to_first_p2pk33addressindex: CompressedVec::forced_import(
height_to_first_p2pk33addressindex: PcoVec::forced_import(
&db,
"first_p2pk33addressindex",
version,
)?,
height_to_first_p2pk65addressindex: CompressedVec::forced_import(
height_to_first_p2pk65addressindex: PcoVec::forced_import(
&db,
"first_p2pk65addressindex",
version,
)?,
height_to_first_p2pkhaddressindex: CompressedVec::forced_import(
height_to_first_p2pkhaddressindex: PcoVec::forced_import(
&db,
"first_p2pkhaddressindex",
version,
)?,
height_to_first_p2shaddressindex: CompressedVec::forced_import(
height_to_first_p2shaddressindex: PcoVec::forced_import(
&db,
"first_p2shaddressindex",
version,
)?,
height_to_first_p2traddressindex: CompressedVec::forced_import(
height_to_first_p2traddressindex: PcoVec::forced_import(
&db,
"first_p2traddressindex",
version,
)?,
height_to_first_p2wpkhaddressindex: CompressedVec::forced_import(
height_to_first_p2wpkhaddressindex: PcoVec::forced_import(
&db,
"first_p2wpkhaddressindex",
version,
)?,
height_to_first_p2wshaddressindex: CompressedVec::forced_import(
height_to_first_p2wshaddressindex: PcoVec::forced_import(
&db,
"first_p2wshaddressindex",
version,
)?,
height_to_first_txindex: CompressedVec::forced_import(&db, "first_txindex", version)?,
height_to_first_unknownoutputindex: CompressedVec::forced_import(
height_to_first_txindex: PcoVec::forced_import(&db, "first_txindex", version)?,
height_to_first_unknownoutputindex: PcoVec::forced_import(
&db,
"first_unknownoutputindex",
version,
)?,
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)?,
opreturnindex_to_txindex: CompressedVec::forced_import(&db, "txindex", 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)?,
p2pk65addressindex_to_p2pk65bytes: RawVec::forced_import(&db, "p2pk65bytes", version)?,
p2pkhaddressindex_to_p2pkhbytes: RawVec::forced_import(&db, "p2pkhbytes", version)?,
p2shaddressindex_to_p2shbytes: RawVec::forced_import(&db, "p2shbytes", version)?,
p2traddressindex_to_p2trbytes: RawVec::forced_import(&db, "p2trbytes", version)?,
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_height: CompressedVec::forced_import(&db, "height", version)?,
txindex_to_first_txinindex: CompressedVec::forced_import(
height_to_timestamp: PcoVec::forced_import(&db, "timestamp", version)?,
height_to_total_size: PcoVec::forced_import(&db, "total_size", version)?,
height_to_weight: PcoVec::forced_import(&db, "weight", version)?,
opreturnindex_to_txindex: PcoVec::forced_import(&db, "txindex", version)?,
p2aaddressindex_to_p2abytes: BytesVec::forced_import(&db, "p2abytes", version)?,
p2msoutputindex_to_txindex: PcoVec::forced_import(&db, "txindex", version)?,
p2pk33addressindex_to_p2pk33bytes: BytesVec::forced_import(
&db,
"first_txinindex",
"p2pk33bytes",
version,
)?,
txindex_to_first_txoutindex: RawVec::forced_import(&db, "first_txoutindex", version)?,
txindex_to_is_explicitly_rbf: CompressedVec::forced_import(
p2pk65addressindex_to_p2pk65bytes: BytesVec::forced_import(
&db,
"is_explicitly_rbf",
"p2pk65bytes",
version,
)?,
txindex_to_rawlocktime: CompressedVec::forced_import(&db, "rawlocktime", version)?,
txindex_to_total_size: CompressedVec::forced_import(&db, "total_size", version)?,
txindex_to_txid: RawVec::forced_import(&db, "txid", version)?,
txindex_to_txversion: CompressedVec::forced_import(&db, "txversion", version)?,
txinindex_to_outpoint: CompressedVec::forced_import(&db, "outpoint", version)?,
txoutindex_to_outputtype: RawVec::forced_import(&db, "outputtype", version)?,
txoutindex_to_txindex: CompressedVec::forced_import(&db, "txindex", version)?,
txoutindex_to_typeindex: RawVec::forced_import(&db, "typeindex", version)?,
txoutindex_to_value: RawVec::forced_import(&db, "value", version)?,
unknownoutputindex_to_txindex: CompressedVec::forced_import(&db, "txindex", version)?,
p2pkhaddressindex_to_p2pkhbytes: BytesVec::forced_import(&db, "p2pkhbytes", version)?,
p2shaddressindex_to_p2shbytes: BytesVec::forced_import(&db, "p2shbytes", version)?,
p2traddressindex_to_p2trbytes: BytesVec::forced_import(&db, "p2trbytes", version)?,
p2wpkhaddressindex_to_p2wpkhbytes: BytesVec::forced_import(
&db,
"p2wpkhbytes",
version,
)?,
p2wshaddressindex_to_p2wshbytes: BytesVec::forced_import(&db, "p2wshbytes", version)?,
txindex_to_base_size: PcoVec::forced_import(&db, "base_size", version)?,
txindex_to_height: PcoVec::forced_import(&db, "height", version)?,
txindex_to_first_txinindex: PcoVec::forced_import(&db, "first_txinindex", version)?,
txindex_to_first_txoutindex: BytesVec::forced_import(&db, "first_txoutindex", version)?,
txindex_to_is_explicitly_rbf: PcoVec::forced_import(&db, "is_explicitly_rbf", version)?,
txindex_to_rawlocktime: PcoVec::forced_import(&db, "rawlocktime", version)?,
txindex_to_total_size: PcoVec::forced_import(&db, "total_size", version)?,
txindex_to_txid: BytesVec::forced_import(&db, "txid", version)?,
txindex_to_txversion: PcoVec::forced_import(&db, "txversion", version)?,
txinindex_to_outpoint: PcoVec::forced_import(&db, "outpoint", version)?,
txoutindex_to_outputtype: BytesVec::forced_import(&db, "outputtype", version)?,
txoutindex_to_txindex: PcoVec::forced_import(&db, "txindex", version)?,
txoutindex_to_typeindex: BytesVec::forced_import(&db, "typeindex", version)?,
txoutindex_to_value: BytesVec::forced_import(&db, "value", version)?,
unknownoutputindex_to_txindex: PcoVec::forced_import(&db, "txindex", version)?,
db,
};