Struct HttpClient

Source
pub struct HttpClient { /* private fields */ }
Expand description

A JSON-RPC/HTTP Tendermint RPC client (implements crate::Client).

Supports both HTTP and HTTPS connections to Tendermint RPC endpoints, and allows for the use of HTTP proxies (see HttpClient::new_with_proxy for details).

Does not provide crate::event::Event subscription facilities (see crate::WebSocketClient for a client that does).

§Examples

use tendermint_rpc::{HttpClient, Client};

#[tokio::main]
async fn main() {
    let client = HttpClient::new("http://127.0.0.1:26657")
        .unwrap();

    let abci_info = client.abci_info()
        .await
        .unwrap();

    println!("Got ABCI info: {:?}", abci_info);
}

Implementations§

Source§

impl HttpClient

Source

pub fn new_from_parts(inner: Client, url: Url, compat: CompatMode) -> Self

Construct a new Tendermint RPC HTTP/S client connecting to the given URL. This avoids using the Builder and thus does not perform any validation of the configuration.

Source

pub fn new<U>(url: U) -> Result<Self, Error>
where U: TryInto<HttpClientUrl, Error = Error>,

Construct a new Tendermint RPC HTTP/S client connecting to the given URL.

Source

pub fn new_with_proxy<U, P>(url: U, proxy_url: P) -> Result<Self, Error>
where U: TryInto<HttpClientUrl, Error = Error>, P: TryInto<HttpClientUrl, Error = Error>,

Construct a new Tendermint RPC HTTP/S client connecting to the given URL, but via the specified proxy’s URL.

If the RPC endpoint is secured (HTTPS), the proxy will automatically attempt to connect using the HTTP CONNECT method.

Source

pub fn builder(url: HttpClientUrl) -> Builder

Initiate a builder for a Tendermint RPC HTTP/S client connecting to the given URL, so that more configuration options can be specified with the builder.

Source

pub fn set_compat_mode(&mut self, compat: CompatMode)

Set compatibility mode on the instantiated client.

As the HTTP client is stateless and does not support subscriptions, the protocol version it uses can be changed at will, for example, as a result of version discovery over the /status endpoint.

Trait Implementations§

Source§

impl Client for HttpClient

Source§

fn broadcast_evidence<'life0, 'async_trait>( &'life0 self, evidence: Evidence, ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

/broadcast_evidence: broadcast an evidence.

Source§

fn perform<'life0, 'async_trait, R>( &'life0 self, request: R, ) -> Pin<Box<dyn Future<Output = Result<R::Output, Error>> + Send + 'async_trait>>
where R: SimpleRequest + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Perform a request against the RPC endpoint. Read more
Source§

fn block<'life0, 'async_trait, H>( &'life0 self, height: H, ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
where H: Into<Height> + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

/block: get block at a given height.
Source§

fn block_by_hash<'life0, 'async_trait>( &'life0 self, hash: Hash, ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

/block_by_hash: get block by hash.
Source§

fn latest_block<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

/block: get the latest block.
Source§

fn block_results<'life0, 'async_trait, H>( &'life0 self, height: H, ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
where H: Into<Height> + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

/block_results: get ABCI results for a block at a particular height.
Source§

fn latest_block_results<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

/block_results: get ABCI results for the latest block.
/block_search: search for blocks by BeginBlock and EndBlock events.
Source§

fn header<'life0, 'async_trait, H>( &'life0 self, height: H, ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
where H: Into<Height> + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

/header: get block header at a given height.
Source§

fn header_by_hash<'life0, 'async_trait>( &'life0 self, hash: Hash, ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

/header_by_hash: get block by hash.
Source§

fn tx<'life0, 'async_trait>( &'life0 self, hash: Hash, prove: bool, ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

/tx: find transaction by hash.
/tx_search: search for transactions with their results.
Source§

fn broadcast_tx_commit<'life0, 'async_trait, T>( &'life0 self, tx: T, ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
where T: Into<Vec<u8>> + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

/broadcast_tx_commit: broadcast a transaction, returning the response from DeliverTx.
Source§

fn abci_info<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Info, Error>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

/abci_info: get information about the ABCI application.
Source§

fn abci_query<'life0, 'async_trait, V>( &'life0 self, path: Option<String>, data: V, height: Option<Height>, prove: bool, ) -> Pin<Box<dyn Future<Output = Result<AbciQuery, Error>> + Send + 'async_trait>>
where V: Into<Vec<u8>> + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

/abci_query: query the ABCI application
Source§

fn blockchain<'life0, 'async_trait, H>( &'life0 self, min: H, max: H, ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
where H: Into<Height> + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

/blockchain: get block headers for min <= height <= max. Read more
Source§

fn broadcast_tx_async<'life0, 'async_trait, T>( &'life0 self, tx: T, ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
where T: Into<Vec<u8>> + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

/broadcast_tx_async: broadcast a transaction, returning immediately.
Source§

fn broadcast_tx_sync<'life0, 'async_trait, T>( &'life0 self, tx: T, ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
where T: Into<Vec<u8>> + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

/broadcast_tx_sync: broadcast a transaction, returning the response from CheckTx.
Source§

fn commit<'life0, 'async_trait, H>( &'life0 self, height: H, ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
where H: Into<Height> + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

/commit: get block commit at a given height.
Source§

fn consensus_params<'life0, 'async_trait, H>( &'life0 self, height: H, ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
where H: Into<Height> + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

/consensus_params: get current consensus parameters at the specified height.
Source§

fn consensus_state<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

/consensus_state: get current consensus state
Source§

fn validators<'life0, 'async_trait, H>( &'life0 self, height: H, paging: Paging, ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
where H: Into<Height> + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

/validators: get validators a given height.
Source§

fn latest_consensus_params<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

/consensus_params: get the latest consensus parameters.
Source§

fn latest_commit<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

/commit: get the latest block commit
Source§

fn health<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

/health: get node health. Read more
Source§

fn genesis<'life0, 'async_trait, AppState>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Genesis<AppState>, Error>> + Send + 'async_trait>>
where AppState: Debug + Serialize + DeserializeOwned + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

/genesis: get genesis file.
Source§

fn genesis_chunked<'life0, 'async_trait>( &'life0 self, chunk: u64, ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

Source§

fn genesis_chunked_stream<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Pin<Box<dyn Stream<Item = Result<Vec<u8>, Error>> + '_>>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

/genesis_chunked: get genesis file in multiple chunks.
Source§

fn net_info<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

/net_info: obtain information about P2P and other network connections.
Source§

fn status<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

/status: get Tendermint status including node info, pubkey, latest block hash, app hash, block height and time.
Source§

fn wait_until_healthy<'life0, 'async_trait, T>( &'life0 self, timeout: T, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where T: Into<Duration> + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

Poll the /health endpoint until it returns a successful result or the given timeout has elapsed.
Source§

impl Clone for HttpClient

Source§

fn clone(&self) -> HttpClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HttpClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T