WatchBlockNumber / WatchBlock #3005
Unanswered
yog4a
asked this question in
Idea / Feature Request
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
There’s an issue with the documentation: the function watchBlockNumber returns an onBlockNumber function with two arguments, the block number and the previous block number.
I noticed that when using watchBlocks, two API calls are made (eth_subscribe + getBlockByNumber), while with watchBlockNumber, only one call is made.
In some use cases, I need not only the block number but also the timestamp and hash (as well as the parentHash). Currently, I have to choose between a function that only returns the block number and another that makes two API calls.
However, in the case of watchBlockNumber, we do have all the block information. I modified the function as follows:
I think it could be a good idea to include this by default, as it allows us to have information on a block instead of discarding this data by only returning the block number.
Beta Was this translation helpful? Give feedback.
All reactions