mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-29 09:09:58 -07:00
global: snapshot
This commit is contained in:
@@ -2,48 +2,35 @@ use std::path::{Path, PathBuf};
|
||||
|
||||
use exit::Exit;
|
||||
use indexer::Indexer;
|
||||
use iterator::rpc;
|
||||
pub use iterator::rpc;
|
||||
|
||||
mod storage;
|
||||
mod structs;
|
||||
|
||||
use storable_vec::{CACHED_GETS, SINGLE_THREAD};
|
||||
use storable_vec::SINGLE_THREAD;
|
||||
use storage::{Fjalls, StorableVecs};
|
||||
use structs::*;
|
||||
pub use structs::*;
|
||||
|
||||
pub struct Computer<const MODE: u8> {
|
||||
outputs_dir: PathBuf,
|
||||
path: PathBuf,
|
||||
pub vecs: StorableVecs<MODE>,
|
||||
pub trees: Fjalls,
|
||||
}
|
||||
|
||||
impl<const MODE: u8> Computer<MODE> {
|
||||
pub fn import(outputs_dir: &Path) -> color_eyre::Result<Self> {
|
||||
let outputs_dir = outputs_dir.to_owned();
|
||||
let computed_dir = outputs_dir.join("computed");
|
||||
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"))?;
|
||||
Ok(Self {
|
||||
outputs_dir,
|
||||
path: computed_dir.to_owned(),
|
||||
vecs,
|
||||
trees,
|
||||
})
|
||||
}
|
||||
|
||||
fn open_indexer<const MODE_IDX: u8>(&self) -> color_eyre::Result<Indexer<MODE_IDX>> {
|
||||
Indexer::import(&self.outputs_dir.join("indexes"))
|
||||
}
|
||||
}
|
||||
|
||||
impl Computer<SINGLE_THREAD> {
|
||||
pub fn compute(&mut self, bitcoin_dir: &Path, rpc: rpc::Client, exit: &Exit) -> color_eyre::Result<()> {
|
||||
if false {
|
||||
let mut indexer: Indexer<CACHED_GETS> = self.open_indexer()?;
|
||||
indexer.index(bitcoin_dir, rpc, exit)?;
|
||||
}
|
||||
|
||||
let mut indexer: Indexer<SINGLE_THREAD> = self.open_indexer()?;
|
||||
|
||||
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();
|
||||
@@ -117,4 +104,8 @@ impl Computer<SINGLE_THREAD> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn path(&self) -> &Path {
|
||||
&self.path
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,26 +2,20 @@ use std::path::Path;
|
||||
|
||||
use bomputer::Computer;
|
||||
use exit::Exit;
|
||||
use iterator::rpc;
|
||||
use storable_vec::SINGLE_THREAD;
|
||||
use indexer::Indexer;
|
||||
|
||||
mod structs;
|
||||
|
||||
pub fn main() -> color_eyre::Result<()> {
|
||||
color_eyre::install()?;
|
||||
|
||||
let data_dir = Path::new("../../bitcoin");
|
||||
let rpc = rpc::Client::new(
|
||||
"http://localhost:8332",
|
||||
rpc::Auth::CookieFile(Path::new(data_dir).join(".cookie")),
|
||||
)?;
|
||||
let exit = Exit::new();
|
||||
|
||||
let i = std::time::Instant::now();
|
||||
|
||||
let mut computer: Computer<SINGLE_THREAD> = Computer::import(Path::new("../_outputs"))?;
|
||||
let outputs_dir = Path::new("../_outputs");
|
||||
|
||||
computer.compute(data_dir, rpc, &exit)?;
|
||||
Computer::import(&outputs_dir.join("computed"))?.compute(Indexer::import(&outputs_dir.join("indexes"))?, &exit)?;
|
||||
|
||||
dbg!(i.elapsed());
|
||||
|
||||
|
||||
@@ -11,20 +11,21 @@ use crate::structs::{Date, Feerate};
|
||||
|
||||
pub struct StorableVecs<const MODE: u8> {
|
||||
pub date_to_first_height: StorableVec<Date, Height, MODE>,
|
||||
// pub date_to_last_height: StorableVec<Date, Height, MODE>,
|
||||
// pub height_to_block_interval: StorableVec<Height, Timestamp, MODE>,
|
||||
pub height_to_date: StorableVec<Height, Date, MODE>,
|
||||
// pub height_to_fee: StorableVec<Txindex, Amount, MODE>,
|
||||
// pub height_to_inputcount: StorableVec<Txindex, u32, MODE>,
|
||||
// pub height_to_inputcount: StorableVec<Height, u32, MODE>,
|
||||
// pub height_to_last_addressindex: StorableVec<Height, Addressindex, MODE>,
|
||||
pub height_to_last_txindex: StorableVec<Height, Txindex, MODE>,
|
||||
// pub height_to_last_txoutindex: StorableVec<Height, Txoutindex, MODE>,
|
||||
// pub height_to_maxfeerate: StorableVec<Txindex, Feerate, MODE>,
|
||||
// pub height_to_medianfeerate: StorableVec<Txindex, Feerate, MODE>,
|
||||
// pub height_to_minfeerate: StorableVec<Txindex, Feerate, MODE>,
|
||||
// pub height_to_outputcount: StorableVec<Txindex, u32, MODE>,
|
||||
// pub height_to_subsidy: StorableVec<Txindex, u32, MODE>,
|
||||
// pub height_to_maxfeerate: StorableVec<Height, Feerate, MODE>,
|
||||
// pub height_to_medianfeerate: StorableVec<Height, Feerate, MODE>,
|
||||
// pub height_to_minfeerate: StorableVec<Height, Feerate, MODE>,
|
||||
// pub height_to_outputcount: StorableVec<Height, u32, MODE>,
|
||||
// pub height_to_subsidy: StorableVec<Height, u32, MODE>,
|
||||
// pub height_to_totalfees: StorableVec<Height, Amount, MODE>,
|
||||
// pub height_to_txcount: StorableVec<Txindex, u32, MODE>,
|
||||
// pub height_to_txcount: StorableVec<Height, u32, MODE>,
|
||||
pub txindex_to_fee: StorableVec<Txindex, Amount, MODE>,
|
||||
pub txindex_to_height: StorableVec<Txindex, Height, MODE>,
|
||||
pub txindex_to_is_coinbase: StorableVec<Txindex, bool, MODE>,
|
||||
|
||||
Reference in New Issue
Block a user