diff --git a/src/api.rs b/src/api.rs index 78ec784..f722374 100644 --- a/src/api.rs +++ b/src/api.rs @@ -18,7 +18,6 @@ use serde::Deserialize; use std::collections::HashMap; pub use bitcoin::consensus::{deserialize, serialize}; -use bitcoin::hash_types::TxMerkleNode; pub use bitcoin::hex::FromHex; pub use bitcoin::{ absolute, block, transaction, Address, Amount, Block, BlockHash, CompactTarget, FeeRate, @@ -204,20 +203,6 @@ pub struct BlockTime { pub height: u32, } -/// Summary about a [`Block`]. -#[derive(Debug, Clone, Deserialize, PartialEq, Eq)] -pub struct BlockSummary { - /// The [`Block`]'s hash. - pub id: BlockHash, - /// The [`Block`]'s timestamp and height. - #[serde(flatten)] - pub time: BlockTime, - /// The [`BlockHash`] of the previous [`Block`] (`None` for the genesis [`Block`]). - pub previousblockhash: Option, - /// The Merkle root of the [`Block`]'s [`Transaction`]s. - pub merkle_root: TxMerkleNode, -} - /// Statistics about an [`Address`]. #[derive(Debug, Clone, Deserialize, PartialEq, Eq)] pub struct AddressStats { diff --git a/src/async.rs b/src/async.rs index fb6d56d..4c37657 100644 --- a/src/async.rs +++ b/src/async.rs @@ -29,9 +29,9 @@ use log::{debug, error, info, trace}; use reqwest::{header, Body, Client, Response}; use crate::{ - AddressStats, BlockInfo, BlockStatus, BlockSummary, Builder, Error, MempoolRecentTx, - MempoolStats, MerkleProof, OutputStatus, ScriptHashStats, SubmitPackageResult, Tx, TxStatus, - Utxo, BASE_BACKOFF_MILLIS, RETRYABLE_ERROR_CODES, + AddressStats, BlockInfo, BlockStatus, Builder, Error, MempoolRecentTx, MempoolStats, + MerkleProof, OutputStatus, ScriptHashStats, SubmitPackageResult, Tx, TxStatus, Utxo, + BASE_BACKOFF_MILLIS, RETRYABLE_ERROR_CODES, }; /// An async client for interacting with an Esplora API server. @@ -563,12 +563,12 @@ impl AsyncClient { /// /// The maximum number of summaries returned depends on the backend itself: /// esplora returns `10` while [mempool.space](https://mempool.space/docs/api) returns `15`. - pub async fn get_blocks(&self, height: Option) -> Result, Error> { + pub async fn get_blocks(&self, height: Option) -> Result, Error> { let path = match height { Some(height) => format!("/blocks/{height}"), None => "/blocks".to_string(), }; - let blocks: Vec = self.get_response_json(&path).await?; + let blocks: Vec = self.get_response_json(&path).await?; if blocks.is_empty() { return Err(Error::InvalidResponse); } diff --git a/src/blocking.rs b/src/blocking.rs index ff54d7f..3ccf767 100644 --- a/src/blocking.rs +++ b/src/blocking.rs @@ -29,9 +29,9 @@ use bitcoin::hex::{DisplayHex, FromHex}; use bitcoin::{Address, Block, BlockHash, MerkleBlock, Script, Transaction, Txid}; use crate::{ - AddressStats, BlockInfo, BlockStatus, BlockSummary, Builder, Error, MempoolRecentTx, - MempoolStats, MerkleProof, OutputStatus, ScriptHashStats, SubmitPackageResult, Tx, TxStatus, - Utxo, BASE_BACKOFF_MILLIS, RETRYABLE_ERROR_CODES, + AddressStats, BlockInfo, BlockStatus, Builder, Error, MempoolRecentTx, MempoolStats, + MerkleProof, OutputStatus, ScriptHashStats, SubmitPackageResult, Tx, TxStatus, Utxo, + BASE_BACKOFF_MILLIS, RETRYABLE_ERROR_CODES, }; /// A blocking client for interacting with an Esplora API server. @@ -501,12 +501,12 @@ impl BlockingClient { /// /// The maximum number of summaries returned depends on the backend itself: /// esplora returns `10` while [mempool.space](https://mempool.space/docs/api) returns `15`. - pub fn get_blocks(&self, height: Option) -> Result, Error> { + pub fn get_blocks(&self, height: Option) -> Result, Error> { let path = match height { Some(height) => format!("/blocks/{height}"), None => "/blocks".to_string(), }; - let blocks: Vec = self.get_response_json(&path)?; + let blocks: Vec = self.get_response_json(&path)?; if blocks.is_empty() { return Err(Error::InvalidResponse); } diff --git a/src/lib.rs b/src/lib.rs index e686078..d3dc05b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1016,7 +1016,7 @@ mod test { let start_height = BITCOIND.client.get_block_count().unwrap().0; let blocks1 = blocking_client.get_blocks(None).unwrap(); let blocks_async1 = async_client.get_blocks(None).await.unwrap(); - assert_eq!(blocks1[0].time.height, start_height as u32); + assert_eq!(blocks1[0].height, start_height as u32); assert_eq!(blocks1, blocks_async1); generate_blocks_and_wait(10); let blocks2 = blocking_client.get_blocks(None).unwrap(); @@ -1031,7 +1031,7 @@ mod test { .await .unwrap(); assert_eq!(blocks3, blocks_async3); - assert_eq!(blocks3[0].time.height, start_height as u32); + assert_eq!(blocks3[0].height, start_height as u32); assert_eq!(blocks3, blocks1); let blocks_genesis = blocking_client.get_blocks(Some(0)).unwrap(); let blocks_genesis_async = async_client.get_blocks(Some(0)).await.unwrap();