Fix for networks with polling with non-consistent block and filter events (#4119).
This commit is contained in:
parent
56ed4e7380
commit
9b0e9920c0
@ -239,6 +239,7 @@ export class PollingEventSubscriber implements Subscriber {
|
|||||||
const filter = copy(this.#filter);
|
const filter = copy(this.#filter);
|
||||||
filter.fromBlock = this.#blockNumber + 1;
|
filter.fromBlock = this.#blockNumber + 1;
|
||||||
filter.toBlock = blockNumber;
|
filter.toBlock = blockNumber;
|
||||||
|
|
||||||
const logs = await this.#provider.getLogs(filter);
|
const logs = await this.#provider.getLogs(filter);
|
||||||
|
|
||||||
// No logs could just mean the node has not indexed them yet,
|
// No logs could just mean the node has not indexed them yet,
|
||||||
@ -250,10 +251,13 @@ export class PollingEventSubscriber implements Subscriber {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#blockNumber = blockNumber;
|
|
||||||
|
|
||||||
for (const log of logs) {
|
for (const log of logs) {
|
||||||
this.#provider.emit(this.#filter, log);
|
this.#provider.emit(this.#filter, log);
|
||||||
|
|
||||||
|
// Only advance the block number when logs were found to
|
||||||
|
// account for networks (like BNB and Polygon) which may
|
||||||
|
// sacrifice event consistency for block event speed
|
||||||
|
this.#blockNumber = log.blockNumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user