Skip to content

Commit

Permalink
Remove usage of global wire.Marshal*
Browse files Browse the repository at this point in the history
  • Loading branch information
jaekwon committed Jan 22, 2018
1 parent 1dfe265 commit 02885cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 5 additions & 6 deletions proof_key.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/go-wire"
cmn "github.com/tendermint/tmlibs/common"
)

Expand Down Expand Up @@ -53,7 +52,7 @@ func (proof *KeyExistsProof) Verify(key []byte, value []byte, root []byte) error

// Bytes returns a go-wire binary serialization
func (proof *KeyExistsProof) Bytes() []byte {
bz, err := wire.MarshalBinary(proof)
bz, err := cdc.MarshalBinary(proof)
if err != nil {
panic(fmt.Sprintf("error marshaling proof (%v): %v", proof, err))
}
Expand All @@ -63,7 +62,7 @@ func (proof *KeyExistsProof) Bytes() []byte {
// readKeyExistsProof will deserialize a KeyExistsProof from bytes.
func readKeyExistsProof(data []byte) (*KeyExistsProof, error) {
proof := new(KeyExistsProof)
err := wire.UnmarshalBinary(data, proof)
err := cdc.UnmarshalBinary(data, proof)
return proof, err
}

Expand Down Expand Up @@ -106,7 +105,7 @@ func (proof *KeyAbsentProof) Verify(key, value []byte, root []byte) error {

// Bytes returns a go-wire binary serialization
func (proof *KeyAbsentProof) Bytes() []byte {
bz, err := wire.MarshalBinary(proof)
bz, err := cdc.MarshalBinary(proof)
if err != nil {
panic(fmt.Sprintf("error marshaling proof (%v): %v", proof, err))
}
Expand All @@ -116,7 +115,7 @@ func (proof *KeyAbsentProof) Bytes() []byte {
// readKeyAbsentProof will deserialize a KeyAbsentProof from bytes.
func readKeyAbsentProof(data []byte) (*KeyAbsentProof, error) {
proof := new(KeyAbsentProof)
err := wire.UnmarshalBinary(data, proof)
err := cdc.UnmarshalBinary(data, proof)
return proof, err
}

Expand Down Expand Up @@ -157,6 +156,6 @@ func (proof *InnerKeyProof) Verify(hash []byte, value []byte, root []byte) error
// ReadKeyInnerProof will deserialize a InnerKeyProof from bytes.
func ReadInnerKeyProof(data []byte) (*InnerKeyProof, error) {
proof := new(InnerKeyProof)
err := wire.UnmarshalBinary(data, proof)
err := cdc.UnmarshalBinary(data, proof)
return proof, err
}
7 changes: 7 additions & 0 deletions wire.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package iavl

import (
"github.com/tendermint/go-wire"
)

var cdc = wire.NewCodec()

0 comments on commit 02885cf

Please sign in to comment.