mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
loopdb: abandon swap state
This commit is contained in:
parent
8612912e97
commit
0fbf253391
1 changed files with 19 additions and 0 deletions
|
|
@ -64,6 +64,10 @@ const (
|
|||
// StateFailIncorrectHtlcAmt indicates that the amount of an externally
|
||||
// published loop in htlc didn't match the swap amount.
|
||||
StateFailIncorrectHtlcAmt SwapState = 10
|
||||
|
||||
// StateFailAbandoned indicates that a swap has been abandoned. Its
|
||||
// execution has been canceled. It won't further be processed.
|
||||
StateFailAbandoned SwapState = 11
|
||||
)
|
||||
|
||||
// SwapStateType defines the types of swap states that exist. Every swap state
|
||||
|
|
@ -98,6 +102,18 @@ func (s SwapState) Type() SwapStateType {
|
|||
return StateTypeFail
|
||||
}
|
||||
|
||||
// IsPending returns true if the swap is in a pending state.
|
||||
func (s SwapState) IsPending() bool {
|
||||
return s == StateInitiated || s == StateHtlcPublished ||
|
||||
s == StatePreimageRevealed || s == StateFailTemporary ||
|
||||
s == StateInvoiceSettled
|
||||
}
|
||||
|
||||
// IsFinal returns true if the swap is in a final state.
|
||||
func (s SwapState) IsFinal() bool {
|
||||
return !s.IsPending()
|
||||
}
|
||||
|
||||
// String returns a string representation of the swap's state.
|
||||
func (s SwapState) String() string {
|
||||
switch s {
|
||||
|
|
@ -134,6 +150,9 @@ func (s SwapState) String() string {
|
|||
case StateFailIncorrectHtlcAmt:
|
||||
return "IncorrectHtlcAmt"
|
||||
|
||||
case StateFailAbandoned:
|
||||
return "FailAbandoned"
|
||||
|
||||
default:
|
||||
return "Unknown"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue