From: mars Date: Mon, 25 Mar 2019 09:18:39 +0000 (+0800) Subject: Handle the abnormal exit situation X-Git-Tag: v1.0.5~218^2 X-Git-Url: http://git.osdn.net/view?p=bytom%2Fvapor.git;a=commitdiff_plain;h=6228102ebf8ffa17faa622662355d7c2dcdc147f;hp=-c Handle the abnormal exit situation --- 6228102ebf8ffa17faa622662355d7c2dcdc147f diff --git a/consensus/consensus/dpos/vote.go b/consensus/consensus/dpos/vote.go index 1fa7e806..405d235b 100644 --- a/consensus/consensus/dpos/vote.go +++ b/consensus/consensus/dpos/vote.go @@ -462,7 +462,7 @@ func (v *Vote) updateAddressBalance(address string, value int64) { if val, ok := v.AddressBalances[address]; ok { banlance := int64(val) + value if banlance < 0 { - cmn.Exit("The balance was negative") + cmn.Exit(fmt.Sprintf("The balance was negative: %s: %d", address, value)) } if banlance == 0 { delete(v.AddressBalances, address) @@ -471,7 +471,7 @@ func (v *Vote) updateAddressBalance(address string, value int64) { } } else { if value < 0 { - cmn.Exit("The balance was negative") + cmn.Exit(fmt.Sprintf("The balance was negative: %s: %d", address, value)) } if value > 0 { v.AddressBalances[address] = uint64(value) diff --git a/protocol/block.go b/protocol/block.go index f629b8f2..3a8dceed 100644 --- a/protocol/block.go +++ b/protocol/block.go @@ -415,7 +415,7 @@ func (c *Chain) RepairDPoSData(oldBlockHeight uint64, oldBlockHash bc.Hash) erro if block.Height != oldBlockHeight { return errors.New("The module vote records data with a problem") } - for i := block.Height + 1; i < c.bestNode.Height; i++ { + for i := block.Height + 1; i <= c.bestNode.Height; i++ { b, err := c.GetBlockByHeight(i) if err != nil { return err