MetaMask / eth-block-tracker

A JS module for keeping track of the latest Ethereum block by polling an ethereum provider
MIT License
132 stars 81 forks source link

Consider using WS provider instead of polling #24

Closed LogvinovLeon closed 6 years ago

LogvinovLeon commented 7 years ago

Both Geth and Parity support eth_subscribe method https://github.com/ethereum/go-ethereum/wiki/RPC-PUB-SUB https://github.com/paritytech/parity/wiki/JSONRPC-Eth-Pub-Sub-Module

It can come in handy for this module and eliminate the need to do polling

danfinlay commented 7 years ago

Since we use this in MetaMask, the data source for the block-tracker needs to support these methods before it can. That means:

https://github.com/MetaMask/provider-engine/issues/189 or, now that MetaMask is moving off provider-engine: https://github.com/kumavis/eth-json-rpc-filters/issues/3

benjamincburns commented 6 years ago

PR inbound for this. Without this my subscriptions tests in ganache are hella slow.

benjamincburns commented 6 years ago

Merge was accidental. I suspect @kumavis will revert it and reopen this issue.

However I just noticed @danfinlay's comment above.

The PR I submitted is backward compatible with old providers, so it isn't blocked in the way that you mention. However it is untested, as I realized after submitting that it won't work for Ganache because in that case the call is coming from inside the house (get out of there!).

If someone else wants to pick it up and get it over the finish line, I'm happy to answer any questions they might have.