routing: move failed channels map into payment session
This is a small preparatory step towards moving mission control logic out of router and reusing the acquired routing result data.
This commit is contained in:
parent
ac04729cff
commit
6ba1144528
@ -164,6 +164,12 @@ type paymentSession struct {
|
|||||||
|
|
||||||
bandwidthHints map[uint64]lnwire.MilliSatoshi
|
bandwidthHints map[uint64]lnwire.MilliSatoshi
|
||||||
|
|
||||||
|
// errFailedFeeChans is a map of the short channel ID's that were the
|
||||||
|
// 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[uint64]struct{}
|
||||||
|
|
||||||
mc *missionControl
|
mc *missionControl
|
||||||
|
|
||||||
haveRoutes bool
|
haveRoutes bool
|
||||||
@ -236,10 +242,11 @@ func (m *missionControl) NewPaymentSession(routeHints [][]HopHint,
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &paymentSession{
|
return &paymentSession{
|
||||||
pruneViewSnapshot: viewSnapshot,
|
pruneViewSnapshot: viewSnapshot,
|
||||||
additionalEdges: edges,
|
additionalEdges: edges,
|
||||||
bandwidthHints: bandwidthHints,
|
bandwidthHints: bandwidthHints,
|
||||||
mc: m,
|
errFailedPolicyChans: make(map[uint64]struct{}),
|
||||||
|
mc: m,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,10 +256,11 @@ func (m *missionControl) NewPaymentSession(routeHints [][]HopHint,
|
|||||||
// used for things like channel rebalancing, and swaps.
|
// used for things like channel rebalancing, and swaps.
|
||||||
func (m *missionControl) NewPaymentSessionFromRoutes(routes []*Route) *paymentSession {
|
func (m *missionControl) NewPaymentSessionFromRoutes(routes []*Route) *paymentSession {
|
||||||
return &paymentSession{
|
return &paymentSession{
|
||||||
pruneViewSnapshot: m.GraphPruneView(),
|
pruneViewSnapshot: m.GraphPruneView(),
|
||||||
haveRoutes: true,
|
haveRoutes: true,
|
||||||
preBuiltRoutes: routes,
|
preBuiltRoutes: routes,
|
||||||
mc: m,
|
errFailedPolicyChans: make(map[uint64]struct{}),
|
||||||
|
mc: m,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1641,12 +1641,6 @@ func (r *ChannelRouter) sendPayment(payment *LightningPayment,
|
|||||||
sendError error
|
sendError error
|
||||||
)
|
)
|
||||||
|
|
||||||
// errFailedFeeChans is a map of the short channel ID's that were the
|
|
||||||
// source of fee 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.
|
|
||||||
errFailedFeeChans := make(map[lnwire.ShortChannelID]struct{})
|
|
||||||
|
|
||||||
// We'll also fetch the current block height so we can properly
|
// We'll also fetch the current block height so we can properly
|
||||||
// calculate the required HTLC time locks within the route.
|
// calculate the required HTLC time locks within the route.
|
||||||
_, currentHeight, err := r.cfg.Chain.GetBestBlock()
|
_, currentHeight, err := r.cfg.Chain.GetBestBlock()
|
||||||
@ -1845,8 +1839,8 @@ func (r *ChannelRouter) sendPayment(payment *LightningPayment,
|
|||||||
// reported a fee related failure for this
|
// reported a fee related failure for this
|
||||||
// node. If so, then we'll actually prune out
|
// node. If so, then we'll actually prune out
|
||||||
// the vertex for now.
|
// the vertex for now.
|
||||||
chanID := update.ShortChannelID
|
chanID := update.ShortChannelID.ToUint64()
|
||||||
_, ok := errFailedFeeChans[chanID]
|
_, ok := paySession.errFailedPolicyChans[chanID]
|
||||||
if ok {
|
if ok {
|
||||||
paySession.ReportVertexFailure(errVertex)
|
paySession.ReportVertexFailure(errVertex)
|
||||||
continue
|
continue
|
||||||
@ -1854,7 +1848,7 @@ func (r *ChannelRouter) sendPayment(payment *LightningPayment,
|
|||||||
|
|
||||||
// Finally, we'll record a fee failure from
|
// Finally, we'll record a fee failure from
|
||||||
// this node and move on.
|
// this node and move on.
|
||||||
errFailedFeeChans[chanID] = struct{}{}
|
paySession.errFailedPolicyChans[chanID] = struct{}{}
|
||||||
continue
|
continue
|
||||||
|
|
||||||
// If we get the failure for an intermediate node that
|
// If we get the failure for an intermediate node that
|
||||||
|
Loading…
Reference in New Issue
Block a user