Skip to content

Commit

Permalink
can;t delete origin orphans key before update orphans key or delete node
Browse files Browse the repository at this point in the history
  • Loading branch information
cwbhhjl committed Feb 15, 2023
1 parent 0af2573 commit 703134d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions libs/iavl/nodedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -648,17 +648,12 @@ func (ndb *nodeDB) deleteOrphansFromDB(version int64) {
// TODO optimize.
ndb.traverseOrphansVersion(version, func(key, hash []byte) {
var fromVersion, toVersion int64
var err error

// See comment on `orphanKeyFmt`. Note that here, `version` and
// `toVersion` are always equal.
orphanKeyFormat.Scan(key, &toVersion, &fromVersion)

// Delete orphan key and reverse-lookup key.
err := ndb.db.Delete(key)
if err != nil {
panic(err)
}

// If there is no predecessor, or the predecessor is earlier than the
// beginning of the lifetime (ie: negative lifetime), or the lifetime
// spans a single version and that version is the one being deleted, we
Expand All @@ -679,6 +674,12 @@ func (ndb *nodeDB) deleteOrphansFromDB(version int64) {
panic(err)
}
}

// Delete orphan key and reverse-lookup key.
err = ndb.db.Delete(key)
if err != nil {
panic(err)
}
})
}

Expand Down

0 comments on commit 703134d

Please sign in to comment.