Skip to content

Commit

Permalink
relax the restriction of delete latest version
Browse files Browse the repository at this point in the history
Closes: cosmos#482
  • Loading branch information
yihuang committed Mar 11, 2022
1 parent ccfb418 commit cbd14fa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
3 changes: 0 additions & 3 deletions mutable_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,9 +566,6 @@ func (tree *MutableTree) deleteVersion(version int64) error {
if version <= 0 {
return errors.New("version must be greater than 0")
}
if version == tree.version {
return errors.Errorf("cannot delete latest saved version (%d)", version)
}
if !tree.VersionExists(version) {
return errors.Wrap(ErrVersionDoesNotExist, "")
}
Expand Down
4 changes: 2 additions & 2 deletions nodedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ func (ndb *nodeDB) DeleteVersionsRange(fromVersion, toVersion int64) error {
defer ndb.mtx.Unlock()

latest := ndb.getLatestVersion()
if latest < toVersion {
return errors.Errorf("cannot delete latest saved version (%d)", latest)
if latest+1 < toVersion {
return errors.Errorf("cannot delete future versions (..%d)", toVersion)
}

predecessor := ndb.getPreviousVersion(fromVersion)
Expand Down

0 comments on commit cbd14fa

Please sign in to comment.