hopr_chain_rpc

Module client

Source
Expand description

Extended JsonRpcClient abstraction.

This module contains custom implementation of ethers::providers::JsonRpcClient which allows usage of non-reqwest based HTTP clients.

The major type implemented in this module is the JsonRpcProviderClient which implements the [ethers::providers::JsonRpcClient] trait. That makes it possible to use it with ethers.

The JsonRpcProviderClient is abstract over the HttpPostRequestor trait, which makes it possible to make the underlying HTTP client implementation easily replaceable. This is needed to make it possible for ethers to work with different async runtimes, since the HTTP client is typically not agnostic to async runtimes (the default HTTP client in ethers is using reqwest, which is tokio specific). Secondly, this abstraction also allows implementing WASM-compatible HTTP client if needed at some point.

Modules§

reqwest_client
surf_client

Structs§

JsonRpcProviderClient
Modified implementation of ethers::providers::Http so that it can operate with any HttpPostRequestor. Also contains possible retry actions to be taken on various failures, therefore it implements also ethers::providers::RetryClient functionality.
RequestorResponseSnapshot
Snapshot of a response cached by the SnapshotRequestor.
SimpleJsonRpcRetryPolicy
Defines a retry policy suitable for JsonRpcProviderClient.
SnapshotRequestor
Replays an RPC response to a request if it is found in the snapshot YAML file. If no such request has been seen before, it captures the new request/response pair obtained from the inner HttpPostRequestor and stores it into the snapshot file.

Functions§

create_rpc_client_to_anvil
Used for testing. Creates Ethers RPC client to the local Anvil instance.