mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-25 07:09:59 -07:00
general: fixed builds
This commit is contained in:
@@ -18,21 +18,27 @@ use storage::{Stores, Vecs};
|
||||
#[derive(Clone)]
|
||||
pub struct Computer {
|
||||
path: PathBuf,
|
||||
pub vecs: Vecs,
|
||||
pub stores: Stores,
|
||||
vecs: Option<Vecs>,
|
||||
stores: Option<Stores>,
|
||||
}
|
||||
|
||||
impl Computer {
|
||||
pub fn import(computed_dir: &Path) -> color_eyre::Result<Self> {
|
||||
let vecs = Vecs::import(&computed_dir.join("vecs"))?;
|
||||
|
||||
let stores = Stores::import(&computed_dir.join("stores"))?;
|
||||
|
||||
Ok(Self {
|
||||
pub fn new(computed_dir: &Path) -> Self {
|
||||
Self {
|
||||
path: computed_dir.to_owned(),
|
||||
vecs,
|
||||
stores,
|
||||
})
|
||||
vecs: None,
|
||||
stores: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn import_vecs(&mut self) -> color_eyre::Result<()> {
|
||||
self.vecs = Some(Vecs::import(&self.path.join("vecs"))?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn import_stores(&mut self) -> color_eyre::Result<()> {
|
||||
self.stores = Some(Stores::import(&self.path.join("stores"))?);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,65 +46,65 @@ impl Computer {
|
||||
pub fn compute(&mut self, indexer: &mut Indexer, starting_indexes: Indexes, exit: &Exit) -> color_eyre::Result<()> {
|
||||
info!("Computing...");
|
||||
|
||||
let height_count = indexer.vecs.height_to_size.len();
|
||||
let txindexes_count = indexer.vecs.txindex_to_txid.len();
|
||||
let txinindexes_count = indexer.vecs.txinindex_to_txoutindex.len();
|
||||
let txoutindexes_count = indexer.vecs.txoutindex_to_addressindex.len();
|
||||
let height_count = indexer.vecs().height_to_size.len();
|
||||
let txindexes_count = indexer.vecs().txindex_to_txid.len();
|
||||
let txinindexes_count = indexer.vecs().txinindex_to_txoutindex.len();
|
||||
let txoutindexes_count = indexer.vecs().txoutindex_to_addressindex.len();
|
||||
|
||||
// TODO: Remove all outdated
|
||||
|
||||
// self.vecs.txindex_to_last_txinindex.compute_last_index_from_first(
|
||||
// starting_indexes.txindex,
|
||||
// &mut indexer.vecs.txindex_to_first_txinindex,
|
||||
// &mut indexer.vecs().txindex_to_first_txinindex,
|
||||
// txinindexes_count,
|
||||
// exit,
|
||||
// )?;
|
||||
|
||||
// self.vecs.txindex_to_inputs_count.compute_count_from_indexes(
|
||||
// starting_indexes.txindex,
|
||||
// &mut indexer.vecs.txindex_to_first_txinindex,
|
||||
// &mut indexer.vecs().txindex_to_first_txinindex,
|
||||
// &mut self.vecs.txindex_to_last_txinindex,
|
||||
// exit,
|
||||
// )?;
|
||||
|
||||
// self.vecs.txindex_to_last_txoutindex.compute_last_index_from_first(
|
||||
// starting_indexes.txindex,
|
||||
// &mut indexer.vecs.txindex_to_first_txoutindex,
|
||||
// &mut indexer.vecs().txindex_to_first_txoutindex,
|
||||
// txoutindexes_count,
|
||||
// exit,
|
||||
// )?;
|
||||
|
||||
// self.vecs.txindex_to_outputs_count.compute_count_from_indexes(
|
||||
// starting_indexes.txindex,
|
||||
// &mut indexer.vecs.txindex_to_first_txoutindex,
|
||||
// &mut indexer.vecs().txindex_to_first_txoutindex,
|
||||
// &mut self.vecs.txindex_to_last_txoutindex,
|
||||
// exit,
|
||||
// )?;
|
||||
|
||||
self.vecs.height_to_height.compute_transform(
|
||||
self.mut_vecs().height_to_height.compute_transform(
|
||||
starting_indexes.height,
|
||||
&mut indexer.vecs.height_to_timestamp,
|
||||
&mut indexer.mut_vecs().height_to_timestamp,
|
||||
|_, height| height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.vecs.height_to_date.compute_transform(
|
||||
self.mut_vecs().height_to_date.compute_transform(
|
||||
starting_indexes.height,
|
||||
&mut indexer.vecs.height_to_timestamp,
|
||||
&mut indexer.mut_vecs().height_to_timestamp,
|
||||
|timestamp, _| Date::from(*timestamp),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
// self.vecs.height_to_last_txindex.compute_last_index_from_first(
|
||||
// starting_indexes.height,
|
||||
// &mut indexer.vecs.height_to_first_txindex,
|
||||
// &mut indexer.vecs().height_to_first_txindex,
|
||||
// height_count,
|
||||
// exit,
|
||||
// )?;
|
||||
|
||||
// self.vecs.txindex_to_height.compute_inverse_less_to_more(
|
||||
// starting_indexes.height,
|
||||
// &mut indexer.vecs.height_to_first_txindex,
|
||||
// &mut indexer.vecs().height_to_first_txindex,
|
||||
// &mut self.vecs.height_to_last_txindex,
|
||||
// exit,
|
||||
// )?;
|
||||
@@ -106,16 +112,16 @@ impl Computer {
|
||||
// self.vecs.txindex_to_is_coinbase.compute_is_first_ordered(
|
||||
// starting_indexes.txindex,
|
||||
// &mut self.vecs.txindex_to_height,
|
||||
// &mut indexer.vecs.height_to_first_txindex,
|
||||
// &mut indexer.vecs().height_to_first_txindex,
|
||||
// exit,
|
||||
// )?;
|
||||
|
||||
// self.vecs.txindex_to_fee.compute_transform(
|
||||
// &mut self.vecs.txindex_to_height,
|
||||
// &mut indexer.vecs.height_to_first_txindex,
|
||||
// &mut indexer.vecs().height_to_first_txindex,
|
||||
// )?;
|
||||
|
||||
let date_count = self.vecs.height_to_date.len();
|
||||
let date_count = self.vecs().height_to_date.len();
|
||||
|
||||
// self.vecs.height_to_dateindex.compute(...)
|
||||
|
||||
@@ -144,4 +150,20 @@ impl Computer {
|
||||
pub fn path(&self) -> &Path {
|
||||
&self.path
|
||||
}
|
||||
|
||||
pub fn vecs(&self) -> &Vecs {
|
||||
self.vecs.as_ref().unwrap()
|
||||
}
|
||||
|
||||
pub fn mut_vecs(&mut self) -> &mut Vecs {
|
||||
self.vecs.as_mut().unwrap()
|
||||
}
|
||||
|
||||
pub fn stores(&self) -> &Stores {
|
||||
self.stores.as_ref().unwrap()
|
||||
}
|
||||
|
||||
pub fn mut_stores(&mut self) -> &mut Stores {
|
||||
self.stores.as_mut().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user