global: snapshot

This commit is contained in:
nym21
2025-02-28 11:52:25 +01:00
parent 5b1ca3711a
commit 1b93ccf608
35 changed files with 460 additions and 271 deletions

View File

@@ -1,3 +1,5 @@
#![doc = include_str!("../README.md")]
use std::path::{Path, PathBuf};
use brk_exit::Exit;
@@ -37,42 +39,52 @@ impl Computer<SINGLE_THREAD> {
// TODO: Remove all outdated
self.vecs
.txindex_to_last_txinindex
.compute_last_index_from_first(&mut indexer.vecs.txindex_to_first_txinindex, txinindexes_count)?;
self.vecs.txindex_to_last_txinindex.compute_last_index_from_first(
&mut indexer.vecs.txindex_to_first_txinindex,
txinindexes_count,
exit,
)?;
self.vecs.txindex_to_inputs_count.compute_count_from_indexes(
&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(&mut indexer.vecs.txindex_to_first_txoutindex, txoutindexes_count)?;
self.vecs.txindex_to_last_txoutindex.compute_last_index_from_first(
&mut indexer.vecs.txindex_to_first_txoutindex,
txoutindexes_count,
exit,
)?;
self.vecs.txindex_to_outputs_count.compute_count_from_indexes(
&mut indexer.vecs.txindex_to_first_txoutindex,
&mut self.vecs.txindex_to_last_txoutindex,
exit,
)?;
self.vecs
.height_to_date
.compute_transform(&mut indexer.vecs.height_to_timestamp, |timestamp| {
Date::from(*timestamp)
})?;
self.vecs.height_to_date.compute_transform(
&mut indexer.vecs.height_to_timestamp,
|timestamp| Date::from(*timestamp),
exit,
)?;
self.vecs
.height_to_last_txindex
.compute_last_index_from_first(&mut indexer.vecs.height_to_first_txindex, height_count)?;
self.vecs.height_to_last_txindex.compute_last_index_from_first(
&mut indexer.vecs.height_to_first_txindex,
height_count,
exit,
)?;
self.vecs.txindex_to_height.compute_inverse_less_to_more(
&mut indexer.vecs.height_to_first_txindex,
&mut self.vecs.height_to_last_txindex,
exit,
)?;
self.vecs.txindex_to_is_coinbase.compute_is_first_ordered(
&mut self.vecs.txindex_to_height,
&mut indexer.vecs.height_to_first_txindex,
exit,
)?;
// self.vecs.txindex_to_fee.compute_transform(
@@ -86,7 +98,7 @@ impl Computer<SINGLE_THREAD> {
self.vecs
.dateindex_to_first_height
.compute_inverse_more_to_less(&mut self.vecs.height_to_dateindex)?;
.compute_inverse_more_to_less(&mut self.vecs.height_to_dateindex, exit)?;
// ---
// Date to X

View File

@@ -1,25 +1,50 @@
use std::path::Path;
use std::{path::Path, thread::sleep, time::Duration};
use brk_computer::Computer;
use brk_exit::Exit;
use brk_indexer::Indexer;
use brk_parser::{
Parser,
rpc::{self, RpcApi},
};
use brk_vec::CACHED_GETS;
use log::info;
pub fn main() -> color_eyre::Result<()> {
color_eyre::install()?;
brk_logger::init(Some(Path::new(".log")));
let data_dir = Path::new("../../../bitcoin");
let rpc = Box::leak(Box::new(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 parser = Parser::new(data_dir, rpc);
let outputs_dir = Path::new("../../_outputs");
let indexer = Indexer::import(&outputs_dir.join("indexes"))?;
let indexer: Indexer<CACHED_GETS> = Indexer::import(&outputs_dir.join("indexes"))?;
let mut computer = Computer::import(&outputs_dir.join("computed"))?;
// let mut computer = Computer::import(&outputs_dir.join("computed"))?;
computer.compute(indexer, &exit)?;
// loop {
// let block_count = rpc.get_block_count()?;
dbg!(i.elapsed());
// info!("{block_count} blocks found.");
// indexer.index(&parser, rpc, &exit)?;
// computer.compute(indexer, &exit)?;
// info!("Waiting for new blocks...");
// while block_count == rpc.get_block_count()? {
// sleep(Duration::from_secs(1))
// }
// }
Ok(())
}