Skip to content

Commit

Permalink
Merge pull request #86 from MinterTeam/dev
Browse files Browse the repository at this point in the history
0.2.1
  • Loading branch information
danil-lashin authored Aug 23, 2018
2 parents 448914a + e5fb666 commit 3b7c49e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@

- [api] Add validators rewards to block api

## 0.2.1
*Aug 23th, 2018*

In this update we well test blockchain's hardfork.
There is no need to wipe old data, just be sure to update binary
until 15000 block.

BUG FIXES

- [validators] Fix validators issue

## 0.2.0
*Aug 22th, 2018*

Expand Down
6 changes: 3 additions & 3 deletions core/minter/minter.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,13 @@ func (app *Blockchain) EndBlock(req abciTypes.RequestEndBlock) abciTypes.Respons

valsCount := validators.GetValidatorsCountForBlock(app.height)

newCandidates := app.stateDeliver.GetCandidates(valsCount)
newCandidates := app.stateDeliver.GetCandidates(valsCount, req.Height)

if len(newCandidates) < valsCount {
valsCount = len(newCandidates)
}

newValidators := make([]abciTypes.Validator, valsCount)
var newValidators []abciTypes.Validator

// calculate total power
totalPower := big.NewInt(0)
Expand All @@ -208,7 +208,7 @@ func (app *Blockchain) EndBlock(req abciTypes.RequestEndBlock) abciTypes.Respons
power = 1
}

newValidators[i] = abciTypes.Ed25519Validator(newCandidates[i].PubKey, power)
newValidators = append(newValidators, abciTypes.Ed25519Validator(newCandidates[i].PubKey, power))
}

// update validators in state
Expand Down
11 changes: 10 additions & 1 deletion core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ func (s *StateDB) SubCoinReserve(symbol types.CoinSymbol, value *big.Int) {
}
}

func (s *StateDB) GetCandidates(count int) []Candidate {
func (s *StateDB) GetCandidates(count int, block int64) []Candidate {
stateCandidates := s.getStateCandidates()

if stateCandidates == nil {
Expand All @@ -773,6 +773,15 @@ func (s *StateDB) GetCandidates(count int) []Candidate {
count = len(activeCandidates)
}

// TODO: remove condition in next testnet
if block >= 15000 {
sort.Slice(activeCandidates, func(i, j int) bool {
return activeCandidates[i].TotalBipStake.Cmp(activeCandidates[j].TotalBipStake) == -1
})

activeCandidates = activeCandidates[:count]
}

return activeCandidates
}

Expand Down
4 changes: 2 additions & 2 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ package version
const (
Maj = "0"
Min = "2"
Fix = "0"
Fix = "1"
)

var (
// Must be a string because scripts like dist.sh read this file.
Version = "0.2.0"
Version = "0.2.1"

// GitCommit is the current HEAD set using ldflags.
GitCommit string
Expand Down

0 comments on commit 3b7c49e

Please sign in to comment.