forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(store/v2): snapshot manager (cosmos#18458)
- Loading branch information
1 parent
14bb52a
commit f6df368
Showing
26 changed files
with
777 additions
and
261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package iavl | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/cosmos/iavl" | ||
|
||
"cosmossdk.io/store/v2/commitment" | ||
snapshotstypes "cosmossdk.io/store/v2/snapshots/types" | ||
) | ||
|
||
// Exporter is a wrapper around iavl.Exporter. | ||
type Exporter struct { | ||
exporter *iavl.Exporter | ||
} | ||
|
||
// Next returns the next item in the exporter. | ||
func (e *Exporter) Next() (*snapshotstypes.SnapshotIAVLItem, error) { | ||
item, err := e.exporter.Next() | ||
if err != nil { | ||
if errors.Is(err, iavl.ErrorExportDone) { | ||
return nil, commitment.ErrorExportDone | ||
} | ||
return nil, err | ||
} | ||
|
||
return &snapshotstypes.SnapshotIAVLItem{ | ||
Key: item.Key, | ||
Value: item.Value, | ||
Version: item.Version, | ||
Height: int32(item.Height), | ||
}, nil | ||
} | ||
|
||
// Close closes the exporter. | ||
func (e *Exporter) Close() error { | ||
e.exporter.Close() | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package iavl | ||
|
||
import ( | ||
"github.com/cosmos/iavl" | ||
|
||
snapshotstypes "cosmossdk.io/store/v2/snapshots/types" | ||
) | ||
|
||
// Importer is a wrapper around iavl.Importer. | ||
type Importer struct { | ||
importer *iavl.Importer | ||
} | ||
|
||
// Add adds the given item to the importer. | ||
func (i *Importer) Add(item *snapshotstypes.SnapshotIAVLItem) error { | ||
return i.importer.Add(&iavl.ExportNode{ | ||
Key: item.Key, | ||
Value: item.Value, | ||
Version: item.Version, | ||
Height: int8(item.Height), | ||
}) | ||
} | ||
|
||
// Commit commits the importer. | ||
func (i *Importer) Commit() error { | ||
return i.importer.Commit() | ||
} | ||
|
||
// Close closes the importer. | ||
func (i *Importer) Close() error { | ||
i.importer.Close() | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.