pub struct MultiChainReader {
pub providers: HashMap<ChainId, Arc<dyn ChainProvider>>,
}Expand description
Executes storage reads and contract calls across many chains in parallel.
§Example
use std::sync::Arc;
use std::collections::HashMap;
use xenith_core::ChainId;
use xenith_read::MultiChainReader;
let reader = MultiChainReader::new(HashMap::new());
let results = reader.read_parallel(vec![ChainId::from(1)], [0u8; 20], [0u8; 32]).await;Fields§
§providers: HashMap<ChainId, Arc<dyn ChainProvider>>Implementations§
Source§impl MultiChainReader
impl MultiChainReader
pub fn new(providers: HashMap<ChainId, Arc<dyn ChainProvider>>) -> Self
Sourcepub async fn read_parallel(
&self,
chains: Vec<ChainId>,
address: [u8; 20],
slot: [u8; 32],
) -> Result<Vec<(ChainId, [u8; 32])>>
pub async fn read_parallel( &self, chains: Vec<ChainId>, address: [u8; 20], slot: [u8; 32], ) -> Result<Vec<(ChainId, [u8; 32])>>
Read slot from address on every chain in chains, concurrently.
Tasks are spawned for all chains simultaneously. Failures are logged as
warnings and omitted from the returned Vec; only successful readings are
included. The outer Result only fails if something prevents spawning
(which in practice never happens with tokio).
Sourcepub async fn call_parallel(
&self,
chains: Vec<ChainId>,
address: [u8; 20],
calldata: Bytes,
) -> Result<Vec<(ChainId, Bytes)>>
pub async fn call_parallel( &self, chains: Vec<ChainId>, address: [u8; 20], calldata: Bytes, ) -> Result<Vec<(ChainId, Bytes)>>
Call address with calldata on every chain in chains, concurrently.
Same failure-tolerance semantics as read_parallel.
Sourcepub async fn check_divergence(
&self,
chains: Vec<ChainId>,
address: [u8; 20],
slot: [u8; 32],
) -> Result<DivergenceReport>
pub async fn check_divergence( &self, chains: Vec<ChainId>, address: [u8; 20], slot: [u8; 32], ) -> Result<DivergenceReport>
Read slot across chains and report whether their values agree.
Auto Trait Implementations§
impl Freeze for MultiChainReader
impl !RefUnwindSafe for MultiChainReader
impl Send for MultiChainReader
impl Sync for MultiChainReader
impl Unpin for MultiChainReader
impl UnsafeUnpin for MultiChainReader
impl !UnwindSafe for MultiChainReader
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more