OSDN Git Service
(root)
/
bytom
/
vapor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix no table (#394)
[bytom/vapor.git]
/
toolbar
/
vote_reward
/
synchron
/
block_keeper.go
diff --git
a/toolbar/vote_reward/synchron/block_keeper.go
b/toolbar/vote_reward/synchron/block_keeper.go
index
9903480
..
368cb44
100644
(file)
--- a/
toolbar/vote_reward/synchron/block_keeper.go
+++ b/
toolbar/vote_reward/synchron/block_keeper.go
@@
-84,7
+84,12
@@
func (c *ChainKeeper) syncChainStatus(db *gorm.DB, chainStatus *orm.ChainStatus)
return err
}
return err
}
- return c.DetachBlock(db, chainStatus, currentBlock)
+ preBlock, err := c.node.GetBlockByHash(currentBlock.PreviousBlockHash.String())
+ if err != nil {
+ return err
+ }
+
+ return c.DetachBlock(db, chainStatus, preBlock)
}
func (c *ChainKeeper) AttachBlock(db *gorm.DB, chainStatus *orm.ChainStatus, block *types.Block) error {
}
func (c *ChainKeeper) AttachBlock(db *gorm.DB, chainStatus *orm.ChainStatus, block *types.Block) error {
@@
-131,11
+136,11
@@
func (c *ChainKeeper) AttachBlock(db *gorm.DB, chainStatus *orm.ChainStatus, blo
}
func (c *ChainKeeper) DetachBlock(db *gorm.DB, chainStatus *orm.ChainStatus, block *types.Block) error {
}
func (c *ChainKeeper) DetachBlock(db *gorm.DB, chainStatus *orm.ChainStatus, block *types.Block) error {
- if err := db.Where(&orm.Utxo{VoteHeight:
block.
Height}).Delete(&orm.Utxo{}).Error; err != nil {
+ if err := db.Where(&orm.Utxo{VoteHeight:
chainStatus.Block
Height}).Delete(&orm.Utxo{}).Error; err != nil {
return err
}
return err
}
- if err := db.
Where(&orm.Utxo{VetoHeight: block.
Height}).Update("veto_height", 0).Error; err != nil {
+ if err := db.
Model(&orm.Utxo{}).Where(&orm.Utxo{VetoHeight: chainStatus.Block
Height}).Update("veto_height", 0).Error; err != nil {
return err
}
return err
}