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 JsonRpcClient types

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

A JSON-RPC Error

Sends a request with the provided JSON-RPC and parameters serialized as JSON

The type of stream this transport returns

Add a subscription to this transport

Remove a subscription from this transport

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

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

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

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

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

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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