Skip to content

Commit

Permalink
Temporary fix for division by zero
Browse files Browse the repository at this point in the history
  • Loading branch information
danil-lashin committed Oct 4, 2018
1 parent 978fdfa commit e1361f9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 0.4.3
*Oct 4th, 2018*

BUG FIXES

- [core] Fix division by zero

## 0.4.2
*Sept 21th, 2018*

Expand Down
4 changes: 4 additions & 0 deletions core/state/state_candidate.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ func (s *Stake) CalcBipValue(context *StateDB) *big.Int {

data := context.stakeCache[s.Coin]

if data.TotalValue.Cmp(types.Big0) == 0 {
return big.NewInt(0)
}

value := big.NewInt(0).Set(data.BipValue)
value.Mul(value, s.Value)
value.Div(value, data.TotalValue)
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 = "4"
Fix = "2"
Fix = "3"
)

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

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

0 comments on commit e1361f9

Please sign in to comment.