indexer: update example

This commit is contained in:
nym21
2025-07-17 11:39:25 +02:00
parent c07e66c086
commit c0a65b30ad

View File

@@ -1,6 +1,10 @@
use std::{path::Path, time::Instant}; use std::{
fs,
path::Path,
thread::sleep,
time::{Duration, Instant},
};
use brk_core::{default_bitcoin_path, default_brk_path};
use brk_exit::Exit; use brk_exit::Exit;
use brk_indexer::Indexer; use brk_indexer::Indexer;
use brk_parser::Parser; use brk_parser::Parser;
@@ -8,12 +12,12 @@ use brk_parser::Parser;
fn main() -> color_eyre::Result<()> { fn main() -> color_eyre::Result<()> {
color_eyre::install()?; color_eyre::install()?;
let i = Instant::now();
brk_logger::init(Some(Path::new(".log"))); brk_logger::init(Some(Path::new(".log")));
let bitcoin_dir = default_bitcoin_path(); // let bitcoin_dir = brk_core::default_bitcoin_path();
let brk_dir = default_brk_path(); let bitcoin_dir = Path::new("/Volumes/WD_BLACK/bitcoin");
// let outputs_dir = brk_core::default_brk_path().join("outputs");
let outputs_dir = Path::new("/Volumes/WD_BLACK/brk/outputs");
let rpc = Box::leak(Box::new(bitcoincore_rpc::Client::new( let rpc = Box::leak(Box::new(bitcoincore_rpc::Client::new(
"http://localhost:8332", "http://localhost:8332",
@@ -21,15 +25,17 @@ fn main() -> color_eyre::Result<()> {
)?)); )?));
let exit = Exit::new(); let exit = Exit::new();
let parser = Parser::new(bitcoin_dir.join("blocks"), brk_dir, rpc); let parser = Parser::new(bitcoin_dir.join("blocks"), outputs_dir.to_path_buf(), rpc);
let outputs = Path::new("../../_outputs"); fs::create_dir_all(outputs_dir)?;
let mut indexer = Indexer::forced_import(outputs)?; let mut indexer = Indexer::forced_import(outputs_dir)?;
indexer.index(&parser, rpc, &exit, true)?; loop {
let i = Instant::now();
indexer.index(&parser, rpc, &exit, false)?;
dbg!(i.elapsed());
dbg!(i.elapsed()); sleep(Duration::from_secs(5 * 60));
}
Ok(())
} }