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

  • 2
    Possible duplicate of Event on Mining of a new block – jeff Apr 13 '17 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 Apr 15 '17 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. – Thomas Jay Rush Apr 20 '17 at 14:13
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, privacy policy and cookie policy

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