global: snapshot

This commit is contained in:
nym21
2025-02-27 12:32:54 +01:00
parent 677aca7a03
commit 877f9299e1
53 changed files with 259 additions and 203 deletions

View File

@@ -1,35 +1,35 @@
use std::path::{Path, PathBuf};
use brk_exit::Exit;
use brk_indexer::Indexer;
pub use brk_parser::rpc;
use hodor::Hodor;
mod storage;
use brk_core::Date;
use storable_vec::SINGLE_THREAD;
use storage::{Fjalls, StorableVecs};
use brk_vec::SINGLE_THREAD;
use storage::{Stores, Vecs};
pub struct Computer<const MODE: u8> {
path: PathBuf,
pub vecs: StorableVecs<MODE>,
pub trees: Fjalls,
pub vecs: Vecs<MODE>,
pub stores: Stores,
}
impl<const MODE: u8> Computer<MODE> {
pub fn import(computed_dir: &Path) -> color_eyre::Result<Self> {
let vecs = StorableVecs::import(&computed_dir.join("vecs"))?;
let trees = Fjalls::import(&computed_dir.join("fjall"))?;
let vecs = Vecs::import(&computed_dir.join("vecs"))?;
let stores = Stores::import(&computed_dir.join("fjall"))?;
Ok(Self {
path: computed_dir.to_owned(),
vecs,
trees,
stores,
})
}
}
impl Computer<SINGLE_THREAD> {
pub fn compute(&mut self, mut indexer: Indexer<SINGLE_THREAD>, hodor: &Hodor) -> color_eyre::Result<()> {
pub fn compute(&mut self, mut indexer: Indexer<SINGLE_THREAD>, exit: &Exit) -> color_eyre::Result<()> {
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();

View File

@@ -1,13 +1,13 @@
use std::path::Path;
use brk_computer::Computer;
use brk_exit::Exit;
use brk_indexer::Indexer;
use hodor::Hodor;
pub fn main() -> color_eyre::Result<()> {
color_eyre::install()?;
let hodor = Hodor::new();
let exit = Exit::new();
let i = std::time::Instant::now();
@@ -17,7 +17,7 @@ pub fn main() -> color_eyre::Result<()> {
let mut computer = Computer::import(&outputs_dir.join("computed"))?;
computer.compute(indexer, &hodor)?;
computer.compute(indexer, &exit)?;
dbg!(i.elapsed());

View File

@@ -1,5 +1,5 @@
mod fjalls;
mod storable_vecs;
mod stores;
mod vecs;
pub use fjalls::*;
pub use storable_vecs::*;
pub use stores::*;
pub use vecs::*;

View File

@@ -2,14 +2,14 @@ use std::path::Path;
use brk_core::{AddressindexTxoutindex, Unit};
use brk_indexer::Store;
use storable_vec::Version;
use brk_vec::Version;
pub struct Fjalls {
pub struct Stores {
pub address_to_utxos_received: Store<AddressindexTxoutindex, Unit>,
pub address_to_utxos_spent: Store<AddressindexTxoutindex, Unit>,
}
impl Fjalls {
impl Stores {
pub fn import(path: &Path) -> color_eyre::Result<Self> {
let address_to_utxos_received = Store::import(&path.join("address_to_utxos_received"), Version::from(1))?;
let address_to_utxos_spent = Store::import(&path.join("address_to_utxos_spent"), Version::from(1))?;

View File

@@ -4,13 +4,13 @@ use brk_core::{
Addressindex, Cents, Close, Date, Dateindex, Dollars, Feerate, Height, High, Low, Open, Sats, Timestamp, Txindex,
Txinindex, Txoutindex,
};
use storable_vec::{StorableVec, Version};
use brk_vec::{StorableVec, Version};
// mod base;
// use base::*;
pub struct StorableVecs<const MODE: u8> {
pub struct Vecs<const MODE: u8> {
pub dateindex_to_first_height: StorableVec<Dateindex, Height, MODE>,
// pub dateindex_to_last_height: StorableVec<Dateindex, Height, MODE>,
// pub height_to_block_interval: StorableVec<Height, Timestamp, MODE>,
@@ -56,7 +56,7 @@ pub struct StorableVecs<const MODE: u8> {
pub txindex_to_outputs_sum: StorableVec<Txindex, Sats, MODE>,
}
impl<const MODE: u8> StorableVecs<MODE> {
impl<const MODE: u8> Vecs<MODE> {
pub fn import(path: &Path) -> color_eyre::Result<Self> {
fs::create_dir_all(path)?;