mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-24 01:18:10 -07:00
Make Parser::new the only entrypoint
This commit is contained in:
@@ -21,7 +21,7 @@ pub fn run() -> color_eyre::Result<()> {
|
|||||||
let exit = Exit::new();
|
let exit = Exit::new();
|
||||||
|
|
||||||
let parser = if config.process() && rpc.is_some() {
|
let parser = if config.process() && rpc.is_some() {
|
||||||
Some(brk_parser::Parser::new_with_outputs_dir(
|
Some(brk_parser::Parser::new(
|
||||||
config.blocksdir(),
|
config.blocksdir(),
|
||||||
config.outputsdir(),
|
config.outputsdir(),
|
||||||
rpc.unwrap(),
|
rpc.unwrap(),
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ pub fn main() -> color_eyre::Result<()> {
|
|||||||
thread::Builder::new()
|
thread::Builder::new()
|
||||||
.stack_size(32 * 1024 * 1024)
|
.stack_size(32 * 1024 * 1024)
|
||||||
.spawn(move || -> color_eyre::Result<()> {
|
.spawn(move || -> color_eyre::Result<()> {
|
||||||
let parser = Parser::new(bitcoin_dir.join("blocks"), rpc);
|
let parser = Parser::new(bitcoin_dir.join("blocks"), default_brk_path(), rpc);
|
||||||
|
|
||||||
let _outputs_dir = default_brk_path().join("outputs");
|
let _outputs_dir = default_brk_path().join("outputs");
|
||||||
let outputs_dir = _outputs_dir.as_path();
|
let outputs_dir = _outputs_dir.as_path();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::{path::Path, time::Instant};
|
use std::{path::Path, time::Instant};
|
||||||
|
|
||||||
use brk_core::default_bitcoin_path;
|
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;
|
||||||
@@ -13,6 +13,7 @@ fn main() -> color_eyre::Result<()> {
|
|||||||
brk_logger::init(Some(Path::new(".log")));
|
brk_logger::init(Some(Path::new(".log")));
|
||||||
|
|
||||||
let bitcoin_dir = default_bitcoin_path();
|
let bitcoin_dir = default_bitcoin_path();
|
||||||
|
let brk_dir = default_brk_path();
|
||||||
|
|
||||||
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",
|
||||||
@@ -20,7 +21,7 @@ fn main() -> color_eyre::Result<()> {
|
|||||||
)?));
|
)?));
|
||||||
let exit = Exit::new();
|
let exit = Exit::new();
|
||||||
|
|
||||||
let parser = Parser::new(bitcoin_dir.join("blocks"), rpc);
|
let parser = Parser::new(bitcoin_dir.join("blocks"), brk_dir, rpc);
|
||||||
|
|
||||||
let outputs = Path::new("../../_outputs");
|
let outputs = Path::new("../../_outputs");
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
use bitcoincore_rpc::{Auth, Client};
|
use bitcoincore_rpc::{Auth, Client};
|
||||||
use brk_core::{Height, default_bitcoin_path};
|
use brk_core::{Height, default_bitcoin_path, default_brk_path};
|
||||||
use brk_parser::Parser;
|
use brk_parser::Parser;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let i = std::time::Instant::now();
|
let i = std::time::Instant::now();
|
||||||
|
|
||||||
let bitcoin_dir = default_bitcoin_path();
|
let bitcoin_dir = default_bitcoin_path();
|
||||||
|
let brk_dir = default_brk_path();
|
||||||
|
|
||||||
let rpc = Box::leak(Box::new(
|
let rpc = Box::leak(Box::new(
|
||||||
Client::new(
|
Client::new(
|
||||||
@@ -18,7 +19,7 @@ fn main() {
|
|||||||
let start = None;
|
let start = None;
|
||||||
let end = None;
|
let end = None;
|
||||||
|
|
||||||
let parser = Parser::new(bitcoin_dir.join("blocks"), rpc);
|
let parser = Parser::new(bitcoin_dir.join("blocks"), brk_dir, rpc);
|
||||||
|
|
||||||
parser
|
parser
|
||||||
.parse(start, end)
|
.parse(start, end)
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
use bitcoincore_rpc::{Auth, Client};
|
use bitcoincore_rpc::{Auth, Client};
|
||||||
use brk_core::{Height, OutputType, default_bitcoin_path};
|
use brk_core::{Height, OutputType, default_bitcoin_path, default_brk_path};
|
||||||
use brk_parser::Parser;
|
use brk_parser::Parser;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let i = std::time::Instant::now();
|
let i = std::time::Instant::now();
|
||||||
|
|
||||||
let bitcoin_dir = default_bitcoin_path();
|
let bitcoin_dir = default_bitcoin_path();
|
||||||
|
let brk_dir = default_brk_path();
|
||||||
|
|
||||||
let rpc = Box::leak(Box::new(
|
let rpc = Box::leak(Box::new(
|
||||||
Client::new(
|
Client::new(
|
||||||
@@ -18,7 +19,7 @@ fn main() {
|
|||||||
// let start = None;
|
// let start = None;
|
||||||
// let end = None;
|
// let end = None;
|
||||||
|
|
||||||
let parser = Parser::new(bitcoin_dir.join("blocks"), rpc);
|
let parser = Parser::new(bitcoin_dir.join("blocks"), brk_dir, rpc);
|
||||||
|
|
||||||
// parser
|
// parser
|
||||||
// .parse(start, end)
|
// .parse(start, end)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use std::{
|
|||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{BlkIndexToBlkPath, Height, blk_recap::BlkRecap};
|
use crate::{blk_recap::BlkRecap, BlkIndexToBlkPath, Height};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct BlkIndexToBlkRecap {
|
pub struct BlkIndexToBlkRecap {
|
||||||
|
|||||||
@@ -43,19 +43,14 @@ pub struct Parser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Parser {
|
impl Parser {
|
||||||
pub fn new(blocks_dir: PathBuf, rpc: &'static bitcoincore_rpc::Client) -> Self {
|
pub fn new(blocks_dir: PathBuf, brk_dir: PathBuf, rpc: &'static bitcoincore_rpc::Client) -> Self {
|
||||||
// For backward compatibility, use blocks_dir as outputs_dir
|
|
||||||
Self {
|
Self {
|
||||||
outputs_dir: blocks_dir.clone(),
|
|
||||||
blocks_dir,
|
blocks_dir,
|
||||||
|
outputs_dir: brk_dir,
|
||||||
rpc
|
rpc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_with_outputs_dir(blocks_dir: PathBuf, outputs_dir: PathBuf, rpc: &'static bitcoincore_rpc::Client) -> Self {
|
|
||||||
Self { blocks_dir, outputs_dir, rpc }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get(&self, height: Height) -> Block {
|
pub fn get(&self, height: Height) -> Block {
|
||||||
self.parse(Some(height), Some(height))
|
self.parse(Some(height), Some(height))
|
||||||
.iter()
|
.iter()
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use std::{path::Path, thread::sleep, time::Duration};
|
|||||||
|
|
||||||
use bitcoincore_rpc::RpcApi;
|
use bitcoincore_rpc::RpcApi;
|
||||||
use brk_computer::Computer;
|
use brk_computer::Computer;
|
||||||
use brk_core::default_bitcoin_path;
|
use brk_core::{default_bitcoin_path, default_brk_path};
|
||||||
use brk_exit::Exit;
|
use brk_exit::Exit;
|
||||||
use brk_fetcher::Fetcher;
|
use brk_fetcher::Fetcher;
|
||||||
use brk_indexer::Indexer;
|
use brk_indexer::Indexer;
|
||||||
@@ -18,6 +18,7 @@ pub fn main() -> color_eyre::Result<()> {
|
|||||||
let process = true;
|
let process = true;
|
||||||
|
|
||||||
let bitcoin_dir = default_bitcoin_path();
|
let bitcoin_dir = default_bitcoin_path();
|
||||||
|
let brk_dir = default_brk_path();
|
||||||
|
|
||||||
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",
|
||||||
@@ -25,7 +26,7 @@ pub fn main() -> color_eyre::Result<()> {
|
|||||||
)?));
|
)?));
|
||||||
let exit = Exit::new();
|
let exit = Exit::new();
|
||||||
|
|
||||||
let parser = Parser::new(bitcoin_dir.join("blocks"), rpc);
|
let parser = Parser::new(bitcoin_dir.join("blocks"), brk_dir, rpc);
|
||||||
|
|
||||||
let outputs_dir = Path::new("../../_outputs");
|
let outputs_dir = Path::new("../../_outputs");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user