xaya / libxayagame

MIT License
21 stars 20 forks source link

Add height to game-state RPCs #30

Closed domob1812 closed 5 years ago

domob1812 commented 5 years ago

RPCs that return the game state (like the default getcurrentstate and GetCustomStateData) include the block hash to which the state corresponds. This identifies the block uniquely - but it would be nice to have also the block height there. (It can be retrieved by frontends through getblockheader with the block hash, but that is an additional RPC that is unnecessary.)

For this, we need to extend the storage to include the block height also with the current game state. A simpler implementation could just call getblockheader from the game daemon.

domob1812 commented 5 years ago

Note that adding this data to the persistent storage is actually mostly redundant. Instead, we could just keep the current height in memory, and update it when attaching/detaching blocks. Whenever needed (i.e. after starting the game daemon), we could just call getblockheader on Xaya Core to initialise the value.

That way, we do not need to complicate the storage unnecessarily, but we also avoid most of the unnecessary RPCs.

domob1812 commented 5 years ago

Fixed with #32.