ethereumjs / ethereumjs-blockstream

Reliable stream of Ethereum blocks
MIT License
80 stars 19 forks source link

Fetch last known good block number +1, instead of latest block. #28

Open MicahZoltu opened 5 years ago

MicahZoltu commented 5 years ago

When polling for new blocks, don't poll for latest but instead poll for last known good block number + 1. This will result in 1-block reorgs not being noticed, but that could be beneficial when speaking with load balanced nodes, and shouldn't ever happen normally. It will also make it so if we start many blocks back from head, we don't hit the backfill logic, and instead just fill from that block forward. This allows us to resume a stream that has been paused for thousands of blocks and while catching up won't be fast (due to the number of round trips) it will happen eventually and the service will be live while it is doing so.

We may also be able to delete some code with this change, would be good to review some of the edge cases and evaluate if we still need to handle them.