global: snapshot

This commit is contained in:
nym21
2026-02-21 17:40:34 +01:00
parent 2128aab6ca
commit be0d749f9c
13 changed files with 284 additions and 258 deletions
+6 -27
View File
@@ -2,10 +2,7 @@ use brk_error::Result;
use brk_reader::Reader;
use brk_rpc::{Auth, Client};
#[allow(clippy::needless_doctest_main)]
fn main() -> Result<()> {
let i = std::time::Instant::now();
let bitcoin_dir = Client::default_bitcoin_path();
let client = Client::new(
@@ -13,32 +10,14 @@ fn main() -> Result<()> {
Auth::CookieFile(bitcoin_dir.join(".cookie")),
)?;
let blocks_dir = bitcoin_dir.join("blocks");
let reader = Reader::new(bitcoin_dir.join("blocks"), &client);
let reader = Reader::new(blocks_dir, &client);
let start = None;
// let start = Some(916037_u32.into());
let end = None;
reader.read(start, end).iter().for_each(|block| {
// Stream all blocks
let i = std::time::Instant::now();
for block in reader.read(None, None) {
println!("{}: {}", block.height(), block.hash());
});
// let v = diff.iter().rev().take(10).collect::<Vec<_>>();
// let block_0 = parser.get(Height::new(0))?;
// dbg!("{}", block_0.coinbase_tag());
// let block_158251 = parser.get(Height::new(158251))?;
// dbg!("{}", block_158251.coinbase_tag());
// let block_173195 = parser.get(Height::new(173195))?;
// dbg!("{}", block_173195.coinbase_tag());
// let block_840_000 = parser.get(Height::new(840_004))?;
// dbg!("{}", block_840_000.coinbase_tag());
dbg!(i.elapsed());
}
println!("Full read: {:?}", i.elapsed());
Ok(())
}