Skip to content

Commit

Permalink
Reuse evaluated variables
Browse files Browse the repository at this point in the history
Signed-off-by: bcmmbaga <[email protected]>
  • Loading branch information
bcmmbaga committed Dec 20, 2024
1 parent bb882c8 commit 4f8f293
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions management/server/types/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -1309,10 +1309,12 @@ func (a *Account) GetNetworkResourcesRoutesToSync(ctx context.Context, peerID st
var allSourcePeers []string

for _, resource := range a.NetworkResources {
var addSourcePeers bool

networkRoutingPeers, exists := routers[resource.NetworkID]
if exists {
if router, ok := networkRoutingPeers[peerID]; ok {
isRoutingPeer = true
isRoutingPeer, addSourcePeers = true, true
routes = append(routes, a.getNetworkResourcesRoutes(resource, peerID, router, resourcePolicies)...)
}
}
Expand All @@ -1326,13 +1328,13 @@ func (a *Account) GetNetworkResourcesRoutesToSync(ctx context.Context, peerID st
}

// routing peer should be able to connect with all source peers
if _, ok := networkRoutingPeers[peerID]; ok {
if addSourcePeers {
allSourcePeers = append(allSourcePeers, group.Peers...)
}

// add routes for the resource if the peer is in the distribution group
if slices.Contains(group.Peers, peerID) {
for peerId, router := range routers[resource.NetworkID] {
for peerId, router := range networkRoutingPeers {
routes = append(routes, a.getNetworkResourcesRoutes(resource, peerId, router, resourcePolicies)...)
}
}
Expand Down

0 comments on commit 4f8f293

Please sign in to comment.