From c0a65b30ad77bd922c17e51651209d50a3c47d81 Mon Sep 17 00:00:00 2001 From: nym21 Date: Thu, 17 Jul 2025 11:39:25 +0200 Subject: [PATCH] indexer: update example --- crates/brk_indexer/examples/main.rs | 32 +++++++++++++++++------------ 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/crates/brk_indexer/examples/main.rs b/crates/brk_indexer/examples/main.rs index f4b18234f..4669d49b3 100644 --- a/crates/brk_indexer/examples/main.rs +++ b/crates/brk_indexer/examples/main.rs @@ -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_indexer::Indexer; use brk_parser::Parser; @@ -8,12 +12,12 @@ use brk_parser::Parser; fn main() -> color_eyre::Result<()> { color_eyre::install()?; - let i = Instant::now(); - brk_logger::init(Some(Path::new(".log"))); - let bitcoin_dir = default_bitcoin_path(); - let brk_dir = default_brk_path(); + // let bitcoin_dir = brk_core::default_bitcoin_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( "http://localhost:8332", @@ -21,15 +25,17 @@ fn main() -> color_eyre::Result<()> { )?)); 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()); - - Ok(()) + sleep(Duration::from_secs(5 * 60)); + } }