Skip to content

Commit

Permalink
chore: eslint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
krhougs committed Aug 12, 2021
1 parent d681b3a commit d22777e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 26 deletions.
41 changes: 16 additions & 25 deletions src/lifecycle/state_machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@ const wrapEventAction = (fn) => (fromState, toState, context) =>
})

const onStarting = async (fromState, toState, context) => {
const {
pid,
runtime,
innerTxQueue,
} = context.stateMachine.rootStateMachine.workerContext
const { pid, runtime, innerTxQueue } =
context.stateMachine.rootStateMachine.workerContext

const initInfo = await innerTxQueue.add(async () => {
if (shouldSkipRa) {
Expand All @@ -66,18 +63,17 @@ const onStarting = async (fromState, toState, context) => {
throw new Error('Worker is assigned to other pool!')
}

context.stateMachine.rootStateMachine.workerContext.onChainState = await subscribeOnChainState(
context.stateMachine.rootStateMachine.workerContext
)
context.stateMachine.rootStateMachine.workerContext.onChainState =
await subscribeOnChainState(
context.stateMachine.rootStateMachine.workerContext
)

context.stateMachine.handle(EVENTS.SHOULD_MARK_SYNCHING)
}

const onSynching = async (fromState, toState, context) => {
const {
runtime,
workerBrief,
} = context.stateMachine.rootStateMachine.workerContext
const { runtime, workerBrief } =
context.stateMachine.rootStateMachine.workerContext

const waitUntilSynched = await startSyncBlob(runtime)
await waitUntilSynched()
Expand All @@ -88,10 +84,8 @@ const onSynching = async (fromState, toState, context) => {
}

const onSynched = async (fromState, toState, context) => {
const {
runtime,
workerBrief,
} = context.stateMachine.rootStateMachine.workerContext
const { runtime, workerBrief } =
context.stateMachine.rootStateMachine.workerContext
const waitUntilMqSynched = await startSyncMessage(runtime)
await waitUntilMqSynched()
context.stateMachine.rootStateMachine.workerContext.message =
Expand All @@ -101,10 +95,8 @@ const onSynched = async (fromState, toState, context) => {
}

const onPreMining = async (fromState, toState, context) => {
const {
runtime,
onChainState,
} = context.stateMachine.rootStateMachine.workerContext
const { runtime, onChainState } =
context.stateMachine.rootStateMachine.workerContext
const { initInfo, rpcClient } = runtime

await wait(12000) // wait for onChainState to be synched
Expand Down Expand Up @@ -183,10 +175,8 @@ const onKicked = async (fromState, toState, context) => {
if (fromState === toState) {
return
}
const {
runtime,
snapshotBrief,
} = context.stateMachine.rootStateMachine.workerContext
const { runtime, snapshotBrief } =
context.stateMachine.rootStateMachine.workerContext

await destroyWorkerContext(
context.stateMachine.rootStateMachine.workerContext,
Expand All @@ -205,7 +195,8 @@ const onStateTransition = async (fromState, toState, context) => {
const { workerBrief } = context.stateMachine.rootStateMachine.workerContext
context.stateMachine.rootStateMachine.workerContext.message = `State changed from ${fromState} to ${toState}`
logger.debug(workerBrief, 'State changed.')
context.stateMachine.rootStateMachine.workerContext.stateMachineState = toState
context.stateMachine.rootStateMachine.workerContext.stateMachineState =
toState
}

const wrapStateMachineStateError = (state) =>
Expand Down
1 change: 0 additions & 1 deletion src/lifecycle/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { keyring, phalaApi } from '../utils/api'
import { setupRuntime } from './pruntime'
import BN from 'bn.js'
import PQueue from 'p-queue'
import stateMachine from './state_machine'
import _stateMachine, { EVENTS } from './state_machine'
import logger from '../utils/logger'

Expand Down

0 comments on commit d22777e

Please sign in to comment.