Skip to content

Commit 8806166

Browse files
committed
cleanup
1 parent 4260cdd commit 8806166

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

codex/utils/asyncstatemachine.nim

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,13 @@ proc start*(machine: Machine, initialState: State) =
9090
machine.scheduled = newAsyncQueue[Event]()
9191

9292
machine.started = true
93-
try:
94-
discard machine.scheduler().track(machine)
95-
machine.schedule(Event.transition(machine.state, initialState))
96-
except CancelledError as e:
97-
discard
98-
except CatchableError as e:
99-
error("Error in scheduler", error = e.msg)
93+
machine.scheduler()
94+
.track(machine)
95+
.cancelled(proc() = trace("machine.scheduler cancelled, swallowing"))
96+
.catch((err: ref CatchableError) =>
97+
error("Error in scheduler", error = err.msg)
98+
)
99+
machine.schedule(Event.transition(machine.state, initialState))
100100

101101
proc stop*(machine: Machine) {.async.} =
102102
if not machine.started:

tests/codex/utils/testasyncstatemachine.nim

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ method run(state: State1, machine: Machine): Future[?State] {.async.} =
2525

2626
method run(state: State2, machine: Machine): Future[?State] {.async.} =
2727
inc runs[1]
28-
echo "State2 run, runs: ", $runs
2928
try:
3029
await sleepAsync(1.hours)
3130
except CancelledError:
@@ -37,7 +36,6 @@ method run(state: State3, machine: Machine): Future[?State] {.async.} =
3736

3837
method run(state: State4, machine: Machine): Future[?State] {.async.} =
3938
inc runs[3]
40-
echo "State4 run, runs: ", $runs
4139
raise newException(ValueError, "failed")
4240

4341
method onMoveToNextStateEvent*(state: State): ?State {.base, upraises:[].} =
@@ -60,7 +58,6 @@ method onError(state: State3, error: ref CatchableError): ?State =
6058

6159
method onError(state: State4, error: ref CatchableError): ?State =
6260
inc errors[3]
63-
echo "State4 onError, errors: ", $errors
6461
some State(State2.new())
6562

6663
asyncchecksuite "async state machines":

tests/integration/marketplacesuite.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import pkg/chronos
2-
import pkg/ethers
2+
import pkg/ethers/erc20
33
from pkg/libp2p import Cid
44
import pkg/codex/contracts/marketplace as mp
55
import pkg/codex/periods

0 commit comments

Comments
 (0)