Skip to content

Commit

Permalink
Merge pull request #163 from vitelabs/hotfix-master
Browse files Browse the repository at this point in the history
Hotfix master
  • Loading branch information
lyd00 authored Jan 14, 2019
2 parents a6b66b8 + 676c9b8 commit f11f53a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
7 changes: 7 additions & 0 deletions chain/cache/snapshot_additional_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ func (al *AdditionList) loadFromDb() error {
var frags []*Fragment
var list []*AdditionItem

var lastHeight uint64
for iter.Next() {
value := iter.Value()
frag := &Fragment{}
Expand All @@ -387,9 +388,15 @@ func (al *AdditionList) loadFromDb() error {

frag.TailHeight = GetFragTailHeightFromDbKey(iter.Key())
frag.HeadHeight = GetFragHeadHeightFromDbKey(iter.Key())
if lastHeight > 0 && frag.TailHeight != lastHeight + 1 {
// log error, and need rebuild
al.log.Error(fmt.Sprintf("current lastHeight is %d, miss %d - %d", lastHeight, frag.TailHeight, frag.HeadHeight))
break
}

frags = append(frags, frag)
list = append(list, frag.List...)
lastHeight = frag.HeadHeight
}
if err := iter.Error(); err != nil &&
err != leveldb.ErrNotFound {
Expand Down
3 changes: 2 additions & 1 deletion chain/snapshot_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ func (c *chain) calculateNeedSnapshot(deleteSubLedger map[types.Address][]*ledge
headHeight = tailDeletedBlockHeight - 1
}
if tailHeight >= tailDeletedBlockHeight {
tailHeight = tailDeletedBlockHeight - 1
// now, tailHeight need be greater than headHeight
tailHeight = tailDeletedBlockHeight
}
}

Expand Down
4 changes: 2 additions & 2 deletions producer/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ func (self *tools) generateAccounts(head *ledger.SnapshotBlock) (ledger.Snapshot
if hashH != nil {
err := self.pool.RollbackAccountTo(k, hashH.Hash, hashH.Height)
if err != nil {
self.log.Error("account rollback err.", "addr", k, "accHash", hashH.Hash, "accHeight", hashH.Height, "err", err)
self.log.Error("account rollback err1.", "addr", k, "accHash", hashH.Hash, "accHeight", hashH.Height, "err", err)
return nil, err
}
} else {
err := self.pool.RollbackAccountTo(k, b.Hash, b.Height)
if err != nil {
self.log.Error("account rollback err.", "addr", k, "accHash", hashH.Hash, "accHeight", hashH.Height, "err", err)
self.log.Error("account rollback err2.", "addr", k, "accHash", b.Hash, "accHeight", b.Height, "err", err)
return nil, err
}
}
Expand Down

0 comments on commit f11f53a

Please sign in to comment.