routing: export RestrictParams and EdgeLocator

This commit is contained in:
Joost Jager 2019-03-05 11:13:44 +01:00
parent 4937304732
commit b2b28b49b1
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7
6 changed files with 155 additions and 153 deletions

View File

@ -46,7 +46,7 @@ type missionControl struct {
// it was added to the prune view. Edges are added to this map if a
// caller reports to missionControl a failure localized to that edge
// when sending a payment.
failedEdges map[edgeLocator]time.Time
failedEdges map[EdgeLocator]time.Time
// failedVertexes maps a node's public key that should be pruned, to
// the time that it was added to the prune view. Vertexes are added to
@ -75,7 +75,7 @@ func newMissionControl(g *channeldb.ChannelGraph, selfNode *channeldb.LightningN
qb func(*channeldb.ChannelEdgeInfo) lnwire.MilliSatoshi) *missionControl {
return &missionControl{
failedEdges: make(map[edgeLocator]time.Time),
failedEdges: make(map[EdgeLocator]time.Time),
failedVertexes: make(map[Vertex]time.Time),
selfNode: selfNode,
queryBandwidth: qb,
@ -89,7 +89,7 @@ func newMissionControl(g *channeldb.ChannelGraph, selfNode *channeldb.LightningN
// state of the wider network from the PoV of mission control compiled via HTLC
// routing attempts in the past.
type graphPruneView struct {
edges map[edgeLocator]struct{}
edges map[EdgeLocator]struct{}
vertexes map[Vertex]struct{}
}
@ -124,7 +124,7 @@ func (m *missionControl) GraphPruneView() graphPruneView {
// We'll also do the same for edges, but use the edgeDecay this time
// rather than the decay for vertexes.
edges := make(map[edgeLocator]struct{})
edges := make(map[EdgeLocator]struct{})
for edge, pruneTime := range m.failedEdges {
if now.Sub(pruneTime) >= edgeDecay {
log.Tracef("Pruning decayed failure report for edge %v "+
@ -217,7 +217,7 @@ func (m *missionControl) NewPaymentSession(routeHints [][]HopHint,
pruneViewSnapshot: viewSnapshot,
additionalEdges: edges,
bandwidthHints: bandwidthHints,
errFailedPolicyChans: make(map[edgeLocator]struct{}),
errFailedPolicyChans: make(map[EdgeLocator]struct{}),
mc: m,
}, nil
}
@ -231,7 +231,7 @@ func (m *missionControl) NewPaymentSessionFromRoutes(routes []*Route) *paymentSe
pruneViewSnapshot: m.GraphPruneView(),
haveRoutes: true,
preBuiltRoutes: routes,
errFailedPolicyChans: make(map[edgeLocator]struct{}),
errFailedPolicyChans: make(map[EdgeLocator]struct{}),
mc: m,
}
}
@ -275,7 +275,7 @@ func generateBandwidthHints(sourceNode *channeldb.LightningNode,
// if no payment attempts have been made.
func (m *missionControl) ResetHistory() {
m.Lock()
m.failedEdges = make(map[edgeLocator]time.Time)
m.failedEdges = make(map[EdgeLocator]time.Time)
m.failedVertexes = make(map[Vertex]time.Time)
m.Unlock()
}

View File

@ -398,24 +398,24 @@ type graphParams struct {
bandwidthHints map[uint64]lnwire.MilliSatoshi
}
// restrictParams wraps the set of restrictions passed to findPath that the
// RestrictParams wraps the set of restrictions passed to findPath that the
// found path must adhere to.
type restrictParams struct {
// ignoredNodes is an optional set of nodes that should be ignored if
type RestrictParams struct {
// IgnoredNodes is an optional set of nodes that should be ignored if
// encountered during path finding.
ignoredNodes map[Vertex]struct{}
IgnoredNodes map[Vertex]struct{}
// ignoredEdges is an optional set of edges that should be ignored if
// IgnoredEdges is an optional set of edges that should be ignored if
// encountered during path finding.
ignoredEdges map[edgeLocator]struct{}
IgnoredEdges map[EdgeLocator]struct{}
// feeLimit is a maximum fee amount allowed to be used on the path from
// FeeLimit is a maximum fee amount allowed to be used on the path from
// the source to the target.
feeLimit lnwire.MilliSatoshi
FeeLimit lnwire.MilliSatoshi
// outgoingChannelID is the channel that needs to be taken to the first
// OutgoingChannelID is the channel that needs to be taken to the first
// hop. If nil, any channel may be used.
outgoingChannelID *uint64
OutgoingChannelID *uint64
}
// findPath attempts to find a path from the source node within the
@ -429,7 +429,7 @@ type restrictParams struct {
// destination node back to source. This is to properly accumulate fees
// that need to be paid along the path and accurately check the amount
// to forward at every node against the available bandwidth.
func findPath(g *graphParams, r *restrictParams,
func findPath(g *graphParams, r *RestrictParams,
sourceNode *channeldb.LightningNode, target *btcec.PublicKey,
amt lnwire.MilliSatoshi) ([]*channeldb.ChannelEdgePolicy, error) {
@ -536,20 +536,20 @@ func findPath(g *graphParams, r *restrictParams,
// If we have an outgoing channel restriction and this is not
// the specified channel, skip it.
if isSourceChan && r.outgoingChannelID != nil &&
*r.outgoingChannelID != edge.ChannelID {
if isSourceChan && r.OutgoingChannelID != nil &&
*r.OutgoingChannelID != edge.ChannelID {
return
}
// If this vertex or edge has been black listed, then we'll
// skip exploring this edge.
if _, ok := r.ignoredNodes[fromVertex]; ok {
if _, ok := r.IgnoredNodes[fromVertex]; ok {
return
}
locator := newEdgeLocator(edge)
if _, ok := r.ignoredEdges[*locator]; ok {
if _, ok := r.IgnoredEdges[*locator]; ok {
return
}
@ -603,7 +603,7 @@ func findPath(g *graphParams, r *restrictParams,
// Check if accumulated fees would exceed fee limit when this
// node would be added to the path.
totalFee := amountToReceive - amt
if totalFee > r.feeLimit {
if totalFee > r.FeeLimit {
return
}
@ -784,7 +784,7 @@ func findPaths(tx *bbolt.Tx, graph *channeldb.ChannelGraph,
amt lnwire.MilliSatoshi, feeLimit lnwire.MilliSatoshi, numPaths uint32,
bandwidthHints map[uint64]lnwire.MilliSatoshi) ([][]*channeldb.ChannelEdgePolicy, error) {
ignoredEdges := make(map[edgeLocator]struct{})
ignoredEdges := make(map[EdgeLocator]struct{})
ignoredVertexes := make(map[Vertex]struct{})
// TODO(roasbeef): modifying ordering within heap to eliminate final
@ -803,10 +803,10 @@ func findPaths(tx *bbolt.Tx, graph *channeldb.ChannelGraph,
graph: graph,
bandwidthHints: bandwidthHints,
},
&restrictParams{
ignoredNodes: ignoredVertexes,
ignoredEdges: ignoredEdges,
feeLimit: feeLimit,
&RestrictParams{
IgnoredNodes: ignoredVertexes,
IgnoredEdges: ignoredEdges,
FeeLimit: feeLimit,
},
source, target, amt,
)
@ -839,7 +839,7 @@ func findPaths(tx *bbolt.Tx, graph *channeldb.ChannelGraph,
// we'll exclude from the next path finding attempt.
// These are required to ensure the paths are unique
// and loopless.
ignoredEdges = make(map[edgeLocator]struct{})
ignoredEdges = make(map[EdgeLocator]struct{})
ignoredVertexes = make(map[Vertex]struct{})
// Our spur node is the i-th node in the prior shortest
@ -891,10 +891,10 @@ func findPaths(tx *bbolt.Tx, graph *channeldb.ChannelGraph,
graph: graph,
bandwidthHints: bandwidthHints,
},
&restrictParams{
ignoredNodes: ignoredVertexes,
ignoredEdges: ignoredEdges,
feeLimit: feeLimit,
&RestrictParams{
IgnoredNodes: ignoredVertexes,
IgnoredEdges: ignoredEdges,
FeeLimit: feeLimit,
}, spurNode, target, amt,
)

View File

@ -598,7 +598,7 @@ func TestFindLowestFeePath(t *testing.T) {
}
sourceVertex := Vertex(sourceNode.PubKeyBytes)
ignoredEdges := make(map[edgeLocator]struct{})
ignoredEdges := make(map[EdgeLocator]struct{})
ignoredVertexes := make(map[Vertex]struct{})
const (
@ -612,10 +612,10 @@ func TestFindLowestFeePath(t *testing.T) {
&graphParams{
graph: testGraphInstance.graph,
},
&restrictParams{
ignoredNodes: ignoredVertexes,
ignoredEdges: ignoredEdges,
feeLimit: noFeeLimit,
&RestrictParams{
IgnoredNodes: ignoredVertexes,
IgnoredEdges: ignoredEdges,
FeeLimit: noFeeLimit,
},
sourceNode, target, paymentAmt,
)
@ -744,7 +744,7 @@ func testBasicGraphPathFindingCase(t *testing.T, graphInstance *testGraphInstanc
}
sourceVertex := Vertex(sourceNode.PubKeyBytes)
ignoredEdges := make(map[edgeLocator]struct{})
ignoredEdges := make(map[EdgeLocator]struct{})
ignoredVertexes := make(map[Vertex]struct{})
const (
@ -758,10 +758,10 @@ func testBasicGraphPathFindingCase(t *testing.T, graphInstance *testGraphInstanc
&graphParams{
graph: graphInstance.graph,
},
&restrictParams{
ignoredNodes: ignoredVertexes,
ignoredEdges: ignoredEdges,
feeLimit: test.feeLimit,
&RestrictParams{
IgnoredNodes: ignoredVertexes,
IgnoredEdges: ignoredEdges,
FeeLimit: test.feeLimit,
},
sourceNode, target, paymentAmt,
)
@ -925,8 +925,8 @@ func TestPathFindingWithAdditionalEdges(t *testing.T) {
graph: graph.graph,
additionalEdges: additionalEdges,
},
&restrictParams{
feeLimit: noFeeLimit,
&RestrictParams{
FeeLimit: noFeeLimit,
},
sourceNode, dogePubKey, paymentAmt,
)
@ -1224,7 +1224,7 @@ func TestNewRoutePathTooLong(t *testing.T) {
t.Fatalf("unable to fetch source node: %v", err)
}
ignoredEdges := make(map[edgeLocator]struct{})
ignoredEdges := make(map[EdgeLocator]struct{})
ignoredVertexes := make(map[Vertex]struct{})
paymentAmt := lnwire.NewMSatFromSatoshis(100)
@ -1236,10 +1236,10 @@ func TestNewRoutePathTooLong(t *testing.T) {
&graphParams{
graph: graph.graph,
},
&restrictParams{
ignoredNodes: ignoredVertexes,
ignoredEdges: ignoredEdges,
feeLimit: noFeeLimit,
&RestrictParams{
IgnoredNodes: ignoredVertexes,
IgnoredEdges: ignoredEdges,
FeeLimit: noFeeLimit,
},
sourceNode, target, paymentAmt,
)
@ -1254,10 +1254,10 @@ func TestNewRoutePathTooLong(t *testing.T) {
&graphParams{
graph: graph.graph,
},
&restrictParams{
ignoredNodes: ignoredVertexes,
ignoredEdges: ignoredEdges,
feeLimit: noFeeLimit,
&RestrictParams{
IgnoredNodes: ignoredVertexes,
IgnoredEdges: ignoredEdges,
FeeLimit: noFeeLimit,
},
sourceNode, target, paymentAmt,
)
@ -1283,7 +1283,7 @@ func TestPathNotAvailable(t *testing.T) {
t.Fatalf("unable to fetch source node: %v", err)
}
ignoredEdges := make(map[edgeLocator]struct{})
ignoredEdges := make(map[EdgeLocator]struct{})
ignoredVertexes := make(map[Vertex]struct{})
// With the test graph loaded, we'll test that queries for target that
@ -1303,10 +1303,10 @@ func TestPathNotAvailable(t *testing.T) {
&graphParams{
graph: graph.graph,
},
&restrictParams{
ignoredNodes: ignoredVertexes,
ignoredEdges: ignoredEdges,
feeLimit: noFeeLimit,
&RestrictParams{
IgnoredNodes: ignoredVertexes,
IgnoredEdges: ignoredEdges,
FeeLimit: noFeeLimit,
},
sourceNode, unknownNode, 100,
)
@ -1328,7 +1328,7 @@ func TestPathInsufficientCapacity(t *testing.T) {
if err != nil {
t.Fatalf("unable to fetch source node: %v", err)
}
ignoredEdges := make(map[edgeLocator]struct{})
ignoredEdges := make(map[EdgeLocator]struct{})
ignoredVertexes := make(map[Vertex]struct{})
// Next, test that attempting to find a path in which the current
@ -1346,10 +1346,10 @@ func TestPathInsufficientCapacity(t *testing.T) {
&graphParams{
graph: graph.graph,
},
&restrictParams{
ignoredNodes: ignoredVertexes,
ignoredEdges: ignoredEdges,
feeLimit: noFeeLimit,
&RestrictParams{
IgnoredNodes: ignoredVertexes,
IgnoredEdges: ignoredEdges,
FeeLimit: noFeeLimit,
},
sourceNode, target, payAmt,
)
@ -1373,7 +1373,7 @@ func TestRouteFailMinHTLC(t *testing.T) {
if err != nil {
t.Fatalf("unable to fetch source node: %v", err)
}
ignoredEdges := make(map[edgeLocator]struct{})
ignoredEdges := make(map[EdgeLocator]struct{})
ignoredVertexes := make(map[Vertex]struct{})
// We'll not attempt to route an HTLC of 10 SAT from roasbeef to Son
@ -1385,10 +1385,10 @@ func TestRouteFailMinHTLC(t *testing.T) {
&graphParams{
graph: graph.graph,
},
&restrictParams{
ignoredNodes: ignoredVertexes,
ignoredEdges: ignoredEdges,
feeLimit: noFeeLimit,
&RestrictParams{
IgnoredNodes: ignoredVertexes,
IgnoredEdges: ignoredEdges,
FeeLimit: noFeeLimit,
},
sourceNode, target, payAmt,
)
@ -1438,7 +1438,7 @@ func TestRouteFailMaxHTLC(t *testing.T) {
if err != nil {
t.Fatalf("unable to fetch source node: %v", err)
}
ignoredEdges := make(map[edgeLocator]struct{})
ignoredEdges := make(map[EdgeLocator]struct{})
ignoredVertexes := make(map[Vertex]struct{})
// First, attempt to send a payment greater than the max HTLC we are
@ -1449,10 +1449,10 @@ func TestRouteFailMaxHTLC(t *testing.T) {
&graphParams{
graph: graph.graph,
},
&restrictParams{
ignoredNodes: ignoredVertexes,
ignoredEdges: ignoredEdges,
feeLimit: noFeeLimit,
&RestrictParams{
IgnoredNodes: ignoredVertexes,
IgnoredEdges: ignoredEdges,
FeeLimit: noFeeLimit,
},
sourceNode, target, payAmt,
)
@ -1475,10 +1475,10 @@ func TestRouteFailMaxHTLC(t *testing.T) {
&graphParams{
graph: graph.graph,
},
&restrictParams{
ignoredNodes: ignoredVertexes,
ignoredEdges: ignoredEdges,
feeLimit: noFeeLimit,
&RestrictParams{
IgnoredNodes: ignoredVertexes,
IgnoredEdges: ignoredEdges,
FeeLimit: noFeeLimit,
},
sourceNode, target, payAmt,
)
@ -1505,7 +1505,7 @@ func TestRouteFailDisabledEdge(t *testing.T) {
if err != nil {
t.Fatalf("unable to fetch source node: %v", err)
}
ignoredEdges := make(map[edgeLocator]struct{})
ignoredEdges := make(map[EdgeLocator]struct{})
ignoredVertexes := make(map[Vertex]struct{})
// First, we'll try to route from roasbeef -> sophon. This should
@ -1516,10 +1516,10 @@ func TestRouteFailDisabledEdge(t *testing.T) {
&graphParams{
graph: graph.graph,
},
&restrictParams{
ignoredNodes: ignoredVertexes,
ignoredEdges: ignoredEdges,
feeLimit: noFeeLimit,
&RestrictParams{
IgnoredNodes: ignoredVertexes,
IgnoredEdges: ignoredEdges,
FeeLimit: noFeeLimit,
},
sourceNode, target, payAmt,
)
@ -1548,10 +1548,10 @@ func TestRouteFailDisabledEdge(t *testing.T) {
&graphParams{
graph: graph.graph,
},
&restrictParams{
ignoredNodes: ignoredVertexes,
ignoredEdges: ignoredEdges,
feeLimit: noFeeLimit,
&RestrictParams{
IgnoredNodes: ignoredVertexes,
IgnoredEdges: ignoredEdges,
FeeLimit: noFeeLimit,
},
sourceNode, target, payAmt,
)
@ -1577,10 +1577,10 @@ func TestRouteFailDisabledEdge(t *testing.T) {
&graphParams{
graph: graph.graph,
},
&restrictParams{
ignoredNodes: ignoredVertexes,
ignoredEdges: ignoredEdges,
feeLimit: noFeeLimit,
&RestrictParams{
IgnoredNodes: ignoredVertexes,
IgnoredEdges: ignoredEdges,
FeeLimit: noFeeLimit,
},
sourceNode, target, payAmt,
)
@ -1605,7 +1605,7 @@ func TestPathSourceEdgesBandwidth(t *testing.T) {
if err != nil {
t.Fatalf("unable to fetch source node: %v", err)
}
ignoredEdges := make(map[edgeLocator]struct{})
ignoredEdges := make(map[EdgeLocator]struct{})
ignoredVertexes := make(map[Vertex]struct{})
// First, we'll try to route from roasbeef -> sophon. This should
@ -1617,10 +1617,10 @@ func TestPathSourceEdgesBandwidth(t *testing.T) {
&graphParams{
graph: graph.graph,
},
&restrictParams{
ignoredNodes: ignoredVertexes,
ignoredEdges: ignoredEdges,
feeLimit: noFeeLimit,
&RestrictParams{
IgnoredNodes: ignoredVertexes,
IgnoredEdges: ignoredEdges,
FeeLimit: noFeeLimit,
},
sourceNode, target, payAmt,
)
@ -1645,10 +1645,10 @@ func TestPathSourceEdgesBandwidth(t *testing.T) {
graph: graph.graph,
bandwidthHints: bandwidths,
},
&restrictParams{
ignoredNodes: ignoredVertexes,
ignoredEdges: ignoredEdges,
feeLimit: noFeeLimit,
&RestrictParams{
IgnoredNodes: ignoredVertexes,
IgnoredEdges: ignoredEdges,
FeeLimit: noFeeLimit,
},
sourceNode, target, payAmt,
)
@ -1667,10 +1667,10 @@ func TestPathSourceEdgesBandwidth(t *testing.T) {
graph: graph.graph,
bandwidthHints: bandwidths,
},
&restrictParams{
ignoredNodes: ignoredVertexes,
ignoredEdges: ignoredEdges,
feeLimit: noFeeLimit,
&RestrictParams{
IgnoredNodes: ignoredVertexes,
IgnoredEdges: ignoredEdges,
FeeLimit: noFeeLimit,
},
sourceNode, target, payAmt,
)
@ -1702,10 +1702,10 @@ func TestPathSourceEdgesBandwidth(t *testing.T) {
graph: graph.graph,
bandwidthHints: bandwidths,
},
&restrictParams{
ignoredNodes: ignoredVertexes,
ignoredEdges: ignoredEdges,
feeLimit: noFeeLimit,
&RestrictParams{
IgnoredNodes: ignoredVertexes,
IgnoredEdges: ignoredEdges,
FeeLimit: noFeeLimit,
},
sourceNode, target, payAmt,
)
@ -2022,7 +2022,7 @@ func TestRestrictOutgoingChannel(t *testing.T) {
}
sourceVertex := Vertex(sourceNode.PubKeyBytes)
ignoredEdges := make(map[edgeLocator]struct{})
ignoredEdges := make(map[EdgeLocator]struct{})
ignoredVertexes := make(map[Vertex]struct{})
const (
@ -2040,11 +2040,11 @@ func TestRestrictOutgoingChannel(t *testing.T) {
&graphParams{
graph: testGraphInstance.graph,
},
&restrictParams{
ignoredNodes: ignoredVertexes,
ignoredEdges: ignoredEdges,
feeLimit: noFeeLimit,
outgoingChannelID: &outgoingChannelID,
&RestrictParams{
IgnoredNodes: ignoredVertexes,
IgnoredEdges: ignoredEdges,
FeeLimit: noFeeLimit,
OutgoingChannelID: &outgoingChannelID,
},
sourceNode, target, paymentAmt,
)

View File

@ -27,7 +27,7 @@ type paymentSession struct {
// source of policy related routing failures during this payment attempt.
// We'll use this map to prune out channels when the first error may not
// require pruning, but any subsequent ones do.
errFailedPolicyChans map[edgeLocator]struct{}
errFailedPolicyChans map[EdgeLocator]struct{}
mc *missionControl
@ -61,7 +61,7 @@ func (p *paymentSession) ReportVertexFailure(v Vertex) {
// retrying an edge after its pruning has expired.
//
// TODO(roasbeef): also add value attempted to send and capacity of channel
func (p *paymentSession) ReportEdgeFailure(e *edgeLocator) {
func (p *paymentSession) ReportEdgeFailure(e *EdgeLocator) {
log.Debugf("Reporting edge %v failure to Mission Control", e)
// First, we'll add the failed edge to our local prune view snapshot.
@ -82,7 +82,7 @@ func (p *paymentSession) ReportEdgeFailure(e *edgeLocator) {
// pruned. This is to prevent nodes from keeping us busy by continuously sending
// new channel updates.
func (p *paymentSession) ReportEdgePolicyFailure(
errSource Vertex, failedEdge *edgeLocator) {
errSource Vertex, failedEdge *EdgeLocator) {
// Check to see if we've already reported a policy related failure for
// this channel. If so, then we'll prune out the vertex.
@ -147,11 +147,11 @@ func (p *paymentSession) RequestRoute(payment *LightningPayment,
additionalEdges: p.additionalEdges,
bandwidthHints: p.bandwidthHints,
},
&restrictParams{
ignoredNodes: pruneView.vertexes,
ignoredEdges: pruneView.edges,
feeLimit: payment.FeeLimit,
outgoingChannelID: payment.OutgoingChannelID,
&RestrictParams{
IgnoredNodes: pruneView.vertexes,
IgnoredEdges: pruneView.edges,
FeeLimit: payment.FeeLimit,
OutgoingChannelID: payment.OutgoingChannelID,
},
p.mc.selfNode, payment.Target, payment.Amount,
)

View File

@ -215,18 +215,20 @@ func newRouteTuple(amt lnwire.MilliSatoshi, dest []byte) routeTuple {
return r
}
// edgeLocator is a struct used to identify a specific edge. The direction
// fields takes the value of 0 or 1 and is identical in definition to the
// channel direction flag. A value of 0 means the direction from the lower node
// pubkey to the higher.
type edgeLocator struct {
channelID uint64
direction uint8
// EdgeLocator is a struct used to identify a specific edge.
type EdgeLocator struct {
// ChannelID is the channel of this edge.
ChannelID uint64
// Direction takes the value of 0 or 1 and is identical in definition to
// the channel direction flag. A value of 0 means the direction from the
// lower node pubkey to the higher.
Direction uint8
}
// newEdgeLocatorByPubkeys returns an edgeLocator based on its end point
// pubkeys.
func newEdgeLocatorByPubkeys(channelID uint64, fromNode, toNode *Vertex) *edgeLocator {
func newEdgeLocatorByPubkeys(channelID uint64, fromNode, toNode *Vertex) *EdgeLocator {
// Determine direction based on lexicographical ordering of both
// pubkeys.
var direction uint8
@ -234,24 +236,24 @@ func newEdgeLocatorByPubkeys(channelID uint64, fromNode, toNode *Vertex) *edgeLo
direction = 1
}
return &edgeLocator{
channelID: channelID,
direction: direction,
return &EdgeLocator{
ChannelID: channelID,
Direction: direction,
}
}
// newEdgeLocator extracts an edgeLocator based for a full edge policy
// structure.
func newEdgeLocator(edge *channeldb.ChannelEdgePolicy) *edgeLocator {
return &edgeLocator{
channelID: edge.ChannelID,
direction: uint8(edge.ChannelFlags & lnwire.ChanUpdateDirection),
func newEdgeLocator(edge *channeldb.ChannelEdgePolicy) *EdgeLocator {
return &EdgeLocator{
ChannelID: edge.ChannelID,
Direction: uint8(edge.ChannelFlags & lnwire.ChanUpdateDirection),
}
}
// String returns a human readable version of the edgeLocator values.
func (e *edgeLocator) String() string {
return fmt.Sprintf("%v:%v", e.channelID, e.direction)
func (e *EdgeLocator) String() string {
return fmt.Sprintf("%v:%v", e.ChannelID, e.Direction)
}
// ChannelRouter is the layer 3 router within the Lightning stack. Below the
@ -1275,7 +1277,7 @@ func pathsToFeeSortedRoutes(source Vertex, paths [][]*channeldb.ChannelEdgePolic
// hop in the path as it contains a "self-hop" that is inserted
// by our KSP algorithm.
route, err := newRoute(
amt, source, path[1:], currentHeight, finalCLTVDelta,
amt, source, path[1:], currentHeight, finalCLTVDelta,
)
if err != nil {
// TODO(roasbeef): report straw breaking edge?
@ -1411,7 +1413,7 @@ func (r *ChannelRouter) FindRoutes(target *btcec.PublicKey,
// factored in.
sourceVertex := Vertex(r.selfNode.PubKeyBytes)
validRoutes, err := pathsToFeeSortedRoutes(
sourceVertex, shortestPaths, finalCLTVDelta, amt,
sourceVertex, shortestPaths, finalCLTVDelta, amt,
uint32(currentHeight),
)
if err != nil {
@ -1972,13 +1974,13 @@ func (r *ChannelRouter) processSendError(paySession *paymentSession,
// we'll prune the channel in both directions and
// continue with the rest of the routes.
case *lnwire.FailPermanentChannelFailure:
paySession.ReportEdgeFailure(&edgeLocator{
channelID: failedEdge.channelID,
direction: 0,
paySession.ReportEdgeFailure(&EdgeLocator{
ChannelID: failedEdge.ChannelID,
Direction: 0,
})
paySession.ReportEdgeFailure(&edgeLocator{
channelID: failedEdge.channelID,
direction: 1,
paySession.ReportEdgeFailure(&EdgeLocator{
ChannelID: failedEdge.ChannelID,
Direction: 1,
})
return false
@ -1991,7 +1993,7 @@ func (r *ChannelRouter) processSendError(paySession *paymentSession,
// pubkey of the node that sent the error. It will assume that the error is
// associated with the outgoing channel of the error node.
func getFailedEdge(route *Route, errSource Vertex) (
*edgeLocator, error) {
*EdgeLocator, error) {
hopCount := len(route.Hops)
fromNode := route.SourcePubKey

View File

@ -1950,7 +1950,7 @@ func TestFindPathFeeWeighting(t *testing.T) {
}
ignoreVertex := make(map[Vertex]struct{})
ignoreEdge := make(map[edgeLocator]struct{})
ignoreEdge := make(map[EdgeLocator]struct{})
amt := lnwire.MilliSatoshi(100)
@ -1966,10 +1966,10 @@ func TestFindPathFeeWeighting(t *testing.T) {
&graphParams{
graph: ctx.graph,
},
&restrictParams{
ignoredNodes: ignoreVertex,
ignoredEdges: ignoreEdge,
feeLimit: noFeeLimit,
&RestrictParams{
IgnoredNodes: ignoreVertex,
IgnoredEdges: ignoreEdge,
FeeLimit: noFeeLimit,
},
sourceNode, target, amt,
)