Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contract Subscriber Tries to Process Same Block #41

Open
lightclient opened this issue May 20, 2018 · 1 comment
Open

Contract Subscriber Tries to Process Same Block #41

lightclient opened this issue May 20, 2018 · 1 comment

Comments

@lightclient
Copy link
Contributor

If no new events occur between iterations of the contract subscriber loop, it will process the same block over and over again.

let fromBlock = await getAsync('currentBlock') || 0;
let events = await StandardBounties.getPastEvents({fromBlock, toBlock: 'latest'});
let eventBlock = await sendEvents(events);
if (eventBlock) {
await writeAsync('currentBlock', eventBlock);
}

I think that eventBlock should be incremented by 1 before updating the currentBlock in the Redis cache. This is a minor issue since messageDeduplicationId should stop it from actually getting processed, however it seems like it puts unnecessary strain on the cache.

@villanuevawill
Copy link
Collaborator

@c-o-l-o-r thanks for this, def a good optimization. My initial concern was there would be multiple transactions within a block - so could intro some failure states... but this shouldn't be an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants