Skip to content
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

Merged
merged 11 commits into from
May 15, 2014

Conversation

domob1812
Copy link
Contributor

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.

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.
@phelixbtc
Copy link
Contributor

Will this make RPC calls faster?

@domob1812
Copy link
Contributor Author

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.

@phelixbtc
Copy link
Contributor

I am worried this might have implications for pools and other systems relying on the order of calls...

@JeremyRand
Copy link
Member

@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?

@phelixbtc
Copy link
Contributor

@JeremyRand Correct, I just hope they do that now and don't run into problems. I guess we can risk it.

@phelixbtc
Copy link
Contributor

ACK

phelixbtc added a commit that referenced this pull request May 15, 2014
Port over async RPC calls from Huntercoin, implement "waitforblock" RPC call.
@phelixbtc phelixbtc merged commit 1bb337b into namecoin:namecoinq May 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants