global: snapshot + monitor: add addresses to mempool

This commit is contained in:
nym21
2025-10-14 17:36:16 +02:00
parent db0298ac1b
commit 5425085953
63 changed files with 707 additions and 330 deletions
+47
View File
@@ -0,0 +1,47 @@
use std::path::Path;
use bitcoincore_rpc::{Auth, Client};
use brk_error::Result;
use brk_reader::Reader;
#[allow(clippy::needless_doctest_main)]
fn main() -> Result<()> {
let i = std::time::Instant::now();
let bitcoin_dir = Path::new(&std::env::var("HOME").unwrap())
.join("Library")
.join("Application Support")
.join("Bitcoin");
let rpc = Box::leak(Box::new(Client::new(
"http://localhost:8332",
Auth::CookieFile(bitcoin_dir.join(".cookie")),
)?));
let reader = Reader::new(bitcoin_dir.join("blocks"), rpc);
let start = None;
// let start = Some(916037_u32.into());
let end = None;
reader.read(start, end).iter().for_each(|block| {
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());
Ok(())
}
+71
View File
@@ -0,0 +1,71 @@
use std::path::Path;
use bitcoincore_rpc::{Auth, Client};
use brk_reader::Reader;
use brk_structs::{Height, OutputType};
fn main() {
let i = std::time::Instant::now();
let bitcoin_dir = Path::new("").join("");
let rpc = Box::leak(Box::new(
Client::new(
"http://localhost:8332",
Auth::CookieFile(bitcoin_dir.join(".cookie")),
)
.unwrap(),
));
// let start = None;
// let end = None;
let parser = Reader::new(bitcoin_dir.join("blocks"), rpc);
// parser
// .parse(start, end)
// .iter()
// .for_each(|(height, _block, hash)| {
// println!("{height}: {hash}");
// });
// println!(
// "{}",
// parser
// .get(Height::new(0))
// .txdata
// .first()
// .unwrap()
// .output
// .first()
// .unwrap()
// .script_pubkey
// );
let block_850_000 = parser.get(Height::new(850_000)).unwrap();
let tx = block_850_000.txdata.iter().find(|tx| {
tx.compute_txid().to_string()
== "b10c0000004da5a9d1d9b4ae32e09f0b3e62d21a5cce5428d4ad714fb444eb5d"
});
let output = tx.unwrap().tx_out(7).unwrap();
dbg!(OutputType::from(&output.script_pubkey));
dbg!(output);
// println!(
// "{}",
// .txdata
// .first()
// .unwrap()
// .output
// .first()
// .unwrap()
// .value
// );
dbg!(i.elapsed());
}