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

Block iterator #742

Merged
merged 2 commits into from
Sep 7, 2020
Merged

Block iterator #742

merged 2 commits into from
Sep 7, 2020

Conversation

iamdefinitelyahuman
Copy link
Member

What I did

Add a block iterator to allow simple loops looking at the latest block.

How I did it

chain.new_blocks() returns an iterator that polls eth_getBlock and yields new blocks as they arrive. You can set a buffer to get latest-n blocks and avoid chain reorgs, and a polling interval to avoid over-frequent requests.

This is a naive implementation and should be replaced with eth_subscribe at some point in the future.

@iamdefinitelyahuman iamdefinitelyahuman merged commit e6b6183 into master Sep 7, 2020
@iamdefinitelyahuman iamdefinitelyahuman deleted the feat-block-iter branch September 7, 2020 19:40
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

Successfully merging this pull request may close these issues.

1 participant