mirror of
https://github.com/lightninglabs/loop
synced 2024-11-16 00:12:52 +00:00
loopdb: abandon swap state
This commit is contained in:
parent
8612912e97
commit
0fbf253391
@ -64,6 +64,10 @@ const (
|
|||||||
// StateFailIncorrectHtlcAmt indicates that the amount of an externally
|
// StateFailIncorrectHtlcAmt indicates that the amount of an externally
|
||||||
// published loop in htlc didn't match the swap amount.
|
// published loop in htlc didn't match the swap amount.
|
||||||
StateFailIncorrectHtlcAmt SwapState = 10
|
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
|
// SwapStateType defines the types of swap states that exist. Every swap state
|
||||||
@ -98,6 +102,18 @@ func (s SwapState) Type() SwapStateType {
|
|||||||
return StateTypeFail
|
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.
|
// String returns a string representation of the swap's state.
|
||||||
func (s SwapState) String() string {
|
func (s SwapState) String() string {
|
||||||
switch s {
|
switch s {
|
||||||
@ -134,6 +150,9 @@ func (s SwapState) String() string {
|
|||||||
case StateFailIncorrectHtlcAmt:
|
case StateFailIncorrectHtlcAmt:
|
||||||
return "IncorrectHtlcAmt"
|
return "IncorrectHtlcAmt"
|
||||||
|
|
||||||
|
case StateFailAbandoned:
|
||||||
|
return "FailAbandoned"
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return "Unknown"
|
return "Unknown"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user