pub trait ClientContext: Send + Sync {
type Environment: Environment;
// Required methods
fn wallet(&self) -> &<Self::Environment as Environment>::Wallet;
fn storage(&self) -> &<Self::Environment as Environment>::Storage;
fn client(&self) -> &Arc<Client<Self::Environment>>;
fn timing_sender(&self) -> Option<UnboundedSender<(u64, TimingType)>>;
fn update_wallet_for_new_chain(
&mut self,
chain_id: ChainId,
owner: Option<AccountOwner>,
timestamp: Timestamp,
epoch: Epoch,
) -> impl Future<Output = Result<(), Error>> + Send + Sync;
fn update_wallet(
&mut self,
client: &ChainClient<<Self as ClientContext>::Environment>,
) -> impl Future<Output = Result<(), Error>> + Send + Sync;
// Provided methods
fn admin_chain_id(&self) -> ChainId { ... }
fn make_chain_client(
&self,
chain_id: ChainId,
) -> impl Future<Output = Result<ChainClient<Self::Environment>, Error>> + Send + Sync { ... }
}Expand description
The context in which a chain listener operates, providing access to the wallet, storage and client.
Required Associated Types§
Sourcetype Environment: Environment
type Environment: Environment
The execution environment used by the client.
Required Methods§
Sourcefn wallet(&self) -> &<Self::Environment as Environment>::Wallet
fn wallet(&self) -> &<Self::Environment as Environment>::Wallet
Returns a reference to the wallet.
Sourcefn storage(&self) -> &<Self::Environment as Environment>::Storage
fn storage(&self) -> &<Self::Environment as Environment>::Storage
Returns a reference to the storage.
Sourcefn client(&self) -> &Arc<Client<Self::Environment>>
fn client(&self) -> &Arc<Client<Self::Environment>>
Returns a reference to the client.
Sourcefn timing_sender(&self) -> Option<UnboundedSender<(u64, TimingType)>>
fn timing_sender(&self) -> Option<UnboundedSender<(u64, TimingType)>>
Gets the timing sender for benchmarking, if available.
Sourcefn update_wallet_for_new_chain(
&mut self,
chain_id: ChainId,
owner: Option<AccountOwner>,
timestamp: Timestamp,
epoch: Epoch,
) -> impl Future<Output = Result<(), Error>> + Send + Sync
fn update_wallet_for_new_chain( &mut self, chain_id: ChainId, owner: Option<AccountOwner>, timestamp: Timestamp, epoch: Epoch, ) -> impl Future<Output = Result<(), Error>> + Send + Sync
Adds a newly created chain to the wallet.
Sourcefn update_wallet(
&mut self,
client: &ChainClient<<Self as ClientContext>::Environment>,
) -> impl Future<Output = Result<(), Error>> + Send + Sync
fn update_wallet( &mut self, client: &ChainClient<<Self as ClientContext>::Environment>, ) -> impl Future<Output = Result<(), Error>> + Send + Sync
Updates the wallet with the latest state of the given chain client.
Provided Methods§
Sourcefn admin_chain_id(&self) -> ChainId
fn admin_chain_id(&self) -> ChainId
Returns the ID of the admin chain.
Sourcefn make_chain_client(
&self,
chain_id: ChainId,
) -> impl Future<Output = Result<ChainClient<Self::Environment>, Error>> + Send + Sync
fn make_chain_client( &self, chain_id: ChainId, ) -> impl Future<Output = Result<ChainClient<Self::Environment>, Error>> + Send + Sync
Creates a chain client for the chain with the given ID, using the wallet’s state.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.