mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-03 19:50:25 +02:00
routing: export dbMPPayment interface
This will assist external programs attempting to re-use ChannelRouter code and leverage the ControlTower's FetchPayment method.
This commit is contained in:
parent
1bf7ad9b43
commit
7547c234cc
@ -9,9 +9,9 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/queue"
|
"github.com/lightningnetwork/lnd/queue"
|
||||||
)
|
)
|
||||||
|
|
||||||
// dbMPPayment is an interface derived from channeldb.MPPayment that is used by
|
// DBMPPayment is an interface derived from channeldb.MPPayment that is used by
|
||||||
// the payment lifecycle.
|
// the payment lifecycle.
|
||||||
type dbMPPayment interface {
|
type DBMPPayment interface {
|
||||||
// GetState returns the current state of the payment.
|
// GetState returns the current state of the payment.
|
||||||
GetState() *channeldb.MPPaymentState
|
GetState() *channeldb.MPPaymentState
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ type ControlTower interface {
|
|||||||
|
|
||||||
// FetchPayment fetches the payment corresponding to the given payment
|
// FetchPayment fetches the payment corresponding to the given payment
|
||||||
// hash.
|
// hash.
|
||||||
FetchPayment(paymentHash lntypes.Hash) (dbMPPayment, error)
|
FetchPayment(paymentHash lntypes.Hash) (DBMPPayment, error)
|
||||||
|
|
||||||
// FailPayment transitions a payment into the Failed state, and records
|
// FailPayment transitions a payment into the Failed state, and records
|
||||||
// the ultimate reason the payment failed. Note that this should only
|
// the ultimate reason the payment failed. Note that this should only
|
||||||
@ -273,7 +273,7 @@ func (p *controlTower) FailAttempt(paymentHash lntypes.Hash,
|
|||||||
|
|
||||||
// FetchPayment fetches the payment corresponding to the given payment hash.
|
// FetchPayment fetches the payment corresponding to the given payment hash.
|
||||||
func (p *controlTower) FetchPayment(paymentHash lntypes.Hash) (
|
func (p *controlTower) FetchPayment(paymentHash lntypes.Hash) (
|
||||||
dbMPPayment, error) {
|
DBMPPayment, error) {
|
||||||
|
|
||||||
return p.db.FetchPayment(paymentHash)
|
return p.db.FetchPayment(paymentHash)
|
||||||
}
|
}
|
||||||
|
@ -504,7 +504,7 @@ func (m *mockControlTowerOld) FailPayment(phash lntypes.Hash,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockControlTowerOld) FetchPayment(phash lntypes.Hash) (
|
func (m *mockControlTowerOld) FetchPayment(phash lntypes.Hash) (
|
||||||
dbMPPayment, error) {
|
DBMPPayment, error) {
|
||||||
|
|
||||||
m.Lock()
|
m.Lock()
|
||||||
defer m.Unlock()
|
defer m.Unlock()
|
||||||
@ -776,7 +776,7 @@ func (m *mockControlTower) FailPayment(phash lntypes.Hash,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockControlTower) FetchPayment(phash lntypes.Hash) (
|
func (m *mockControlTower) FetchPayment(phash lntypes.Hash) (
|
||||||
dbMPPayment, error) {
|
DBMPPayment, error) {
|
||||||
|
|
||||||
args := m.Called(phash)
|
args := m.Called(phash)
|
||||||
|
|
||||||
@ -814,7 +814,7 @@ type mockMPPayment struct {
|
|||||||
mock.Mock
|
mock.Mock
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ dbMPPayment = (*mockMPPayment)(nil)
|
var _ DBMPPayment = (*mockMPPayment)(nil)
|
||||||
|
|
||||||
func (m *mockMPPayment) GetState() *channeldb.MPPaymentState {
|
func (m *mockMPPayment) GetState() *channeldb.MPPaymentState {
|
||||||
args := m.Called()
|
args := m.Called()
|
||||||
|
@ -109,7 +109,7 @@ const (
|
|||||||
|
|
||||||
// decideNextStep is used to determine the next step in the payment lifecycle.
|
// decideNextStep is used to determine the next step in the payment lifecycle.
|
||||||
func (p *paymentLifecycle) decideNextStep(
|
func (p *paymentLifecycle) decideNextStep(
|
||||||
payment dbMPPayment) (stateStep, error) {
|
payment DBMPPayment) (stateStep, error) {
|
||||||
|
|
||||||
// Check whether we could make new HTLC attempts.
|
// Check whether we could make new HTLC attempts.
|
||||||
allow, err := payment.AllowMoreAttempts()
|
allow, err := payment.AllowMoreAttempts()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user