Browse Source

go-merkle -> merkleeyes/iavl and tmlibs/merkle

pull/1780/head
Ethan Buchman 8 years ago
parent
commit
078e617d1c
3 changed files with 10 additions and 9 deletions
  1. +3
    -2
      example/dummy/dummy.go
  2. +4
    -4
      example/dummy/dummy_test.go
  3. +3
    -3
      example/dummy/persistent_dummy.go

+ 3
- 2
example/dummy/dummy.go View File

@ -4,8 +4,9 @@ import (
"strings"
"github.com/tendermint/abci/types"
"github.com/tendermint/merkleeyes/iavl"
cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/go-merkle"
"github.com/tendermint/tmlibs/merkle"
)
type DummyApplication struct {
@ -15,7 +16,7 @@ type DummyApplication struct {
}
func NewDummyApplication() *DummyApplication {
state := merkle.NewIAVLTree(0, nil)
state := iavl.NewIAVLTree(0, nil)
return &DummyApplication{state: state}
}


+ 4
- 4
example/dummy/dummy_test.go View File

@ -10,9 +10,9 @@ import (
abcicli "github.com/tendermint/abci/client"
"github.com/tendermint/abci/server"
"github.com/tendermint/abci/types"
cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/go-crypto"
"github.com/tendermint/go-merkle"
"github.com/tendermint/merkleeyes/iavl"
cmn "github.com/tendermint/tmlibs/common"
)
func testDummy(t *testing.T, app types.Application, tx []byte, key, value string) {
@ -38,7 +38,7 @@ func testDummy(t *testing.T, app types.Application, tx []byte, key, value string
})
require.Equal(t, types.CodeType_OK, resQuery.Code)
require.Equal(t, value, string(resQuery.Value))
proof, err := merkle.ReadProof(resQuery.Proof)
proof, err := iavl.ReadProof(resQuery.Proof)
require.Nil(t, err)
require.True(t, proof.Verify([]byte(key), resQuery.Value, proof.RootHash)) // NOTE: we have no way to verify the RootHash
}
@ -302,7 +302,7 @@ func testClient(t *testing.T, app abcicli.Client, tx []byte, key, value string)
require.Nil(t, err)
require.Equal(t, types.CodeType_OK, resQuery.Code)
require.Equal(t, value, string(resQuery.Value))
proof, err := merkle.ReadProof(resQuery.Proof)
proof, err := iavl.ReadProof(resQuery.Proof)
require.Nil(t, err)
require.True(t, proof.Verify([]byte(key), resQuery.Value, proof.RootHash)) // NOTE: we have no way to verify the RootHash
}

+ 3
- 3
example/dummy/persistent_dummy.go View File

@ -7,10 +7,10 @@ import (
"strings"
"github.com/tendermint/abci/types"
"github.com/tendermint/go-wire"
"github.com/tendermint/merkleeyes/iavl"
cmn "github.com/tendermint/tmlibs/common"
dbm "github.com/tendermint/tmlibs/db"
"github.com/tendermint/go-merkle"
"github.com/tendermint/go-wire"
)
const (
@ -35,7 +35,7 @@ func NewPersistentDummyApplication(dbDir string) *PersistentDummyApplication {
db := dbm.NewDB("dummy", "leveldb", dbDir)
lastBlock := LoadLastBlock(db)
stateTree := merkle.NewIAVLTree(0, db)
stateTree := iavl.NewIAVLTree(0, db)
stateTree.Load(lastBlock.AppHash)
log.Notice("Loaded state", "block", lastBlock.Height, "root", stateTree.Hash())


Loading…
Cancel
Save