Last active
November 15, 2019 20:17
-
-
Save andrewgordstewart/2a237a1851b1d1e993b0522e79dea0c5 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const config = { | |
key: 'ledger-update', | |
initial: 'vote', | |
states: { | |
vote: { | |
on: { | |
'': [ | |
{ target: 'waiting', cond: 'turnNumberCorrect', actions: 'vote' }, | |
{ target: 'failure', cond: 'turnNumberIncorrect' } | |
] | |
} | |
}, | |
waiting: { | |
on: { | |
'*': [ | |
{ target: 'success', cond: 'consensusReached' }, | |
{ target: 'failure', cond: 'dissent' } | |
] | |
} | |
}, | |
success: { type: 'final' }, | |
failure: { type: 'final' } | |
}, | |
context: { channelID: '0xabc', currentTurnNumber: 7, goal: [] } | |
}; | |
const guards = { | |
consensusReached: context => true, | |
// ensures that the latest supported | |
// state in the store has the correct | |
// turn number | |
turnNumberCorrect: context => true, | |
turnNumberIncorrect: context => false, | |
dissent: context => false | |
}; | |
const customActions = {}; | |
const machine = Machine(config, { guards, actions: customActions }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment