Skip to content

Commit

Permalink
routing: export dbMPPayment interface
Browse files Browse the repository at this point in the history
This will assist external programs attempting to re-use
ChannelRouter code and leverage the ControlTower's FetchPayment
method.
  • Loading branch information
calvinrzachman committed Aug 28, 2024
1 parent 1bf7ad9 commit 7547c23
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions routing/control_tower.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"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.
type dbMPPayment interface {
type DBMPPayment interface {
// GetState returns the current state of the payment.
GetState() *channeldb.MPPaymentState

Expand Down Expand Up @@ -76,7 +76,7 @@ type ControlTower interface {

// FetchPayment fetches the payment corresponding to the given payment
// hash.
FetchPayment(paymentHash lntypes.Hash) (dbMPPayment, error)
FetchPayment(paymentHash lntypes.Hash) (DBMPPayment, error)

// FailPayment transitions a payment into the Failed state, and records
// the ultimate reason the payment failed. Note that this should only
Expand Down Expand Up @@ -273,7 +273,7 @@ func (p *controlTower) FailAttempt(paymentHash lntypes.Hash,

// FetchPayment fetches the payment corresponding to the given payment hash.
func (p *controlTower) FetchPayment(paymentHash lntypes.Hash) (
dbMPPayment, error) {
DBMPPayment, error) {

return p.db.FetchPayment(paymentHash)
}
Expand Down
6 changes: 3 additions & 3 deletions routing/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ func (m *mockControlTowerOld) FailPayment(phash lntypes.Hash,
}

func (m *mockControlTowerOld) FetchPayment(phash lntypes.Hash) (
dbMPPayment, error) {
DBMPPayment, error) {

m.Lock()
defer m.Unlock()
Expand Down Expand Up @@ -776,7 +776,7 @@ func (m *mockControlTower) FailPayment(phash lntypes.Hash,
}

func (m *mockControlTower) FetchPayment(phash lntypes.Hash) (
dbMPPayment, error) {
DBMPPayment, error) {

args := m.Called(phash)

Expand Down Expand Up @@ -814,7 +814,7 @@ type mockMPPayment struct {
mock.Mock
}

var _ dbMPPayment = (*mockMPPayment)(nil)
var _ DBMPPayment = (*mockMPPayment)(nil)

func (m *mockMPPayment) GetState() *channeldb.MPPaymentState {
args := m.Called()
Expand Down
2 changes: 1 addition & 1 deletion routing/payment_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const (

// decideNextStep is used to determine the next step in the payment lifecycle.
func (p *paymentLifecycle) decideNextStep(
payment dbMPPayment) (stateStep, error) {
payment DBMPPayment) (stateStep, error) {

// Check whether we could make new HTLC attempts.
allow, err := payment.AllowMoreAttempts()
Expand Down

0 comments on commit 7547c23

Please sign in to comment.