xaya / libxayagame

MIT License
21 stars 19 forks source link

Decouple core channel code from RPC connections #115

Closed domob1812 closed 2 years ago

domob1812 commented 2 years ago

This is a first step in decoupling / simplifying the code game-channels code. In particular, this code was very deeply depending on an RPC connection to Xaya Core to handle signing/verification of moves, and triggering of on-chain moves for disputes and resolutions. This set of changes introduces abstract interfaces for these tasks, and replaces the direct use of RPC connections with those interfaces in many places. The production-implementation of the interfaces is still based on the same RPC calls as before. But with this structure, it will be possible to e.g. introduce direct signing/verification code instead (perhaps for Ethereum-based blockchains).

With this, the unit tests can be simplified, as they can directly mock / implement the interfaces without having to go through a real JSON-RPC server. It will also make it easier to use the game-channel code e.g. for games on Polygon, and do things like run the channel daemon in a browser with wasm.