xaya / libxayagame

MIT License
21 stars 20 forks source link

Pass known block to waitforchange #63

Closed domob1812 closed 5 years ago

domob1812 commented 5 years ago

This adds an argument to waitforchange, where the caller may pass the best known block to them. Then, if the current state already is different from that, waitforchange will return immediately.

By making use of this feature, callers can avoid a potential race condition: If they call waitforchange but then a change happens between the client processing the result and calling waitforchange again, previously the call would block until another change was made. With this feature, clients can make sure they always get notified as soon as possible of any changes.

By passing an empty string for the new argument, callers can revert back to the old behaviour.