mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-30 10:35:32 +02:00
routing: add new interface AdditionalEdge.
A new interface AdditionalEdge is introduced which allows us to enhance the CachedEdgePolicy with additional information. We currently only need a PayloadSize function which is then used to determine the exact payload size when building a route to adhere to the sphinx package size limit (BOLT04).
This commit is contained in:
32
routing/mocks.go
Normal file
32
routing/mocks.go
Normal file
@ -0,0 +1,32 @@
|
||||
package routing
|
||||
|
||||
import (
|
||||
"github.com/lightningnetwork/lnd/channeldb/models"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// mockAdditionalEdge is a mock of the AdditionalEdge interface.
|
||||
type mockAdditionalEdge struct{ mock.Mock }
|
||||
|
||||
// IntermediatePayloadSize returns the sphinx payload size defined in BOLT04 if
|
||||
// this edge were to be included in a route.
|
||||
func (m *mockAdditionalEdge) IntermediatePayloadSize(amount lnwire.MilliSatoshi,
|
||||
expiry uint32, legacy bool, channelID uint64) uint64 {
|
||||
|
||||
args := m.Called(amount, expiry, legacy, channelID)
|
||||
|
||||
return args.Get(0).(uint64)
|
||||
}
|
||||
|
||||
// EdgePolicy return the policy of the mockAdditionalEdge.
|
||||
func (m *mockAdditionalEdge) EdgePolicy() *models.CachedEdgePolicy {
|
||||
args := m.Called()
|
||||
|
||||
edgePolicy := args.Get(0)
|
||||
if edgePolicy == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return edgePolicy.(*models.CachedEdgePolicy)
|
||||
}
|
Reference in New Issue
Block a user