Skip to content

Instantly share code, notes, and snippets.

@andrewgordstewart
Created June 15, 2020 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewgordstewart/f94898d6d9f023ea313d50a3e0f660d4 to your computer and use it in GitHub Desktop.
Save andrewgordstewart/f94898d6d9f023ea313d50a3e0f660d4 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const wireMachine = Machine({
initial: 'setup',
invoke: {src: 'watcher'},
states: {
setup: {invoke: {src: 'createPaymentChannel', onDone: 'uploading'}, exit: 'sendSpacerState'},
uploading: {
initial: 'unblocked',
on: {DONE: 'refunding'},
states: {
unblocked: {
entry: 'popFromBlockedRequests',
on: {
REQUEST: [
{target: 'blocked', cond: 'insufficientFunds'},
{target: 'unblocked', actions: 'upload'}
]
}
},
blocked: {
entry: 'blockPeer',
on: {PAYMENT: {target: 'unblocked', cond: 'sufficientFunds'}}
}
}
},
refunding: {invoke: {src: 'refund', onDone: 'closing'}},
closing: {invoke: {src: 'closeChannel', onDone: 'done'}},
done: {type: 'final'}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment