-
Notifications
You must be signed in to change notification settings - Fork 177
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
Port over async RPC calls from Huntercoin, implement "waitforblock" RPC call. #60
Conversation
Add a dummy 'game_waitforblock' method that only sleeps for now, and encapsulate the RPC server's client streams into a new class that can be used in the future to persist the streams in new threads for asynchronous RPC calls. Conflicts: src/bitcoinrpc.h src/namecoin.cpp
Implement async RPC method calls that spawn a new thread waiting to finish them. Conflicts: src/namecoin.cpp
Move the check for RPC server shutdown above accept call, so that it does execute when stop() was called.
Add a new "waitforblock" async RPC call, that currently just sleeps for some time instead of doing actual things.
Implement the body of the waitforblock RPC call, but the condition variable introduced is not yet notified when new blocks actually arrive.
When a new block has finished processing, notify all threads waiting on the condition variable about it so that waitforblock now fully works.
Will this make RPC calls faster? |
Not per se. But, if we switch all RPC calls over to being async, it will make calls no longer wait on an earlier one. In the case that some call takes a long time and another one, which executes quickly, is issued afterwards, with async calls, at least the second call will return immediately without waiting for the long one. Furthermore, the particular "waitforblock" command can be used instead of regularly executing RPC calls for things like the block explorer or other "front ends". This will reduce the load on the RPC server, which could also help with performance. |
I am worried this might have implications for pools and other systems relying on the order of calls... |
@phelixbtc my understanding is that if you care about the order of the calls, you can just wait for one RPC call to return before you make the next one. Unless I'm misunderstanding your concern? |
@JeremyRand Correct, I just hope they do that now and don't run into problems. I guess we can risk it. |
ACK |
Port over async RPC calls from Huntercoin, implement "waitforblock" RPC call.
Port over the possibility to execute RPC calls asynchronously that has been integrated in Huntercoin for some time now. Use it to implement a new "waitforblock" call that blocks and only returns when a new block is found - this can be used to update block explorers or other front-ends in near real-time when things change, without needing to repeatedly poll the RPC interface for changes.