use ethers::{prelude::*, utils::Ganache};
use std::{str::FromStr, time::Duration};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let ganache = Ganache::new().spawn();
let quorum = QuorumProvider::dyn_rpc()
.add_provider(WeightedProvider::new(Box::new(Http::from_str(&ganache.endpoint())?)))
.add_provider(WeightedProvider::with_weight(
Box::new(Ws::connect(ganache.ws_endpoint()).await?),
2,
))
.add_provider(WeightedProvider::with_weight(
Box::new(Ws::connect(ganache.ws_endpoint()).await?),
2,
))
.quorum(Quorum::Majority)
.build();
let provider = Provider::quorum(quorum).interval(Duration::from_millis(10u64));
dbg!(provider.get_accounts().await?);
Ok(())
}