LogFilterBuilder

Struct 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: TopicFilter

Topic 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>

Source

pub fn new(web3: Web3<T>) -> Self

Creates a new log filter builder from the specified web3 provider.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn topic1(self, topic: Topic<H256>) -> Self

Adds a filter for the second indexed topic.

Source

pub fn topic2(self, topic: Topic<H256>) -> Self

Adds a filter for the third indexed topic.

Source

pub fn topic3(self, topic: Topic<H256>) -> Self

Adds a filter for the third indexed topic.

Source

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.

Source

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.

Source

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.

Source

pub fn into_filter(self) -> FilterBuilder

Returns a web3 filter builder needed for querying and streaming logs.

Source

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.

Source

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.

Source

pub fn stream(self) -> impl Stream<Item = Result<Log, ExecutionError>>

Creates a filter-based log stream that emits logs for each filter change.

Trait Implementations§

Source§

impl<T: Debug + Transport> Debug for LogFilterBuilder<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for LogFilterBuilder<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for LogFilterBuilder<T>
where T: RefUnwindSafe,

§

impl<T> Send for LogFilterBuilder<T>
where T: Send,

§

impl<T> Sync for LogFilterBuilder<T>
where T: Sync,

§

impl<T> Unpin for LogFilterBuilder<T>
where T: Unpin,

§

impl<T> UnwindSafe for LogFilterBuilder<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more