Skip to content

Commit

Permalink
continuing to update iavl, log, and dbm-> cosmos/cosmos-db
Browse files Browse the repository at this point in the history
  • Loading branch information
faddat committed Nov 14, 2023
1 parent 7064b1d commit 3dd8562
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 26 deletions.
15 changes: 3 additions & 12 deletions store/iavl/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,7 @@ func (st *Store) Commit() types.CommitID {

// LastCommitID implements Committer.
func (st *Store) LastCommitID() types.CommitID {
hash, err := st.tree.Hash()
if err != nil {
panic(err)
}
hash := st.tree.Hash()

return types.CommitID{
Version: st.tree.Version(),
Expand Down Expand Up @@ -246,19 +243,13 @@ func (st *Store) LazyLoadVersionForOverwriting(targetVersion int64) (int64, erro

// Implements types.KVStore.
func (st *Store) Iterator(start, end []byte) types.Iterator {
iterator, err := st.tree.Iterator(start, end, true)
if err != nil {
panic(err)
}
iterator := st.tree.Iterator(start, end, true)
return iterator
}

// Implements types.KVStore.
func (st *Store) ReverseIterator(start, end []byte) types.Iterator {
iterator, err := st.tree.Iterator(start, end, false)
if err != nil {
panic(err)
}
iterator := st.tree.Iterator(start, end, false)
return iterator
}

Expand Down
15 changes: 5 additions & 10 deletions store/iavl/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (

"github.com/cosmos/cosmos-sdk/store/cachekv"

dbm "github.com/cometbft/cometbft-db"
"cosmossdk.io/log"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/iavl"
"github.com/stretchr/testify/require"

Expand All @@ -34,8 +34,7 @@ func randBytes(numBytes int) []byte {

// make a tree with data from above and save it
func newAlohaTree(t *testing.T, db dbm.DB) (*iavl.MutableTree, types.CommitID) {
tree, err := iavl.NewMutableTree(db, cacheSize, false)
require.NoError(t, err)
tree := iavl.NewMutableTree(dbm.NewMemDB(), 100, false, log.NewNopLogger())

for k, v := range treeData {
tree.Set([]byte(k), []byte(v))
Expand Down Expand Up @@ -280,10 +279,8 @@ func TestIAVLIterator(t *testing.T) {
}

func TestIAVLReverseIterator(t *testing.T) {
db := dbm.NewMemDB()

tree, err := iavl.NewMutableTree(db, cacheSize, false)
require.NoError(t, err)
tree := iavl.NewMutableTree(dbm.NewMemDB(), 100, false, log.NewNopLogger())

iavlStore := UnsafeNewStore(tree)

Expand Down Expand Up @@ -314,9 +311,7 @@ func TestIAVLReverseIterator(t *testing.T) {
}

func TestIAVLPrefixIterator(t *testing.T) {
db := dbm.NewMemDB()
tree, err := iavl.NewMutableTree(db, cacheSize, false)
require.NoError(t, err)
tree := iavl.NewMutableTree(dbm.NewMemDB(), 100, false, log.NewNopLogger())

iavlStore := UnsafeNewStore(tree)

Expand Down
7 changes: 3 additions & 4 deletions store/prefix/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"crypto/rand"
"testing"

"cosmossdk.io/log"
"github.com/cosmos/cosmos-sdk/store/cachekv"

dbm "github.com/cometbft/cometbft-db"
dbm "github.com/cosmos/cosmos-db"
"github.com/stretchr/testify/require"

tiavl "github.com/cosmos/iavl"
Expand Down Expand Up @@ -89,9 +90,7 @@ func testPrefixStore(t *testing.T, baseStore types.KVStore, prefix []byte) {
}

func TestIAVLStorePrefix(t *testing.T) {
db := dbm.NewMemDB()
tree, err := tiavl.NewMutableTree(db, cacheSize, false)
require.NoError(t, err)
tree := tiavl.NewMutableTree(dbm.NewMemDB(), 100, false, log.NewNopLogger())
iavlStore := iavl.UnsafeNewStore(tree)

testPrefixStore(t, iavlStore, []byte("test"))
Expand Down

0 comments on commit 3dd8562

Please sign in to comment.