From 35766bf251032d20508db114efc2fd47314329d2 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 22 Aug 2022 03:04:41 +0000 Subject: [PATCH] Remove unnecessary Arcs in verifier.rs --- src/verifier.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/verifier.rs b/src/verifier.rs index 90f2f3c..46c8709 100644 --- a/src/verifier.rs +++ b/src/verifier.rs @@ -1,5 +1,4 @@ use std::convert::TryInto; -use std::sync::Arc; use bitcoin::{BlockHash, TxOut}; use bitcoin::blockdata::block::Block; @@ -13,30 +12,30 @@ use lightning_block_sync::rest::RestClient; use crate::config; pub(crate) struct ChainVerifier { - rest_client: Arc, + rest_client: RestClient, } struct RestBinaryResponse(Vec); impl ChainVerifier { pub(crate) fn new() -> Self { - let rest_client = RestClient::new(config::bitcoin_rest_endpoint()).unwrap(); ChainVerifier { - rest_client: Arc::new(rest_client), + rest_client: RestClient::new(config::bitcoin_rest_endpoint()).unwrap(), } } fn retrieve_block(&self, block_height: u32) -> Result { - let rest_client = self.rest_client.clone(); tokio::task::block_in_place(move || { tokio::runtime::Handle::current().block_on(async move { - let block_hash_result = rest_client.request_resource::(&format!("blockhashbyheight/{}.bin", block_height)).await; + let uri = format!("blockhashbyheight/{}.bin", block_height); + let block_hash_result = + self.rest_client.request_resource::(&uri).await; let block_hash: Vec = block_hash_result.map_err(|error| { eprintln!("Could't find block hash at height {}: {}", block_height, error.to_string()); AccessError::UnknownChain })?.0; let block_hash = BlockHash::from_slice(&block_hash).unwrap(); - let block_result = rest_client.get_block(&block_hash).await; + let block_result = self.rest_client.get_block(&block_hash).await; let block = block_result.map_err(|error| { eprintln!("Couldn't retrieve block {}: {:?} ({})", block_height, error, block_hash); AccessError::UnknownChain -- 2.39.5