Skip to content

Commit

Permalink
remove redundant hashing on commit
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaSripal committed May 22, 2020
1 parent 70a4b5e commit b8be4a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
1 change: 0 additions & 1 deletion crypto/merkle/proof_simple_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"

"github.com/pkg/errors"

"github.com/tendermint/tendermint/crypto/tmhash"
)

Expand Down
17 changes: 10 additions & 7 deletions crypto/merkle/simple_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

amino "github.com/tendermint/go-amino"

"github.com/tendermint/tendermint/crypto/tmhash"
"github.com/tendermint/tendermint/libs/kv"
)

Expand All @@ -29,14 +28,9 @@ func newSimpleMap() *simpleMap {
func (sm *simpleMap) Set(key string, value []byte) {
sm.sorted = false

// The value is hashed, so you can
// check for equality with a cached value (say)
// and make a determination to fetch or not.
vhash := tmhash.Sum(value)

sm.kvs = append(sm.kvs, kv.Pair{
Key: []byte(key),
Value: vhash,
Value: value,
})
}

Expand Down Expand Up @@ -71,6 +65,15 @@ func (sm *simpleMap) KVPairs() kv.Pairs {
// then hashed.
type KVPair kv.Pair

// NewKVPair takes in a key and value and creates a kv.Pair
// wrapped in the local extension KVPair
func NewKVPair(key, value []byte) KVPair {
return KVPair(kv.Pair{
Key: key,
Value: value,
})
}

// Bytes returns key || value, with both the
// key and value length prefixed.
func (kv KVPair) Bytes() []byte {
Expand Down

0 comments on commit b8be4a0

Please sign in to comment.