AdamISZ / CoinSwapCS

Simple implementation of Bitcoin CoinSwap, client-server
GNU General Public License v3.0
31 stars 14 forks source link

Investigate folding tick() and tick_return() together in state machine #13

Closed AdamISZ closed 7 years ago

AdamISZ commented 7 years ago

There are two ways in which the server-side tick_return() differs from the client-side tick() in the StateMachine class; first, the obvious, the server side provides a return value, second, the server side enforces ordering of calls by checking whether the callback requested is the one expected.

It should be possible to fold these two together and would avoid code duplication, which is a bad thing to have in this core part of the logic. There may be other aspects of the way the state machine is coded that should be changed, for example the recursion in case of auto_continue.

AdamISZ commented 7 years ago

Addressed in 657663cc422e1fefe3362939d43b8754a02ae637

Also note that state machine function is now documented here ; state machine is now its own module here and serialization is now enforced (not possible for a tick() call to execute if it's already running).