From e1d32906f77f23f5de19961c40f4b25114632fdd Mon Sep 17 00:00:00 2001 From: Yarom Swisa Date: Wed, 16 Aug 2023 21:36:41 +0000 Subject: [PATCH] fix the chain! --- utils/rand/rand.go | 4 +--- x/pairing/keeper/scores/score.go | 8 +++++++- x/plans/types/geolocation.go | 3 +++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/utils/rand/rand.go b/utils/rand/rand.go index 271c6b902e..2d88cfe2e4 100644 --- a/utils/rand/rand.go +++ b/utils/rand/rand.go @@ -4,8 +4,6 @@ import ( "crypto/sha256" "encoding/binary" "math/rand" - - "github.com/vpxyz/xorshift/xoroshiro128starstar" ) func generateSeed(data []byte) int64 { @@ -17,7 +15,7 @@ func generateSeed(data []byte) int64 { // New returns a new RPNG instance properly seeded func New(data []byte) *rand.Rand { seed := generateSeed(data) - source := xoroshiro128starstar.NewSource(seed) + source := rand.NewSource(seed) return rand.New(source) } diff --git a/x/pairing/keeper/scores/score.go b/x/pairing/keeper/scores/score.go index 49c692f723..1e7454b87a 100644 --- a/x/pairing/keeper/scores/score.go +++ b/x/pairing/keeper/scores/score.go @@ -129,8 +129,14 @@ func GetStrategy() ScoreStrategy { // and the previous slot func CalcPairingScore(scores []*PairingScore, strategy ScoreStrategy, diffSlot *PairingSlot) error { // calculate the score for each req for each provider + keys := []string{} + for key, _ := range diffSlot.Reqs { + keys = append(keys, key) + } + for _, score := range scores { - for _, req := range diffSlot.Reqs { + for _, key := range keys { + req := diffSlot.Reqs[key] reqName := req.GetName() weight, ok := strategy[reqName] if !ok { diff --git a/x/plans/types/geolocation.go b/x/plans/types/geolocation.go index f0765d29bd..c15d316f3e 100644 --- a/x/plans/types/geolocation.go +++ b/x/plans/types/geolocation.go @@ -23,6 +23,9 @@ func init() { allGeoEnumRegions |= geoloc } } + sort.Slice(allGeoEnumRegionsList, func(i, j int) bool { + return allGeoEnumRegionsList[i] < allGeoEnumRegionsList[j] + }) } // IsValidGeoEnum tests the validity of a given geolocation