-
-
Save romanz/2630210f497b69d605cdb831fd057b98 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::str::FromStr; | |
| use bitcoin::{BlockHash, Txid}; | |
| use bitcoincore_rpc::{Auth, Client, RpcApi}; | |
| type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>; | |
| fn main() -> Result<()> { | |
| let args: Vec<String> = std::env::args().skip(1).collect(); | |
| let auth = Auth::CookieFile(".cookie".into()); | |
| let rpc = Client::new("http://localhost:8332", auth)?; | |
| let txid = Txid::from_str(&args[0])?; | |
| let block_hash = BlockHash::from_str(&args[1])?; | |
| let t = std::time::Instant::now(); | |
| let count = 1_000; | |
| for _ in 0..count { | |
| rpc.get_raw_transaction_hex(&txid, Some(&block_hash))?; | |
| } | |
| let dt = t.elapsed(); | |
| println!("iterations = {}", count); | |
| println!("average RPC duration = {:?}", dt.div_f32(count as f32)); | |
| Ok(()) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment