Skip to content

Commit

Permalink
fsm: add hyperloop fsm
Browse files Browse the repository at this point in the history
  • Loading branch information
sputn1ck committed Aug 19, 2024
1 parent 45cc003 commit 5d5546f
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
8 changes: 8 additions & 0 deletions fsm/stateparser/stateparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"sort"

"github.com/lightninglabs/loop/fsm"
"github.com/lightninglabs/loop/hyperloop"
"github.com/lightninglabs/loop/instantout"
"github.com/lightninglabs/loop/instantout/reservation"
)
Expand Down Expand Up @@ -57,6 +58,13 @@ func run() error {
return err
}

case "hyperloop":
hyperloop := hyperloop.FSM{}
err = writeMermaidFile(fp, hyperloop.GetStateMap())
if err != nil {
return err
}

default:
fmt.Println("Missing or wrong argument: fsm must be one of:")
fmt.Println("\treservations")
Expand Down
45 changes: 45 additions & 0 deletions hyperloop/fsm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
```mermaid
stateDiagram-v2
[*] --> Init: OnStart
Failed
Init
Init --> Registering: OnInit
Init --> Failed: OnError
PubslishSweep
PubslishSweep --> WaitForSweepConfirmation: OnSweeplessSweepPublish
PubslishSweep --> Failed: OnError
PushHtlcNonce
PushHtlcNonce --> WaitForReadyForHtlcSig: OnPushedHtlcNonce
PushHtlcNonce --> Failed: OnError
PushHtlcSig
PushHtlcSig --> WaitForHtlcSig: OnPushedHtlcSig
PushHtlcSig --> Failed: OnError
PushPreimage
PushPreimage --> WaitForReadyForSweeplessSweepSig: OnPushedPreimage
PushPreimage --> Failed: OnError
PushSweeplessSweepSig
PushSweeplessSweepSig --> PubslishSweep: OnPushedSweeplessSweepSig
PushSweeplessSweepSig --> Failed: OnError
Registering
Registering --> WaitForPublish: OnRegistered
Registering --> Failed: OnError
SweepConfirmed
WaitForConfirmation
WaitForConfirmation --> PushHtlcNonce: OnConfirmed
WaitForConfirmation --> Failed: OnError
WaitForHtlcSig
WaitForHtlcSig --> PushPreimage: OnReceivedHtlcSig
WaitForHtlcSig --> Failed: OnError
WaitForPublish
WaitForPublish --> WaitForConfirmation: OnPublished
WaitForPublish --> Failed: OnError
WaitForReadyForHtlcSig
WaitForReadyForHtlcSig --> PushHtlcSig: OnReadyForHtlcSig
WaitForReadyForHtlcSig --> Failed: OnError
WaitForReadyForSweeplessSweepSig
WaitForReadyForSweeplessSweepSig --> PushSweeplessSweepSig: OnReadyForSweeplessSweepSig
WaitForReadyForSweeplessSweepSig --> Failed: OnError
WaitForSweepConfirmation
WaitForSweepConfirmation --> SweepConfirmed: OnSweeplessSweepConfirmed
WaitForSweepConfirmation --> Failed: OnError
```
3 changes: 2 additions & 1 deletion scripts/fsm-generate.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
go run ./fsm/stateparser/stateparser.go --out ./fsm/example_fsm.md --fsm example
go run ./fsm/stateparser/stateparser.go --out ./reservation/reservation_fsm.md --fsm reservation
go run ./fsm/stateparser/stateparser.go --out ./instantout/fsm.md --fsm instantout
go run ./fsm/stateparser/stateparser.go --out ./instantout/fsm.md --fsm instantout
go run ./fsm/stateparser/stateparser.go --out ./hyperloop/fsm.md --fsm hyperloop

0 comments on commit 5d5546f

Please sign in to comment.