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

General code for tracking pending moves in a GSP #79

Merged
merged 8 commits into from
Aug 7, 2019

Conversation

domob1812
Copy link
Collaborator

This set of changes adds core support for tracking pending moves in a GSP (as described in #43). It defines an abstract class PendingMoveProcessor, which games can subclass if they want to do game-specific processing of a "pending state". If this feature is enabled, then libxayagame will listen to the zmqgamepending notifications sent from Xaya Core and keep the pending state updated as well as is possible.

Note that with these changes in, there are still some things to do that will come later: Support in mover and integration tests with it, a waitforchange equivalent for the pending state, and support for SQLiteGame with integration in Xayaships.

Allow the ZmqSubscriber to have more than one socket, and read from them
in a multiplexed fashion using zmq::poll.  For now, we still have at most
one socket open, but that will change when we support also receiving
notifications about pending moves.
This extends the ZmqSubscriber class so that it can listen to pending
move notifications in addition to block attach/detach ones.  This works
both if the notifications are on a separate address or on the same as
block messages.
Expose the getrawmempool method of Xaya Core in the RPC stub.  This method
will be useful for the handling of pending moves (because we can use it to
compare our list of pending moves to the real mempool and make sure we
expunge spurious entries from time to time).
This creates the new class GameProcessorWithContext, which holds the
game ID, chain and Xaya Core RPC connection.  That way, we can reuse that
code for the upcoming processor of pending moves.
This adds the new class PendingMoveProcessor, which allows subclasses to
receive updates about pending moves and build a "pending state".  It has
logic to track currently known pending moves, sync them with Xaya Core's
mempool using getrawmempool, and to construct the "correct" pending
state when blocks or new transactions come in.
This adds support for tracking pending moves to the Game class.  It will
auto-detect the ZMQ endpoint for pending moves alongside of the one for
block notifications.  Also, one can (optionally) attach a
PendingMoveProcessor instance, which will then be kept up-to-date with
incoming moves and block attaches/detaches.
Allow the default main functions to install a PendingMoveProcessor.
To do so, the instance must be created and managed outside of the
default main, and passed to it in the GameDaemonConfiguration struct.
This adds the new method Game::GetPendingJsonState, which exposes
the pending state (if it is tracked) as JSON from the Game instance.
It is also exposed by the default GameRpcServer with the new method
"getpendingstate".
@domob1812 domob1812 merged commit a133336 into master Aug 7, 2019
domob1812 added a commit that referenced this pull request Aug 7, 2019
General code for tracking pending moves in a GSP
@domob1812 domob1812 deleted the pending-processing branch August 7, 2019 11:04
@domob1812 domob1812 added this to the 0.1 milestone Aug 7, 2019
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.

1 participant