Browse Source

fix(fsm): ensure lnd connect before state change

Ensure that a failed lnd connection attempt prevents the FSM from
changing state by moving the connect handlers to the
`onBefore<TRANSITION>` lifecycle events.

See https://github.com/jakesgordon/javascript-state-machine/blob/master/docs/lifecycle-events.md#cancelling-a-transition

Fix #739
renovate/lint-staged-8.x
Tom Kirkpatrick 6 years ago
parent
commit
bfb8b6d86e
No known key found for this signature in database GPG Key ID: 72203A8EC5967EA8
  1. 11
      app/lib/zap/controller.js

11
app/lib/zap/controller.js

@ -147,8 +147,8 @@ class ZapController {
this.sendMessage('startOnboarding', this.lndConfig)
}
onStartLnd() {
mainLog.debug('[FSM] onStartLnd...')
onBeforeStartLnd() {
mainLog.debug('[FSM] onBeforeStartLnd...')
return isLndRunning().then(res => {
if (res) {
@ -168,8 +168,8 @@ class ZapController {
})
}
onConnectLnd() {
mainLog.debug('[FSM] onConnectLnd...')
onBeforeConnectLnd() {
mainLog.debug('[FSM] onBeforeConnectLnd...')
mainLog.info('Connecting to custom lnd instance')
mainLog.info(' > host:', this.lndConfig.host)
mainLog.info(' > cert:', this.lndConfig.cert)
@ -197,7 +197,8 @@ class ZapController {
}
// Notify the app of errors.
return this.sendMessage('startLndError', errors)
this.sendMessage('startLndError', errors)
throw e
})
}

Loading…
Cancel
Save