Skip to content

Commit 8b7f1a7

Browse files
committed
fsm: add hyperloop fsm
1 parent e2db611 commit 8b7f1a7

File tree

3 files changed

+56
-2
lines changed

3 files changed

+56
-2
lines changed

fsm/stateparser/stateparser.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"sort"
1111

1212
"github.com/lightninglabs/loop/fsm"
13+
"github.com/lightninglabs/loop/hyperloop"
1314
"github.com/lightninglabs/loop/instantout"
1415
"github.com/lightninglabs/loop/instantout/reservation"
1516
)
@@ -57,6 +58,13 @@ func run() error {
5758
return err
5859
}
5960

61+
case "hyperloop":
62+
hyperloop := hyperloop.FSM{}
63+
err = writeMermaidFile(fp, hyperloop.GetStateMap())
64+
if err != nil {
65+
return err
66+
}
67+
6068
default:
6169
fmt.Println("Missing or wrong argument: fsm must be one of:")
6270
fmt.Println("\treservations")

hyperloop/fsm.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
```mermaid
2+
stateDiagram-v2
3+
[*] --> Init: OnStart
4+
Failed
5+
Init
6+
Init --> Failed: OnError
7+
Init --> Registering: OnInit
8+
PushHtlcNonce
9+
PushHtlcNonce --> WaitForReadyForHtlcSig: OnPushedHtlcNonce
10+
PushHtlcNonce --> Failed: OnError
11+
PushHtlcSig
12+
PushHtlcSig --> WaitForHtlcSig: OnPushedHtlcSig
13+
PushHtlcSig --> Failed: OnError
14+
PushPreimage
15+
PushPreimage --> WaitForReadyForSweeplessSweepSig: OnPushedPreimage
16+
PushPreimage --> Failed: OnError
17+
PushSweeplessSweepSig
18+
PushSweeplessSweepSig --> WaitForSweepPublish: OnPushedSweeplessSweepSig
19+
PushSweeplessSweepSig --> Failed: OnError
20+
Registering
21+
Registering --> WaitForPublish: OnRegistered
22+
Registering --> Failed: OnError
23+
SweepConfirmed
24+
WaitForConfirmation
25+
WaitForConfirmation --> PushHtlcNonce: OnConfirmed
26+
WaitForConfirmation --> Failed: OnError
27+
WaitForHtlcSig
28+
WaitForHtlcSig --> PushPreimage: OnReceivedHtlcSig
29+
WaitForHtlcSig --> Failed: OnError
30+
WaitForPublish
31+
WaitForPublish --> WaitForConfirmation: OnPublished
32+
WaitForPublish --> Failed: OnError
33+
WaitForReadyForHtlcSig
34+
WaitForReadyForHtlcSig --> PushHtlcSig: OnReadyForHtlcSig
35+
WaitForReadyForHtlcSig --> Failed: OnError
36+
WaitForReadyForSweeplessSweepSig
37+
WaitForReadyForSweeplessSweepSig --> PushSweeplessSweepSig: OnReadyForSweeplessSweepSig
38+
WaitForReadyForSweeplessSweepSig --> Failed: OnError
39+
WaitForSweepConfirmation
40+
WaitForSweepConfirmation --> SweepConfirmed: OnSweeplessSweepConfirmed
41+
WaitForSweepConfirmation --> Failed: OnError
42+
WaitForSweepPublish
43+
WaitForSweepPublish --> WaitForSweepConfirmation: OnSweeplessSweepPublish
44+
WaitForSweepPublish --> Failed: OnError
45+
```

scripts/fsm-generate.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env bash
22
go run ./fsm/stateparser/stateparser.go --out ./fsm/example_fsm.md --fsm example
3-
go run ./fsm/stateparser/stateparser.go --out ./reservation/reservation_fsm.md --fsm reservation
4-
go run ./fsm/stateparser/stateparser.go --out ./instantout/fsm.md --fsm instantout
3+
go run ./fsm/stateparser/stateparser.go --out ./instantout/reservation/reservation_fsm.md --fsm reservation
4+
go run ./fsm/stateparser/stateparser.go --out ./instantout/fsm.md --fsm instantout
5+
go run ./fsm/stateparser/stateparser.go --out ./hyperloop/fsm.md --fsm hyperloop

0 commit comments

Comments
 (0)