pub struct RpcClient { /* private fields */ }Expand description
Minimal JSON-RPC transport.
Implementations§
Source§impl RpcClient
impl RpcClient
Sourcepub fn new(url: impl Into<String>, timeout: Duration) -> Result<Self, Error>
pub fn new(url: impl Into<String>, timeout: Duration) -> Result<Self, Error>
Build a client posting to url.
Sourcepub fn with_http(url: impl Into<String>, http: Client) -> Self
pub fn with_http(url: impl Into<String>, http: Client) -> Self
Build a client from an already-configured reqwest::Client.
This is the way to reach a node that authenticates by header, or to share
a connection pool: set default_headers on the reqwest::Client and pass
it in.
Sourcepub fn block(self, block: impl Into<String>) -> Self
pub fn block(self, block: impl Into<String>) -> Self
Evaluate every RpcClient::call against this block instead of
"latest" — a decimal or 0x-prefixed height, or a tag the node knows.
Pinning a block is what makes two quotes comparable: "latest" moves
under you between calls, so a buy priced at one height and a sell priced
at the next are not describing the same curve.
Sourcepub fn block_tag(&self) -> &str
pub fn block_tag(&self) -> &str
The block tag RpcClient::call uses.
Sourcepub async fn request(&self, method: &str, params: Value) -> Result<Value, Error>
pub async fn request(&self, method: &str, params: Value) -> Result<Value, Error>
Invoke a JSON-RPC method and return its result.
Sourcepub async fn call(
&self,
to: &str,
data: &str,
from: Option<&str>,
) -> Result<CallOutcome, Error>
pub async fn call( &self, to: &str, data: &str, from: Option<&str>, ) -> Result<CallOutcome, Error>
Run eth_call, separating a revert from a transport failure.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RpcClient
impl !RefUnwindSafe for RpcClient
impl !UnwindSafe for RpcClient
impl Send for RpcClient
impl Sync for RpcClient
impl Unpin for RpcClient
impl UnsafeUnpin for RpcClient
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