mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 22:59:58 -07:00
52 lines
1.5 KiB
Rust
52 lines
1.5 KiB
Rust
use std::{fs, path::Path};
|
|
|
|
use brk_computer::Computer;
|
|
use brk_error::Result;
|
|
use brk_indexer::Indexer;
|
|
use brk_interface::{Index, Interface, Params, ParamsOpt};
|
|
use brk_parser::Parser;
|
|
use vecdb::Exit;
|
|
|
|
pub fn main() -> Result<()> {
|
|
let bitcoin_dir = Path::new(&std::env::var("HOME").unwrap())
|
|
.join("Library")
|
|
.join("Application Support")
|
|
.join("Bitcoin");
|
|
// let bitcoin_dir = Path::new("/Volumes/WD_BLACK1/bitcoin");
|
|
|
|
let blocks_dir = bitcoin_dir.join("blocks");
|
|
|
|
let outputs_dir = Path::new(&std::env::var("HOME").unwrap()).join(".brk");
|
|
fs::create_dir_all(&outputs_dir)?;
|
|
// let outputs_dir = Path::new("/Volumes/WD_BLACK1/brk");
|
|
|
|
let rpc = Box::leak(Box::new(bitcoincore_rpc::Client::new(
|
|
"http://localhost:8332",
|
|
bitcoincore_rpc::Auth::CookieFile(bitcoin_dir.join(".cookie")),
|
|
)?));
|
|
|
|
let exit = Exit::new();
|
|
exit.set_ctrlc_handler();
|
|
|
|
let parser = Parser::new(blocks_dir, rpc);
|
|
|
|
let indexer = Indexer::forced_import(&outputs_dir)?;
|
|
|
|
let computer = Computer::forced_import(&outputs_dir, &indexer, None)?;
|
|
|
|
let interface = Interface::build(&parser, &indexer, &computer);
|
|
|
|
dbg!(interface.search_and_format(Params {
|
|
index: Index::Height,
|
|
ids: vec!["date"].into(),
|
|
rest: ParamsOpt::default().set_from(-1),
|
|
})?);
|
|
dbg!(interface.search_and_format(Params {
|
|
index: Index::Height,
|
|
ids: vec!["date", "timestamp"].into(),
|
|
rest: ParamsOpt::default().set_from(-10).set_count(5),
|
|
})?);
|
|
|
|
Ok(())
|
|
}
|