Fix removal of maps.Keys in go1.21rc4
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
DataHoarder 2023-08-02 20:54:13 +02:00
parent 73194bd79f
commit 6ba8959a8a
Signed by: DataHoarder
SSH key fingerprint: SHA256:OLTRf6Fl87G52SiR7sWLGNzlJt4WOX+tfI2yxo0z7xk
3 changed files with 11 additions and 4 deletions

View file

@ -21,7 +21,6 @@ import (
"github.com/gorilla/mux"
"io"
"log"
"maps"
"math"
"net/http"
_ "net/http/pprof"
@ -1556,7 +1555,7 @@ func main() {
}
}
sortedAddresses := maps.Keys(addresses)
sortedAddresses := utils.Keys(addresses)
//Sort based on addresses
slices.SortFunc(sortedAddresses, func(a address.PackedAddress, b address.PackedAddress) int {

View file

@ -18,7 +18,6 @@ import (
"github.com/valyala/quicktemplate"
"io"
"log"
"maps"
"math"
"net/http"
_ "net/http/pprof"
@ -722,7 +721,7 @@ func main() {
}
}
minerKeys := maps.Keys(miners)
minerKeys := utils.Keys(miners)
slices.SortFunc(minerKeys, func(a uint64, b uint64) int {
return miners[a].Weight.Cmp(miners[b].Weight) * -1
})

9
utils/maps.go Normal file
View file

@ -0,0 +1,9 @@
package utils
func Keys[M ~map[K]V, K comparable, V any](m M) []K {
r := make([]K, 0, len(m))
for k := range m {
r = append(r, k)
}
return r
}