Skip to content

Commit

Permalink
fix: apply comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Woosang Son committed May 16, 2020
1 parent 4372cb6 commit aba9ce3
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 17 deletions.
1 change: 0 additions & 1 deletion libs/rand/sampling.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ type Candidate interface {
Priority() uint64
LessThan(other Candidate) bool
IncreaseWin()
MultiplyWin(times float64) uint64
}

const uint64Mask = uint64(0x7FFFFFFFFFFFFFFF)
Expand Down
5 changes: 0 additions & 5 deletions libs/rand/sampling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ func (e *Element) IncreaseWin() {
e.Win++
}

func (e *Element) MultiplyWin(times float64) uint64 {
e.Win = uint64(float64(e.Win) * times)
return e.Win
}

func TestRandomSamplingWithPriority(t *testing.T) {
candidates := newCandidates(100, func(i int) uint64 { return uint64(i) })

Expand Down
14 changes: 3 additions & 11 deletions types/voter_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type VoterSet struct {
}

func NewVoterSet(valz []*Validator) *VoterSet {
sort.Sort(ValidatorsByAddress(valz))
vals := &VoterSet{Voters: copyValidatorListShallow(valz), totalVotingPower: 0}
vals.updateTotalVotingPower()
return vals
Expand Down Expand Up @@ -415,16 +416,12 @@ func SelectVoter(validators *ValidatorSet, proofHash []byte) *VoterSet {
index++
}
}
result := &VoterSet{Voters: vals, totalVotingPower: 0}
result.updateTotalVotingPower()
return result
return NewVoterSet(vals)
}

// This should be used in only test
func ToVoterAll(validators *ValidatorSet) *VoterSet {
result := &VoterSet{Voters: copyValidatorListShallow(validators.Validators), totalVotingPower: 0}
result.updateTotalVotingPower()
return result
return NewVoterSet(validators.Validators)
}

// candidate save simple validator data for selecting proposer
Expand Down Expand Up @@ -454,11 +451,6 @@ func (c *candidate) IncreaseWin() {
c.win++
}

func (c *candidate) MultiplyWin(times float64) uint64 {
c.win = uint64(float64(c.win) * times)
return c.win
}

func hashToSeed(hash []byte) uint64 {
for len(hash) < 8 {
hash = append(hash, byte(0))
Expand Down

0 comments on commit aba9ce3

Please sign in to comment.