Struct ethers_providers::QuorumProvider [−][src]
pub struct QuorumProvider<T> { /* fields omitted */ }
Expand description
A provider that bundles multiple providers and only returns a value to the caller once the quorum has been reached.
Example
Create a QuorumProvider
that only returns a value if the Quorum::Majority
of
the weighted providers return the same value.
use ethers_core::types::U64;
use ethers_providers::{JsonRpcClient, QuorumProvider, Quorum, WeightedProvider, Http};
use std::str::FromStr;
let provider1 = WeightedProvider::new(Http::from_str("http://localhost:8545")?);
let provider2 = WeightedProvider::with_weight(Http::from_str("http://localhost:8545")?, 2);
let provider3 = WeightedProvider::new(Http::from_str("http://localhost:8545")?);
let provider = QuorumProvider::builder()
.add_providers([provider1, provider2, provider3])
.quorum(Quorum::Majority)
.build();
// the weight at which a quorum is reached,
assert_eq!(provider.quorum_weight(), 4 / 2); // majority >=50%
let block_number: U64 = provider.request("eth_blockNumber", ()).await?;
Implementations
Create a QuorumProvider
for different PubsubClient
types
Convenience method for creating a QuorumProviderBuilder
with same JsonRpcClient
types
The weight at which the provider reached a quorum
Trait Implementations
type Error = ProviderError
type Error = ProviderError
A JSON-RPC Error
fn request<'life0, 'life1, 'async_trait, T: Serialize + Send + Sync, R: DeserializeOwned>(
&'life0 self,
method: &'life1 str,
params: T
) -> Pin<Box<dyn Future<Output = Result<R, Self::Error>> + Send + 'async_trait>> where
T: 'async_trait,
R: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn request<'life0, 'life1, 'async_trait, T: Serialize + Send + Sync, R: DeserializeOwned>(
&'life0 self,
method: &'life1 str,
params: T
) -> Pin<Box<dyn Future<Output = Result<R, Self::Error>> + Send + 'async_trait>> where
T: 'async_trait,
R: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Sends a request with the provided JSON-RPC and parameters serialized as JSON
type NotificationStream = QuorumStream
type NotificationStream = QuorumStream
The type of stream this transport returns
Add a subscription to this transport
Auto Trait Implementations
impl<T> RefUnwindSafe for QuorumProvider<T> where
T: RefUnwindSafe,
impl<T> Send for QuorumProvider<T> where
T: Send,
impl<T> Sync for QuorumProvider<T> where
T: Sync,
impl<T> Unpin for QuorumProvider<T> where
T: Unpin,
impl<T> UnwindSafe for QuorumProvider<T> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more