Skip to content

Commit dc17ce5

Browse files
committed
fsm: add hyperloop fsm
1 parent 9cd91df commit dc17ce5

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
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 --> Registering: OnInit
7+
Init --> Failed: OnError
8+
PubslishSweep
9+
PubslishSweep --> WaitForSweepConfirmation: OnSweeplessSweepPublish
10+
PubslishSweep --> Failed: OnError
11+
PushHtlcNonce
12+
PushHtlcNonce --> Failed: OnError
13+
PushHtlcNonce --> PushHtlcSig: OnPushedHtlcNonce
14+
PushHtlcSig
15+
PushHtlcSig --> WaitForHtlcSig: OnPushedHtlcSig
16+
PushHtlcSig --> Failed: OnError
17+
PushPreimage
18+
PushPreimage --> PushSweeplessSweepSig: OnPushedPreimage
19+
PushPreimage --> Failed: OnError
20+
PushSweeplessSweepSig
21+
PushSweeplessSweepSig --> PubslishSweep: OnPushedSweeplessSweepSig
22+
PushSweeplessSweepSig --> Failed: OnError
23+
Registering
24+
Registering --> WaitForPublish: OnRegistered
25+
Registering --> Failed: OnError
26+
SweepConfirmed
27+
WaitForConfirmation
28+
WaitForConfirmation --> PushHtlcNonce: OnConfirmed
29+
WaitForConfirmation --> Failed: OnError
30+
WaitForHtlcSig
31+
WaitForHtlcSig --> PushPreimage: OnReceivedHtlcSig
32+
WaitForHtlcSig --> Failed: OnError
33+
WaitForPublish
34+
WaitForPublish --> WaitForConfirmation: OnPublished
35+
WaitForPublish --> Failed: OnError
36+
WaitForReadyForHtlcSig
37+
WaitForReadyForHtlcSig --> PushHtlcSig: OnReadyForHtlcSig
38+
WaitForReadyForHtlcSig --> Failed: OnError
39+
WaitForReadyForSweeplessSweepSig
40+
WaitForReadyForSweeplessSweepSig --> PushSweeplessSweepSig: OnReadyForSweeplessSweepSig
41+
WaitForReadyForSweeplessSweepSig --> Failed: OnError
42+
WaitForSweepConfirmation
43+
WaitForSweepConfirmation --> SweepConfirmed: OnSweeplessSweepConfirmed
44+
WaitForSweepConfirmation --> Failed: OnError
45+
```

scripts/fsm-generate.sh

Lines changed: 2 additions & 1 deletion
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
33
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
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)