routing+routerrpc: add multiple outgoing channel restriction

This commit is contained in:
Joost Jager
2020-05-07 11:48:39 +02:00
parent 53e4876a1d
commit c33d94ff27
11 changed files with 287 additions and 214 deletions

View File

@@ -21,13 +21,13 @@ type unifiedPolicies struct {
// outChanRestr is an optional outgoing channel restriction for the
// local channel to use.
outChanRestr *uint64
outChanRestr map[uint64]struct{}
}
// newUnifiedPolicies instantiates a new unifiedPolicies object. Channel
// policies can be added to this object.
func newUnifiedPolicies(sourceNode, toNode route.Vertex,
outChanRestr *uint64) *unifiedPolicies {
outChanRestr map[uint64]struct{}) *unifiedPolicies {
return &unifiedPolicies{
policies: make(map[route.Vertex]*unifiedPolicy),
@@ -45,10 +45,10 @@ func (u *unifiedPolicies) addPolicy(fromNode route.Vertex,
localChan := fromNode == u.sourceNode
// Skip channels if there is an outgoing channel restriction.
if localChan && u.outChanRestr != nil &&
*u.outChanRestr != edge.ChannelID {
return
if localChan && u.outChanRestr != nil {
if _, ok := u.outChanRestr[edge.ChannelID]; !ok {
return
}
}
// Update the policies map.