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

Add a log and block filter dispatcher. #6

Open
MicahZoltu opened this issue Apr 5, 2017 · 0 comments
Open

Add a log and block filter dispatcher. #6

MicahZoltu opened this issue Apr 5, 2017 · 0 comments

Comments

@MicahZoltu
Copy link
Collaborator

Users of the library may want to be notified when a block or log that matches certain criteria arrives. At the moment, they have to subscribe to the firehose (that they have added filters for) and then filter off of that. It would be nice if the user could do something like:

function evenBlocks(block) { return parseInt(block.number, 16) % 2; }
const subscriptionToken = blockAndLogStreamer.subscribeByFilter(evenBlocks, onEvenBlock);
blockAndLogStreamer.

The library would deal with dynamic dispatch for the user, giving them a simple interface for supplying filter functions and callbacks without them having to build a dispatch system themselves. This solution wouldn't couple blockstream to any particular filtering strategy which is nice because it keeps blockstream library fairly agnostic to dApp's usage of log/block data.

Another potential option would be to support one-shot filters. These would be filters that will fire a callback once the filter function passes and then un-install themselves. This would allow users to subscribe to log/block events that they believe are coming. Potentially, adding a timeout (number of blocks filter will live for) would further simplify user experience by allowing them to hookup one-shot filters for logs they think will come in eventually, without the user having to deal with eventually giving up.

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

No branches or pull requests

1 participant