mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
fsm: add reservation fsm compiling
This commit is contained in:
parent
f00329d7c7
commit
9b178dd979
4 changed files with 29 additions and 1 deletions
|
|
@ -206,6 +206,8 @@ func (s *StateMachine) SendEvent(event EventType, eventCtx EventContext) error {
|
|||
// current state.
|
||||
state, err := s.getNextState(event)
|
||||
if err != nil {
|
||||
log.Errorf("unable to get next state: %v from event: "+
|
||||
"%v, current state: %v", err, event, s.current)
|
||||
return ErrEventRejected
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import (
|
|||
"sort"
|
||||
|
||||
"github.com/lightninglabs/loop/fsm"
|
||||
"github.com/lightninglabs/loop/instantout/reservation"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -41,6 +42,13 @@ func run() error {
|
|||
return err
|
||||
}
|
||||
|
||||
case "reservation":
|
||||
reservationFSM := &reservation.FSM{}
|
||||
err = writeMermaidFile(fp, reservationFSM.GetReservationStates())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
default:
|
||||
fmt.Println("Missing or wrong argument: fsm must be one of:")
|
||||
fmt.Println("\treservations")
|
||||
|
|
|
|||
17
instantout/reservation/reservation_fsm.md
Normal file
17
instantout/reservation/reservation_fsm.md
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
```mermaid
|
||||
stateDiagram-v2
|
||||
[*] --> Init: OnServerRequest
|
||||
Confirmed
|
||||
Confirmed --> TimedOut: OnTimedOut
|
||||
Confirmed --> Confirmed: OnRecover
|
||||
Failed
|
||||
Init
|
||||
Init --> Failed: OnError
|
||||
Init --> WaitForConfirmation: OnBroadcast
|
||||
Init --> Failed: OnRecover
|
||||
TimedOut
|
||||
WaitForConfirmation
|
||||
WaitForConfirmation --> WaitForConfirmation: OnRecover
|
||||
WaitForConfirmation --> Confirmed: OnConfirmed
|
||||
WaitForConfirmation --> TimedOut: OnTimedOut
|
||||
```
|
||||
|
|
@ -1,2 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
go run ./fsm/stateparser/stateparser.go --out ./fsm/example_fsm.md --fsm example
|
||||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue