state: return a node's primary routes in stable order

They came from map iteration, so an unchanged router rendered its self
node differently on every call.

Updates #3502
This commit is contained in:
Kristoffer Dalby authored and Kristoffer Dalby committed 2026-10-07 23:36:16 +02:00
1 parent 31582dd2c2
commit ba413fca3d
2 files changed
+25 -1

No files matched your search

+3 -1
View File
@@ -986,7 +986,7 @@ func (s *NodeStore) PrimaryRouteFor(prefix netip.Prefix) (types.NodeID, bool) {
}
// PrimaryRoutesForNode returns the prefixes for which id is the current
// primary advertiser.
// primary advertiser, sorted so an unchanged node renders identically.
func (s *NodeStore) PrimaryRoutesForNode(id types.NodeID) []netip.Prefix {
snap := s.data.Load()
if !snap.isPrimaryRoute[id] {
@@ -1001,6 +1001,8 @@ func (s *NodeStore) PrimaryRoutesForNode(id types.NodeID) []netip.Prefix {
}
}
slices.SortFunc(out, netip.Prefix.Compare)
return out
}