-
Notifications
You must be signed in to change notification settings - Fork 246
fix(network): IPv6 addresses sorting was using wrong references #997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
61c2fa4
86be6df
8a76a70
ad4f7c0
4edf753
7f8b0b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,17 +42,19 @@ func sortAndCompareStringSlices(a, b []string) bool { | |
| return true | ||
| } | ||
|
|
||
| func sortIPv6AddressSlicesStable(a []types.IPv6Address) { | ||
| sort.SliceStable(a, func(i, j int) bool { | ||
| return a[i].Address.String() < a[j].Address.String() | ||
| }) | ||
| } | ||
|
|
||
| func sortAndCompareIPv6AddressSlices(a, b []types.IPv6Address) bool { | ||
| if len(a) != len(b) { | ||
| return false | ||
| } | ||
|
|
||
| sort.SliceStable(a, func(i, j int) bool { | ||
| return a[i].Address.String() < b[j].Address.String() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... so should have been |
||
| }) | ||
| sort.SliceStable(b, func(i, j int) bool { | ||
| return b[i].Address.String() < a[j].Address.String() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... so should have been |
||
| }) | ||
| sortIPv6AddressSlicesStable(a) | ||
| sortIPv6AddressSlicesStable(b) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry I didn't notice this error :( |
||
|
|
||
| for i := range a { | ||
| if a[i].Address.String() != b[i].Address.String() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When multiple state changes occur in the same update cycle, only the last change reason will be preserved and logged. For example, if both IPv4 and IPv6 addresses change, only "IPv6 addresses changed" will be logged. Consider accumulating all change reasons (e.g., using a slice) or logging each change individually to aid in debugging.