OSDN Git Service

Handle the abnormal exit situation
authormars <mars@bytom.io>
Mon, 25 Mar 2019 09:18:39 +0000 (17:18 +0800)
committermars <mars@bytom.io>
Mon, 25 Mar 2019 09:18:39 +0000 (17:18 +0800)
consensus/consensus/dpos/vote.go
protocol/block.go

index 1fa7e80..405d235 100644 (file)
@@ -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)
index f629b8f..3a8dcee 100644 (file)
@@ -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