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
|
||||
|
||||
// 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
|
||||
|
||||
haveRoutes bool
|
||||
@ -239,6 +245,7 @@ func (m *missionControl) NewPaymentSession(routeHints [][]HopHint,
|
||||
pruneViewSnapshot: viewSnapshot,
|
||||
additionalEdges: edges,
|
||||
bandwidthHints: bandwidthHints,
|
||||
errFailedPolicyChans: make(map[uint64]struct{}),
|
||||
mc: m,
|
||||
}, nil
|
||||
}
|
||||
@ -252,6 +259,7 @@ func (m *missionControl) NewPaymentSessionFromRoutes(routes []*Route) *paymentSe
|
||||
pruneViewSnapshot: m.GraphPruneView(),
|
||||
haveRoutes: true,
|
||||
preBuiltRoutes: routes,
|
||||
errFailedPolicyChans: make(map[uint64]struct{}),
|
||||
mc: m,
|
||||
}
|
||||
}
|
||||
|
@ -1641,12 +1641,6 @@ func (r *ChannelRouter) sendPayment(payment *LightningPayment,
|
||||
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
|
||||
// calculate the required HTLC time locks within the route.
|
||||
_, currentHeight, err := r.cfg.Chain.GetBestBlock()
|
||||
@ -1845,8 +1839,8 @@ func (r *ChannelRouter) sendPayment(payment *LightningPayment,
|
||||
// reported a fee related failure for this
|
||||
// node. If so, then we'll actually prune out
|
||||
// the vertex for now.
|
||||
chanID := update.ShortChannelID
|
||||
_, ok := errFailedFeeChans[chanID]
|
||||
chanID := update.ShortChannelID.ToUint64()
|
||||
_, ok := paySession.errFailedPolicyChans[chanID]
|
||||
if ok {
|
||||
paySession.ReportVertexFailure(errVertex)
|
||||
continue
|
||||
@ -1854,7 +1848,7 @@ func (r *ChannelRouter) sendPayment(payment *LightningPayment,
|
||||
|
||||
// Finally, we'll record a fee failure from
|
||||
// this node and move on.
|
||||
errFailedFeeChans[chanID] = struct{}{}
|
||||
paySession.errFailedPolicyChans[chanID] = struct{}{}
|
||||
continue
|
||||
|
||||
// If we get the failure for an intermediate node that
|
||||
|
Loading…
Reference in New Issue
Block a user