mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-28 16:49:58 -07:00
computer: big refactor
This commit is contained in:
@@ -107,301 +107,75 @@ impl Vecs {
|
||||
|
||||
let version = parent_version + VERSION;
|
||||
|
||||
macro_rules! eager {
|
||||
($name:expr) => { EagerVec::forced_import(&db, $name, version)? };
|
||||
}
|
||||
macro_rules! lazy {
|
||||
($name:expr, $source:expr) => {
|
||||
LazyVecFrom1::init($name, version, $source.boxed_clone(), |index, _| Some(index))
|
||||
};
|
||||
}
|
||||
|
||||
let this = Self {
|
||||
txinindex_to_txoutindex: EagerVec::forced_import(&db, "txoutindex", version)?,
|
||||
txoutindex_to_txoutindex: LazyVecFrom1::init(
|
||||
"txoutindex",
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.txoutindex_to_value.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
),
|
||||
txinindex_to_txinindex: LazyVecFrom1::init(
|
||||
"txinindex",
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.txinindex_to_outpoint.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
),
|
||||
p2pk33addressindex_to_p2pk33addressindex: LazyVecFrom1::init(
|
||||
"p2pk33addressindex",
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.p2pk33addressindex_to_p2pk33bytes.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
),
|
||||
p2pk65addressindex_to_p2pk65addressindex: LazyVecFrom1::init(
|
||||
"p2pk65addressindex",
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.p2pk65addressindex_to_p2pk65bytes.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
),
|
||||
p2pkhaddressindex_to_p2pkhaddressindex: LazyVecFrom1::init(
|
||||
"p2pkhaddressindex",
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.p2pkhaddressindex_to_p2pkhbytes.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
),
|
||||
p2shaddressindex_to_p2shaddressindex: LazyVecFrom1::init(
|
||||
"p2shaddressindex",
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.p2shaddressindex_to_p2shbytes.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
),
|
||||
p2traddressindex_to_p2traddressindex: LazyVecFrom1::init(
|
||||
"p2traddressindex",
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.p2traddressindex_to_p2trbytes.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
),
|
||||
p2wpkhaddressindex_to_p2wpkhaddressindex: LazyVecFrom1::init(
|
||||
"p2wpkhaddressindex",
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.p2wpkhaddressindex_to_p2wpkhbytes.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
),
|
||||
p2wshaddressindex_to_p2wshaddressindex: LazyVecFrom1::init(
|
||||
"p2wshaddressindex",
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.p2wshaddressindex_to_p2wshbytes.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
),
|
||||
p2aaddressindex_to_p2aaddressindex: LazyVecFrom1::init(
|
||||
"p2aaddressindex",
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.p2aaddressindex_to_p2abytes.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
),
|
||||
p2msoutputindex_to_p2msoutputindex: LazyVecFrom1::init(
|
||||
"p2msoutputindex",
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.p2msoutputindex_to_txindex.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
),
|
||||
emptyoutputindex_to_emptyoutputindex: LazyVecFrom1::init(
|
||||
"emptyoutputindex",
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.emptyoutputindex_to_txindex.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
),
|
||||
unknownoutputindex_to_unknownoutputindex: LazyVecFrom1::init(
|
||||
"unknownoutputindex",
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.unknownoutputindex_to_txindex.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
),
|
||||
opreturnindex_to_opreturnindex: LazyVecFrom1::init(
|
||||
"opreturnindex",
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.opreturnindex_to_txindex.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
),
|
||||
txindex_to_txindex: LazyVecFrom1::init(
|
||||
"txindex",
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.txindex_to_txid.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
),
|
||||
txindex_to_input_count: EagerVec::forced_import(
|
||||
&db,
|
||||
"input_count",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
txindex_to_output_count: EagerVec::forced_import(
|
||||
&db,
|
||||
"output_count",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
dateindex_to_date: EagerVec::forced_import(&db, "date", version + Version::ZERO)?,
|
||||
dateindex_to_dateindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"dateindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
dateindex_to_first_height: EagerVec::forced_import(
|
||||
&db,
|
||||
"first_height",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
dateindex_to_monthindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"monthindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
dateindex_to_weekindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"weekindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
decadeindex_to_decadeindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"decadeindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
decadeindex_to_first_yearindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"first_yearindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
difficultyepoch_to_difficultyepoch: EagerVec::forced_import(
|
||||
&db,
|
||||
"difficultyepoch",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
difficultyepoch_to_first_height: EagerVec::forced_import(
|
||||
&db,
|
||||
"first_height",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
halvingepoch_to_first_height: EagerVec::forced_import(
|
||||
&db,
|
||||
"first_height",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
halvingepoch_to_halvingepoch: EagerVec::forced_import(
|
||||
&db,
|
||||
"halvingepoch",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_date: EagerVec::forced_import(&db, "date", version + Version::ZERO)?,
|
||||
height_to_difficultyepoch: EagerVec::forced_import(
|
||||
&db,
|
||||
"difficultyepoch",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_halvingepoch: EagerVec::forced_import(
|
||||
&db,
|
||||
"halvingepoch",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_height: EagerVec::forced_import(&db, "height", version + Version::ZERO)?,
|
||||
monthindex_to_first_dateindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"first_dateindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
monthindex_to_monthindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"monthindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
monthindex_to_quarterindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"quarterindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
monthindex_to_semesterindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"semesterindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
monthindex_to_yearindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"yearindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
quarterindex_to_first_monthindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"first_monthindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
semesterindex_to_first_monthindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"first_monthindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
weekindex_to_first_dateindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"first_dateindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
yearindex_to_first_monthindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"first_monthindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
quarterindex_to_quarterindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"quarterindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
semesterindex_to_semesterindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"semesterindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
weekindex_to_weekindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"weekindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
yearindex_to_decadeindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"decadeindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
yearindex_to_yearindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"yearindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_date_fixed: EagerVec::forced_import(
|
||||
&db,
|
||||
"date_fixed",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_dateindex: EagerVec::forced_import(
|
||||
&db,
|
||||
"dateindex",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_timestamp_fixed: EagerVec::forced_import(
|
||||
&db,
|
||||
"timestamp_fixed",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_txindex_count: EagerVec::forced_import(
|
||||
&db,
|
||||
"txindex_count",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
dateindex_to_height_count: EagerVec::forced_import(
|
||||
&db,
|
||||
"height_count",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
weekindex_to_dateindex_count: EagerVec::forced_import(
|
||||
&db,
|
||||
"dateindex_count",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
difficultyepoch_to_height_count: EagerVec::forced_import(
|
||||
&db,
|
||||
"height_count",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
monthindex_to_dateindex_count: EagerVec::forced_import(
|
||||
&db,
|
||||
"dateindex_count",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
quarterindex_to_monthindex_count: EagerVec::forced_import(
|
||||
&db,
|
||||
"monthindex_count",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
semesterindex_to_monthindex_count: EagerVec::forced_import(
|
||||
&db,
|
||||
"monthindex_count",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
yearindex_to_monthindex_count: EagerVec::forced_import(
|
||||
&db,
|
||||
"monthindex_count",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
decadeindex_to_yearindex_count: EagerVec::forced_import(
|
||||
&db,
|
||||
"yearindex_count",
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
txinindex_to_txoutindex: eager!("txoutindex"),
|
||||
txoutindex_to_txoutindex: lazy!("txoutindex", indexer.vecs.txoutindex_to_value),
|
||||
txinindex_to_txinindex: lazy!("txinindex", indexer.vecs.txinindex_to_outpoint),
|
||||
p2pk33addressindex_to_p2pk33addressindex: lazy!("p2pk33addressindex", indexer.vecs.p2pk33addressindex_to_p2pk33bytes),
|
||||
p2pk65addressindex_to_p2pk65addressindex: lazy!("p2pk65addressindex", indexer.vecs.p2pk65addressindex_to_p2pk65bytes),
|
||||
p2pkhaddressindex_to_p2pkhaddressindex: lazy!("p2pkhaddressindex", indexer.vecs.p2pkhaddressindex_to_p2pkhbytes),
|
||||
p2shaddressindex_to_p2shaddressindex: lazy!("p2shaddressindex", indexer.vecs.p2shaddressindex_to_p2shbytes),
|
||||
p2traddressindex_to_p2traddressindex: lazy!("p2traddressindex", indexer.vecs.p2traddressindex_to_p2trbytes),
|
||||
p2wpkhaddressindex_to_p2wpkhaddressindex: lazy!("p2wpkhaddressindex", indexer.vecs.p2wpkhaddressindex_to_p2wpkhbytes),
|
||||
p2wshaddressindex_to_p2wshaddressindex: lazy!("p2wshaddressindex", indexer.vecs.p2wshaddressindex_to_p2wshbytes),
|
||||
p2aaddressindex_to_p2aaddressindex: lazy!("p2aaddressindex", indexer.vecs.p2aaddressindex_to_p2abytes),
|
||||
p2msoutputindex_to_p2msoutputindex: lazy!("p2msoutputindex", indexer.vecs.p2msoutputindex_to_txindex),
|
||||
emptyoutputindex_to_emptyoutputindex: lazy!("emptyoutputindex", indexer.vecs.emptyoutputindex_to_txindex),
|
||||
unknownoutputindex_to_unknownoutputindex: lazy!("unknownoutputindex", indexer.vecs.unknownoutputindex_to_txindex),
|
||||
opreturnindex_to_opreturnindex: lazy!("opreturnindex", indexer.vecs.opreturnindex_to_txindex),
|
||||
txindex_to_txindex: lazy!("txindex", indexer.vecs.txindex_to_txid),
|
||||
txindex_to_input_count: eager!("input_count"),
|
||||
txindex_to_output_count: eager!("output_count"),
|
||||
dateindex_to_date: eager!("date"),
|
||||
dateindex_to_dateindex: eager!("dateindex"),
|
||||
dateindex_to_first_height: eager!("first_height"),
|
||||
dateindex_to_monthindex: eager!("monthindex"),
|
||||
dateindex_to_weekindex: eager!("weekindex"),
|
||||
decadeindex_to_decadeindex: eager!("decadeindex"),
|
||||
decadeindex_to_first_yearindex: eager!("first_yearindex"),
|
||||
difficultyepoch_to_difficultyepoch: eager!("difficultyepoch"),
|
||||
difficultyepoch_to_first_height: eager!("first_height"),
|
||||
halvingepoch_to_first_height: eager!("first_height"),
|
||||
halvingepoch_to_halvingepoch: eager!("halvingepoch"),
|
||||
height_to_date: eager!("date"),
|
||||
height_to_difficultyepoch: eager!("difficultyepoch"),
|
||||
height_to_halvingepoch: eager!("halvingepoch"),
|
||||
height_to_height: eager!("height"),
|
||||
monthindex_to_first_dateindex: eager!("first_dateindex"),
|
||||
monthindex_to_monthindex: eager!("monthindex"),
|
||||
monthindex_to_quarterindex: eager!("quarterindex"),
|
||||
monthindex_to_semesterindex: eager!("semesterindex"),
|
||||
monthindex_to_yearindex: eager!("yearindex"),
|
||||
quarterindex_to_first_monthindex: eager!("first_monthindex"),
|
||||
semesterindex_to_first_monthindex: eager!("first_monthindex"),
|
||||
weekindex_to_first_dateindex: eager!("first_dateindex"),
|
||||
yearindex_to_first_monthindex: eager!("first_monthindex"),
|
||||
quarterindex_to_quarterindex: eager!("quarterindex"),
|
||||
semesterindex_to_semesterindex: eager!("semesterindex"),
|
||||
weekindex_to_weekindex: eager!("weekindex"),
|
||||
yearindex_to_decadeindex: eager!("decadeindex"),
|
||||
yearindex_to_yearindex: eager!("yearindex"),
|
||||
height_to_date_fixed: eager!("date_fixed"),
|
||||
height_to_dateindex: eager!("dateindex"),
|
||||
height_to_timestamp_fixed: eager!("timestamp_fixed"),
|
||||
height_to_txindex_count: eager!("txindex_count"),
|
||||
dateindex_to_height_count: eager!("height_count"),
|
||||
weekindex_to_dateindex_count: eager!("dateindex_count"),
|
||||
difficultyepoch_to_height_count: eager!("height_count"),
|
||||
monthindex_to_dateindex_count: eager!("dateindex_count"),
|
||||
quarterindex_to_monthindex_count: eager!("monthindex_count"),
|
||||
semesterindex_to_monthindex_count: eager!("monthindex_count"),
|
||||
yearindex_to_monthindex_count: eager!("monthindex_count"),
|
||||
decadeindex_to_yearindex_count: eager!("yearindex_count"),
|
||||
db,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user