ethereumjs / ethereumjs-blockstream

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

Simplifies usage by encapsulating state into a class. #3

Closed MicahZoltu closed 7 years ago

MicahZoltu commented 7 years ago

There is a new class named BlockAndLogStreamer. To use this library you just need to instantiate this class with the required parameters (a couple callbacks) and then you can feed it blocks and it will reconcile them with its internal state. Optionally, you can subscribe to notifications of block addition, block removal, log addition and log removal. You can also add/remove log filters you would like it to use.

This change should make this library much easier to use as the user no longer needs to worry about correctly managing the object state and dealing with proper coordination of calls to reconcile blocks. You can now call reconcileNewBlock as fast as you want and it will "do the right thing".

This also makes it so any errors thrown by subscription handlers will be logged to console and then swallowed, making this class less susceptible to breaking when an error elsewhere in the codebase occurs.