Struct ethcontract::contract::AllEventsBuilder
source · [−]pub struct AllEventsBuilder<T: Transport, E: ParseLog> {
pub filter: LogFilterBuilder<T>,
pub deployment_information: Option<DeploymentInformation>,
/* private fields */
}Expand description
A builder for creating a filtered stream for any contract event.
Fields
filter: LogFilterBuilder<T>The underlying log filter for these contract events.
deployment_information: Option<DeploymentInformation>The contract deployment transaction hash. Specifying this can increase the performance of the paginated events query.
Note that if the contract was created from an existing deployment that includes the transaction hash, then this property will be automatically set.
Implementations
sourceimpl<T: Transport, E: ParseLog> AllEventsBuilder<T, E>
impl<T: Transport, E: ParseLog> AllEventsBuilder<T, E>
sourcepub fn new(
web3: Web3<T>,
address: Address,
deployment_information: Option<DeploymentInformation>
) -> Self
pub fn new(
web3: Web3<T>,
address: Address,
deployment_information: Option<DeploymentInformation>
) -> Self
Creates a new all events builder from a web3 provider and and address.
sourcepub fn from_block(self, block: BlockNumber) -> Self
pub fn from_block(self, block: BlockNumber) -> Self
Sets the starting block from which to stream logs for.
If left unset defaults to the latest block.
sourcepub fn to_block(self, block: BlockNumber) -> Self
pub fn to_block(self, block: BlockNumber) -> Self
Sets the last block from which to stream logs for.
If left unset defaults to the streaming until the end of days.
sourcepub fn block_hash(self, hash: H256) -> Self
pub fn block_hash(self, hash: H256) -> Self
Sets block_hash. The field block_hash and the pair from_block and
to_block are mutually exclusive.
sourcepub fn topic0(self, topic: Topic<H256>) -> Self
pub fn topic0(self, topic: Topic<H256>) -> Self
Adds a filter for the first indexed topic.
For regular events, this corresponds to the event signature. For anonymous events, this is the first indexed property.
sourcepub fn limit(self, value: usize) -> Self
pub fn limit(self, value: usize) -> Self
Limit the number of events that can be retrieved by this filter.
Note that this parameter is non-standard.
sourcepub fn block_page_size(self, value: u64) -> Self
pub fn block_page_size(self, value: u64) -> Self
The page size in blocks to use when doing a paginated query on past events.
sourcepub fn poll_interval(self, value: Duration) -> Self
pub fn poll_interval(self, value: Duration) -> Self
The polling interval. This is used as the interval between consecutive
eth_getLogs calls to get log updates.
sourcepub async fn query(self) -> Result<Vec<Event<E>>, ExecutionError>
pub async fn query(self) -> Result<Vec<Event<E>>, ExecutionError>
Returns a future that resolves into a collection of events matching the event builder’s parameters.
sourcepub async fn query_paginated(
self
) -> Result<impl Stream<Item = Result<Event<E>, ExecutionError>>, ExecutionError>
pub async fn query_paginated(
self
) -> Result<impl Stream<Item = Result<Event<E>, ExecutionError>>, ExecutionError>
Returns a future that resolves into a collection of events matching the
event builder’s parameters. This method is similar to query with the
notable difference that the logs are fetched in pages by querying
smaller block ranges specified by block_page_size instead of using a
single query.
Note that if the block range is inconsistent (for example from block is after the to block, or querying until the earliest block), then the query will be forwarded to the node as is.
sourcepub fn stream(
self
) -> impl Stream<Item = Result<StreamEvent<E>, ExecutionError>>
pub fn stream(
self
) -> impl Stream<Item = Result<StreamEvent<E>, ExecutionError>>
Creates an event stream from the current event builder.