From afcbc4407c31fb21ddb0b9b6dfcee19a3aba68ad Mon Sep 17 00:00:00 2001 From: dragon Date: Mon, 7 May 2018 12:01:32 +0800 Subject: [PATCH] fix a bug about updating candidacy. --- modules/stake/handler.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/modules/stake/handler.go b/modules/stake/handler.go index 70485fa1..a8b13d5b 100644 --- a/modules/stake/handler.go +++ b/modules/stake/handler.go @@ -247,17 +247,19 @@ func (c check) updateCandidacy(tx TxUpdateCandidacy) error { return ErrBadAmount() } - y := big.NewInt(int64(c.params.ReserveRequirementRatio)) - rr.Mul(x, y) - rr.Div(rr, big.NewInt(100)) - - balance, err := commons.GetBalance(c.ethereum, c.sender) - if err != nil { - return err - } + if candidate.MaxShares.Cmp(x) != 0 { + y := big.NewInt(int64(c.params.ReserveRequirementRatio)) + rr.Mul(x, y) + rr.Div(rr, big.NewInt(100)) + + balance, err := commons.GetBalance(c.ethereum, c.sender) + if err != nil { + return err + } - if balance.Cmp(rr) < 0 { - return ErrInsufficientFunds() + if balance.Cmp(rr) < 0 { + return ErrInsufficientFunds() + } } }