mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
staticaddr: generate FSM diagrams
This commit is contained in:
parent
e77a1ab634
commit
0176e96e3c
4 changed files with 103 additions and 1 deletions
|
|
@ -12,6 +12,8 @@ import (
|
||||||
"github.com/lightninglabs/loop/fsm"
|
"github.com/lightninglabs/loop/fsm"
|
||||||
"github.com/lightninglabs/loop/instantout"
|
"github.com/lightninglabs/loop/instantout"
|
||||||
"github.com/lightninglabs/loop/instantout/reservation"
|
"github.com/lightninglabs/loop/instantout/reservation"
|
||||||
|
"github.com/lightninglabs/loop/staticaddr/deposit"
|
||||||
|
"github.com/lightninglabs/loop/staticaddr/loopin"
|
||||||
)
|
)
|
||||||
|
|
||||||
var errInvalidFSMSelector = errors.New("missing or unknown fsm selector")
|
var errInvalidFSMSelector = errors.New("missing or unknown fsm selector")
|
||||||
|
|
@ -59,9 +61,18 @@ func getStates(stateMachine string) (fsm.States, error) {
|
||||||
instantOutFSM := &instantout.FSM{}
|
instantOutFSM := &instantout.FSM{}
|
||||||
return instantOutFSM.GetV1ReservationStates(), nil
|
return instantOutFSM.GetV1ReservationStates(), nil
|
||||||
|
|
||||||
|
case "staticaddr-deposit":
|
||||||
|
depositFSM := &deposit.FSM{}
|
||||||
|
return depositFSM.DepositStatesV0(), nil
|
||||||
|
|
||||||
|
case "staticaddr-loopin":
|
||||||
|
loopInFSM := &loopin.FSM{}
|
||||||
|
return loopInFSM.LoopInStatesV0(), nil
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf(
|
return nil, fmt.Errorf(
|
||||||
"%w %q; supported selectors: example, instantout, reservation",
|
"%w %q; supported selectors: example, instantout, "+
|
||||||
|
"reservation, staticaddr-deposit, staticaddr-loopin",
|
||||||
errInvalidFSMSelector, stateMachine,
|
errInvalidFSMSelector, stateMachine,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,3 +4,5 @@ set -euo pipefail
|
||||||
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 ./instantout/reservation/reservation_fsm.md --fsm reservation
|
go run ./fsm/stateparser/stateparser.go --out ./instantout/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 ./staticaddr/deposit/fsm.md --fsm staticaddr-deposit
|
||||||
|
go run ./fsm/stateparser/stateparser.go --out ./staticaddr/loopin/fsm.md --fsm staticaddr-loopin
|
||||||
|
|
|
||||||
52
staticaddr/deposit/fsm.md
Normal file
52
staticaddr/deposit/fsm.md
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
```mermaid
|
||||||
|
stateDiagram-v2
|
||||||
|
[*] --> Deposited: OnStart
|
||||||
|
ChannelPublished
|
||||||
|
ChannelPublished --> ChannelPublished: OnExpiry
|
||||||
|
Deposited
|
||||||
|
Deposited --> Deposited: OnError
|
||||||
|
Deposited --> PublishExpirySweep: OnExpiry
|
||||||
|
Deposited --> LoopingIn: OnLoopInInitiated
|
||||||
|
Deposited --> OpeningChannel: OnOpeningChannel
|
||||||
|
Deposited --> Deposited: OnRecover
|
||||||
|
Deposited --> SweepHtlcTimeout: OnSweepingHtlcTimeout
|
||||||
|
Deposited --> Withdrawing: OnWithdrawInitiated
|
||||||
|
Expired
|
||||||
|
Expired --> Expired: OnExpiry
|
||||||
|
HtlcTimeoutSwept
|
||||||
|
HtlcTimeoutSwept --> HtlcTimeoutSwept: OnExpiry
|
||||||
|
LoopedIn
|
||||||
|
LoopedIn --> LoopedIn: OnExpiry
|
||||||
|
LoopingIn
|
||||||
|
LoopingIn --> Deposited: OnError
|
||||||
|
LoopingIn --> PublishExpirySweep: OnExpiry
|
||||||
|
LoopingIn --> LoopingIn: OnLoopInInitiated
|
||||||
|
LoopingIn --> LoopedIn: OnLoopedIn
|
||||||
|
LoopingIn --> LoopingIn: OnRecover
|
||||||
|
LoopingIn --> SweepHtlcTimeout: OnSweepingHtlcTimeout
|
||||||
|
OpeningChannel
|
||||||
|
OpeningChannel --> ChannelPublished: OnChannelPublished
|
||||||
|
OpeningChannel --> Deposited: OnError
|
||||||
|
OpeningChannel --> OpeningChannel: OnExpiry
|
||||||
|
OpeningChannel --> OpeningChannel: OnRecover
|
||||||
|
PublishExpirySweep
|
||||||
|
PublishExpirySweep --> Deposited: OnError
|
||||||
|
PublishExpirySweep --> WaitForExpirySweep: OnExpiryPublished
|
||||||
|
PublishExpirySweep --> PublishExpirySweep: OnRecover
|
||||||
|
SweepHtlcTimeout
|
||||||
|
SweepHtlcTimeout --> HtlcTimeoutSwept: OnHtlcTimeoutSwept
|
||||||
|
SweepHtlcTimeout --> SweepHtlcTimeout: OnRecover
|
||||||
|
WaitForExpirySweep
|
||||||
|
WaitForExpirySweep --> Deposited: OnError
|
||||||
|
WaitForExpirySweep --> Expired: OnExpirySwept
|
||||||
|
WaitForExpirySweep --> PublishExpirySweep: OnRecover
|
||||||
|
Withdrawing
|
||||||
|
Withdrawing --> Deposited: OnError
|
||||||
|
Withdrawing --> Withdrawing: OnExpiry
|
||||||
|
Withdrawing --> Withdrawing: OnRecover
|
||||||
|
Withdrawing --> Withdrawing: OnWithdrawInitiated
|
||||||
|
Withdrawing --> Withdrawn: OnWithdrawn
|
||||||
|
Withdrawn
|
||||||
|
Withdrawn --> Withdrawn: OnExpiry
|
||||||
|
Withdrawn --> Withdrawn: OnWithdrawn
|
||||||
|
```
|
||||||
37
staticaddr/loopin/fsm.md
Normal file
37
staticaddr/loopin/fsm.md
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
```mermaid
|
||||||
|
stateDiagram-v2
|
||||||
|
[*] --> InitHtlcTx: OnInitHtlc
|
||||||
|
Failed
|
||||||
|
HtlcTimeoutSwept
|
||||||
|
InitHtlcTx
|
||||||
|
InitHtlcTx --> UnlockDeposits: OnError
|
||||||
|
InitHtlcTx --> SignHtlcTx: OnHtlcInitiated
|
||||||
|
InitHtlcTx --> UnlockDeposits: OnRecover
|
||||||
|
MonitorHtlcTimeoutSweep
|
||||||
|
MonitorHtlcTimeoutSweep --> Failed: OnError
|
||||||
|
MonitorHtlcTimeoutSweep --> HtlcTimeoutSwept: OnHtlcTimeoutSwept
|
||||||
|
MonitorHtlcTimeoutSweep --> MonitorHtlcTimeoutSweep: OnRecover
|
||||||
|
MonitorInvoiceAndHtlcTx
|
||||||
|
MonitorInvoiceAndHtlcTx --> UnlockDeposits: OnError
|
||||||
|
MonitorInvoiceAndHtlcTx --> PaymentReceived: OnPaymentReceived
|
||||||
|
MonitorInvoiceAndHtlcTx --> MonitorInvoiceAndHtlcTx: OnRecover
|
||||||
|
MonitorInvoiceAndHtlcTx --> Failed: OnSwapTimedOut
|
||||||
|
MonitorInvoiceAndHtlcTx --> SweepHtlcTimeout: OnSweepHtlcTimeout
|
||||||
|
PaymentReceived
|
||||||
|
PaymentReceived --> SucceededTransitioningFailed: OnError
|
||||||
|
PaymentReceived --> Succeeded: OnRecover
|
||||||
|
PaymentReceived --> Succeeded: OnSucceeded
|
||||||
|
SignHtlcTx
|
||||||
|
SignHtlcTx --> UnlockDeposits: OnError
|
||||||
|
SignHtlcTx --> MonitorInvoiceAndHtlcTx: OnHtlcTxSigned
|
||||||
|
SignHtlcTx --> UnlockDeposits: OnRecover
|
||||||
|
Succeeded
|
||||||
|
SucceededTransitioningFailed
|
||||||
|
SweepHtlcTimeout
|
||||||
|
SweepHtlcTimeout --> Failed: OnError
|
||||||
|
SweepHtlcTimeout --> MonitorHtlcTimeoutSweep: OnHtlcTimeoutSweepPublished
|
||||||
|
SweepHtlcTimeout --> SweepHtlcTimeout: OnRecover
|
||||||
|
UnlockDeposits
|
||||||
|
UnlockDeposits --> Failed: OnError
|
||||||
|
UnlockDeposits --> UnlockDeposits: OnRecover
|
||||||
|
```
|
||||||
Loading…
Add table
Add a link
Reference in a new issue