Update admin socket response sorting

This commit is contained in:
Neil Alexander 2024-09-23 22:40:52 +01:00
parent e138fa679c
commit b8ab843a98
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
4 changed files with 30 additions and 20 deletions

View file

@ -3,7 +3,7 @@ package admin
import (
"encoding/hex"
"net"
"sort"
"slices"
"strings"
"github.com/yggdrasil-network/yggdrasil-go/src/address"
@ -34,8 +34,8 @@ func (a *AdminSocket) getTreeHandler(_ *GetTreeRequest, res *GetTreeResponse) er
Sequence: d.Sequence,
})
}
sort.SliceStable(res.Tree, func(i, j int) bool {
return strings.Compare(res.Tree[i].PublicKey, res.Tree[j].PublicKey) < 0
slices.SortStableFunc(res.Tree, func(a, b TreeEntry) int {
return strings.Compare(a.PublicKey, b.PublicKey)
})
return nil
}