general: fixed builds

This commit is contained in:
nym21
2025-03-03 19:36:17 +01:00
parent d24096374f
commit fc6f12fb22
16 changed files with 229 additions and 98 deletions
@@ -13,8 +13,8 @@ const DAT: &str = ".dat";
pub struct BlkIndexToBlkPath(BTreeMap<u16, PathBuf>);
impl BlkIndexToBlkPath {
pub fn scan(data_dir: &Path) -> Self {
let blocks_dir = data_dir.join("blocks");
pub fn scan(bitcoin_dir: &Path) -> Self {
let blocks_dir = bitcoin_dir.join("blocks");
Self(
fs::read_dir(blocks_dir)
@@ -14,8 +14,8 @@ pub struct BlkIndexToBlkRecap {
}
impl BlkIndexToBlkRecap {
pub fn import(data_dir: &Path, blk_index_to_blk_path: &BlkIndexToBlkPath, start: Option<Height>) -> (Self, u16) {
let path = data_dir.join("blk_index_to_blk_recap.json");
pub fn import(bitcoin_dir: &Path, blk_index_to_blk_path: &BlkIndexToBlkPath, start: Option<Height>) -> (Self, u16) {
let path = bitcoin_dir.join("blk_index_to_blk_recap.json");
let tree = {
if let Ok(file) = File::open(&path) {
+7 -7
View File
@@ -47,14 +47,14 @@ const MAGIC_BYTES: [u8; 4] = [249, 190, 180, 217];
const BOUND_CAP: usize = 50;
pub struct Parser {
data_dir: PathBuf,
bitcoin_dir: PathBuf,
rpc: &'static bitcoincore_rpc::Client,
}
impl Parser {
pub fn new(data_dir: &Path, rpc: &'static bitcoincore_rpc::Client) -> Self {
pub fn new(bitcoin_dir: &Path, rpc: &'static bitcoincore_rpc::Client) -> Self {
Self {
data_dir: data_dir.to_owned(),
bitcoin_dir: bitcoin_dir.to_owned(),
rpc,
}
}
@@ -69,19 +69,19 @@ impl Parser {
/// For an example checkout `./main.rs`
///
pub fn parse(&self, start: Option<Height>, end: Option<Height>) -> Receiver<(Height, Block, BlockHash)> {
let data_dir = self.data_dir.as_path();
let bitcoin_dir = self.bitcoin_dir.as_path();
let rpc = self.rpc;
let (send_bytes, recv_bytes) = bounded(BOUND_CAP);
let (send_block, recv_block) = bounded(BOUND_CAP);
let (send_height_block_hash, recv_height_block_hash) = bounded(BOUND_CAP);
let blk_index_to_blk_path = BlkIndexToBlkPath::scan(data_dir);
let blk_index_to_blk_path = BlkIndexToBlkPath::scan(bitcoin_dir);
let (mut blk_index_to_blk_recap, blk_index) =
BlkIndexToBlkRecap::import(data_dir, &blk_index_to_blk_path, start);
BlkIndexToBlkRecap::import(bitcoin_dir, &blk_index_to_blk_path, start);
let xor_bytes = XORBytes::from(data_dir);
let xor_bytes = XORBytes::from(bitcoin_dir);
thread::spawn(move || {
let xor_bytes = xor_bytes;
+3 -3
View File
@@ -7,11 +7,11 @@ use brk_parser::Parser;
fn main() {
let i = std::time::Instant::now();
let data_dir = Path::new("../../../bitcoin");
let bitcoin_dir = Path::new("../../../bitcoin");
let rpc = Box::leak(Box::new(
Client::new(
"http://localhost:8332",
Auth::CookieFile(Path::new(data_dir).join(".cookie")),
Auth::CookieFile(Path::new(bitcoin_dir).join(".cookie")),
)
.unwrap(),
));
@@ -19,7 +19,7 @@ fn main() {
let start = None;
let end = None;
let parser = Parser::new(data_dir, rpc);
let parser = Parser::new(bitcoin_dir, rpc);
parser.parse(start, end).iter().for_each(|(height, _block, hash)| {
println!("{height}: {hash}");