Merge pull request #2 from zero-gravity-labs/filter_address

Filter address in log sync.
This commit is contained in:
peilun-conflux 2024-01-19 19:45:27 +08:00 committed by GitHub
commit 877f484dd0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View File

@ -71,6 +71,7 @@ impl LogEntryFetcher {
.submit_filter()
.from_block(progress)
.to_block(end_block_number)
.address(contract.address().into())
.filter;
let mut stream = LogQuery::new(&provider, &filter, log_query_delay)
.with_page_size(log_page_size);
@ -116,7 +117,7 @@ impl LogEntryFetcher {
}
Err(e) => {
error!("log query error: e={:?}", e);
filter = filter.from_block(progress);
filter = filter.from_block(progress).address(contract.address());
stream = LogQuery::new(&provider, &filter, log_query_delay)
.with_page_size(log_page_size);
tokio::time::sleep(Duration::from_millis(RETRY_WAIT_MS)).await;
@ -143,6 +144,7 @@ impl LogEntryFetcher {
let mut filter = contract
.submit_filter()
.from_block(start_block_number)
.address(contract.address().into())
.filter;
debug!("start_watch starts, start={}", start_block_number);
let mut filter_id =
@ -160,7 +162,7 @@ impl LogEntryFetcher {
{
Err(e) => {
error!("log sync watch error: e={:?}", e);
filter = filter.from_block(progress);
filter = filter.from_block(progress).address(contract.address());
filter_id = repeat_run_and_log(|| {
provider.new_filter(FilterKind::Logs(&filter))
})

@ -1 +1 @@
Subproject commit b9263529250ff1e3dde863215c1eb81e58973ff7
Subproject commit 5d32ed0df9bd0c6e95ffe4d11e06ceed233a23af