pub struct SvNodeClient { /* private fields */ }Expand description
Client for communicating with a Bitcoin SV node.
This client manages both JSON-RPC and REST API connections to a Bitcoin SV node. The client is cloneable and safe for concurrent use - clones share the same underlying connection pool for efficient resource usage.
§Example
use bitcoinsv_rpc::{NodeClient, SvNodeClient};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = SvNodeClient::new(
"http://localhost:8332",
Some("user".to_string()),
Some("password".to_string()),
)?;
let hash = client.get_best_block_hash().await?;
println!("Best block: {}", hash);
// Clone the client for concurrent use
let client2 = client.clone();
let (hash1, hash2) = tokio::join!(
client.get_best_block_hash(),
client2.get_best_block_hash(),
);
Ok(())
}Implementations§
Trait Implementations§
Source§impl Clone for SvNodeClient
impl Clone for SvNodeClient
Source§fn clone(&self) -> SvNodeClient
fn clone(&self) -> SvNodeClient
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl NodeClient for SvNodeClient
impl NodeClient for SvNodeClient
Source§fn get_best_block_hash<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<BlockHash>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_best_block_hash<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<BlockHash>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns the hash of the best (tip) block in the longest blockchain.
Source§fn get_block_header<'life0, 'life1, 'async_trait>(
&'life0 self,
block_hash: &'life1 BlockHash,
) -> Pin<Box<dyn Future<Output = Result<BlockHeader>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_block_header<'life0, 'life1, 'async_trait>(
&'life0 self,
block_hash: &'life1 BlockHash,
) -> Pin<Box<dyn Future<Output = Result<BlockHeader>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Returns the block header for the specified block hash. Read more
Source§fn get_block<'life0, 'life1, 'async_trait>(
&'life0 self,
block_hash: &'life1 BlockHash,
) -> Pin<Box<dyn Future<Output = Result<Block>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_block<'life0, 'life1, 'async_trait>(
&'life0 self,
block_hash: &'life1 BlockHash,
) -> Pin<Box<dyn Future<Output = Result<Block>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Returns the complete block data for the specified block hash. Read more
Auto Trait Implementations§
impl Freeze for SvNodeClient
impl !RefUnwindSafe for SvNodeClient
impl Send for SvNodeClient
impl Sync for SvNodeClient
impl Unpin for SvNodeClient
impl !UnwindSafe for SvNodeClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more