Skip to content

Commit

Permalink
get all versions
Browse files Browse the repository at this point in the history
backport cosmos#11124
  • Loading branch information
roysc committed Feb 15, 2022
1 parent b200867 commit 9cdd990
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions store/v2/multi/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,20 @@ func (rs *Store) CacheWrap() types.CacheMultiStore {
return newCacheStore(rs)
}

// GetAllVersions implements CommitMultiStore.
// https://github.com/cosmos/cosmos-sdk/pull/11124
func (rs *Store) GetAllVersions() []int {
vs, err := rs.stateDB.Versions()
if err != nil {
panic(err)
}
var ret []int
for it := vs.Iterator(); it.Next(); {
ret = append(ret, int(it.Value()))
}
return ret
}

// parsePath expects a format like /<storeName>[/<subpath>]
// Must start with /, subpath may be empty
// Returns error if it doesn't start with /
Expand Down
2 changes: 2 additions & 0 deletions store/v2/multi/v1asv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ func (s store1as2) SetInitialVersion(ver uint64) error {
func (s store1as2) SetTracer(w io.Writer) { s.SetTracer(w) }
func (s store1as2) SetTracingContext(tc v2.TraceContext) { s.SetTracingContext(tc) }

func (s store1as2) GetAllVersions() []int { panic("unsupported: GetAllVersions") }

// cache store

func (s cacheStore1as2) CacheWrap() v2.CacheMultiStore {
Expand Down
3 changes: 3 additions & 0 deletions store/v2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ type CommitMultiStore interface {
Close() error
// Defines the minimum version number that can be saved by this store.
SetInitialVersion(uint64) error
// Gets all versions in the DB
// https://github.com/cosmos/cosmos-sdk/pull/11124
GetAllVersions() []int
}

// CacheMultiStore defines a branch of the root state which can be written back to the source store.
Expand Down

0 comments on commit 9cdd990

Please sign in to comment.