2

I am writing an application to get notified when a new block is mined using the awesome go language. I installed a filter for that

I connected via IPC to geth, all good and nice but I don't seem to get it working without continuously polling eth_getFilterChanges is any other method to be notified by geth a blocking version of this RPC maybe?

Thanks

3
  • 2
    Possible duplicate of Event on Mining of a new block
    – jeff
    Commented Apr 13, 2017 at 4:40
  • @jeff how is duplicate I am not trying to get notified when a block is mined. Just asking how I can get notified without me calling that rpc function over and over again
    – octav
    Commented Apr 15, 2017 at 7:24
  • The duplicate referenced does not provide a solution for 'go'. If the solution to this question (which is "how do I do this in 'go') is added to the referenced duplicate, then I would vote to close this. Otherwise, I'd like to see the answer. Commented Apr 20, 2017 at 14:13

1 Answer 1

1

Hearing you on this...

You need to make anew block filter and then poll that filter for changes as it looks like you're already doing. Yes, you were trying to avoid polling, but the magic of web3.eth.filter and web3.eth.filter.watch that SEEM to not use a polling approach, under the hood are actually polling eth_getFilterChanges.

:(

So, basically, your would use eth_newBlockFilter + eth_getFilterChanges or use eth_blockNumber since you probably already know what block you left off on.

Agreed that this is an issue with no inherent solution since RPC is inherently query/response based. Yes, I feel like taking a shower too when making code that has to poll.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.