OSDN Git Service

fix fix_no_table
authorwz <mars@bytom.io>
Fri, 30 Aug 2019 02:17:58 +0000 (10:17 +0800)
committerwz <mars@bytom.io>
Fri, 30 Aug 2019 02:17:58 +0000 (10:17 +0800)
toolbar/vote_reward/synchron/block_keeper.go

index afcba27..368cb44 100644 (file)
@@ -79,7 +79,12 @@ func (c *ChainKeeper) syncChainStatus(db *gorm.DB, chainStatus *orm.ChainStatus)
        }
 
        log.WithField("block height", chainStatus.BlockHeight).Debug("the prev hash of remote is not equals the hash of current best block, must rollback")
-       preBlock, err := c.node.GetBlockByHeight(chainStatus.BlockHeight - 1)
+       currentBlock, err := c.node.GetBlockByHash(chainStatus.BlockHash)
+       if err != nil {
+               return err
+       }
+
+       preBlock, err := c.node.GetBlockByHash(currentBlock.PreviousBlockHash.String())
        if err != nil {
                return err
        }