Struct ethcontract::log::LogFilterBuilder
source · pub struct LogFilterBuilder<T: Transport> {
pub from_block: Option<BlockNumber>,
pub to_block: Option<BlockNumber>,
pub block_hash: Option<H256>,
pub address: Vec<Address>,
pub topics: TopicFilter,
pub limit: Option<usize>,
pub block_page_size: Option<NonZeroU64>,
pub poll_interval: Option<Duration>,
/* private fields */
}Expand description
A log filter builder for configuring either a query for past logs or a stream that constantly queries new logs and deals with re-orgs.
Fields§
§from_block: Option<BlockNumber>The block to start streaming logs from.
See web3::types::BlockNumber for more details on possible values.
to_block: Option<BlockNumber>The block to stop streaming logs from.
See web3::types::BlockNumber for more details on possible values.
block_hash: Option<H256>Block hash, mutually exclusive with pair from_block / to_block.
address: Vec<Address>The contract addresses to filter logs for.
topics: TopicFilterTopic filters used for filtering logs based on indexed topics.
limit: Option<usize>Limit the number of events that can be retrieved by this filter.
Note that this is option is non-standard.
block_page_size: Option<NonZeroU64>The page size in blocks to use when doing a paginated query on past logs. This provides no guarantee in how many logs will be returned per page, but used to limit the block range for the query.
poll_interval: Option<Duration>The polling interval for querying the node for more logs.
Implementations§
source§impl<T: Transport> LogFilterBuilder<T>
impl<T: Transport> LogFilterBuilder<T>
sourcepub fn new(web3: Web3<T>) -> Self
pub fn new(web3: Web3<T>) -> Self
Creates a new log filter builder from the specified web3 provider.
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 address(self, address: Vec<Address>) -> Self
pub fn address(self, address: Vec<Address>) -> Self
Adds an address filter to only retrieve logs that were emitted by a contract matching the povided addresses.
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.
§Panics
Panics if a block page size of 0 is specified.
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 fn into_filter(self) -> FilterBuilder
pub fn into_filter(self) -> FilterBuilder
Returns a web3 filter builder needed for querying and streaming logs.
sourcepub async fn past_logs(self) -> Result<Vec<Log>, ExecutionError>
pub async fn past_logs(self) -> Result<Vec<Log>, ExecutionError>
Performs a eth_getLogs query to past logs. For large block ranges,
such as retrieving all contract logs since genesis, it is recommended to
use the past_logs_pages method instead.
sourcepub fn past_logs_pages(
self
) -> impl Stream<Item = Result<Vec<Log>, ExecutionError>>
pub fn past_logs_pages( self ) -> impl Stream<Item = Result<Vec<Log>, ExecutionError>>
Returns a stream that resolves into a page of logs matching the filter builder’s parameters.