-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec91784
commit 4b43c99
Showing
8 changed files
with
136 additions
and
101 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
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,59 @@ | ||
package iavlv2 | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/cosmos/iavl/v2" | ||
|
||
"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 { | ||
return e.exporter.Close() | ||
} | ||
|
||
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.NewImportNode(item.Key, item.Value, item.Version, 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
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