feat(store/v2): add SetInitialVersion in SC (#18665)

This commit is contained in:
cool-developer
2023-12-09 22:31:21 +00:00
committed by GitHub
parent 3ba1c5bf26
commit cc9d8526d0
5 changed files with 19 additions and 5 deletions
+6
View File
@@ -75,6 +75,12 @@ func (t *IavlTree) GetLatestVersion() uint64 {
return uint64(t.tree.Version())
}
// SetInitialVersion sets the initial version of the database.
func (t *IavlTree) SetInitialVersion(version uint64) error {
t.tree.SetInitialVersion(version)
return nil
}
// Prune prunes all versions up to and including the provided version.
func (t *IavlTree) Prune(version uint64) error {
return t.tree.DeleteVersionsTo(int64(version))
+10
View File
@@ -116,6 +116,16 @@ func (c *CommitStore) Commit() ([]store.StoreInfo, error) {
return storeInfos, nil
}
func (c *CommitStore) SetInitialVersion(version uint64) error {
for _, tree := range c.multiTrees {
if err := tree.SetInitialVersion(version); err != nil {
return err
}
}
return nil
}
func (c *CommitStore) GetProof(storeKey string, version uint64, key []byte) (*ics23.CommitmentProof, error) {
tree, ok := c.multiTrees[storeKey]
if !ok {
+1
View File
@@ -20,6 +20,7 @@ type Tree interface {
WorkingHash() []byte
LoadVersion(version uint64) error
Commit() ([]byte, error)
SetInitialVersion(version uint64) error
GetProof(version uint64, key []byte) (*ics23.CommitmentProof, error)
Prune(version uint64) error
Export(version uint64) (Exporter, error)