Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Commit

Permalink
fix hard code in algo 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Benzbeeb committed May 4, 2020
1 parent eee3eb5 commit 4e2629d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions chain/random/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ func luckyDraw(seed []byte, vals Validators, randomRange int64) (Validator, Vali
return luckyVal, vals
}

func getRandomRange(vals Validators, round, algo int) int64 {
func getRandomRange(vals Validators, round, amount, algo int) int64 {
var randomRange int64
switch algo {
case 0:
randomRange = int64(len(vals.ValidatorSet) - 10*round)
randomRange = int64(len(vals.ValidatorSet) - len(vals.ValidatorSet)*round/amount)
if randomRange < 0 {
randomRange = 0
}
Expand All @@ -73,7 +73,7 @@ func randomValidators(seed []byte, vals Validators, amount int, algo int) Valida
var val Validator
for round := 0; round < amount; round++ {
seed = nextSeed(seed)
randomRange := getRandomRange(vals, round, algo)
randomRange := getRandomRange(vals, round, amount, algo)
val, vals = luckyDraw(seed, vals, randomRange)
luckyVal.ValidatorSet = append(luckyVal.ValidatorSet, val)
}
Expand Down

0 comments on commit 4e2629d

Please sign in to comment.