From 3395f5fb0e023017c701bdf2f8ab087b185f7174 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Thu, 15 Feb 2018 14:26:49 -0500 Subject: [PATCH] types: builds --- types/block.go | 12 ++++++++---- types/canonical_json.go | 6 +++--- types/evidence.go | 12 ++++++------ types/heartbeat.go | 2 +- types/proposal.go | 2 +- types/proposal_test.go | 2 +- types/results.go | 6 +++--- types/signable.go | 6 +----- types/tx.go | 4 ++-- types/tx_test.go | 2 +- types/validator_set_test.go | 2 +- types/vote.go | 2 +- types/vote_test.go | 2 +- 13 files changed, 30 insertions(+), 30 deletions(-) diff --git a/types/block.go b/types/block.go index 9aa7b0a03..a447cc39a 100644 --- a/types/block.go +++ b/types/block.go @@ -7,7 +7,7 @@ import ( "strings" "time" - wire "github.com/tendermint/go-wire" + wire "github.com/tendermint/tendermint/wire" cmn "github.com/tendermint/tmlibs/common" "github.com/tendermint/tmlibs/merkle" "golang.org/x/crypto/ripemd160" @@ -515,9 +515,13 @@ type hasher struct { } func (h hasher) Hash() []byte { - hasher, n, err := ripemd160.New(), new(int), new(error) - wire.WriteBinary(h.item, hasher, n, err) - if *err != nil { + hasher := ripemd160.New() + bz, err := wire.MarshalBinary(h.item) + if err != nil { + panic(err) + } + _, err = hasher.Write(bz) + if err != nil { panic(err) } return hasher.Sum(nil) diff --git a/types/canonical_json.go b/types/canonical_json.go index 879bb5c52..4eeeb2064 100644 --- a/types/canonical_json.go +++ b/types/canonical_json.go @@ -3,11 +3,11 @@ package types import ( "time" - wire "github.com/tendermint/go-wire" + wire "github.com/tendermint/tendermint/wire" cmn "github.com/tendermint/tmlibs/common" ) -// canonical json is go-wire's json for structs with fields in alphabetical order +// canonical json is wire's json for structs with fields in alphabetical order // TimeFormat is used for generating the sigs const TimeFormat = wire.RFC3339Millis @@ -114,7 +114,7 @@ func CanonicalHeartbeat(heartbeat *Heartbeat) CanonicalJSONHeartbeat { } func CanonicalTime(t time.Time) string { - // note that sending time over go-wire resets it to + // note that sending time over wire resets it to // local time, we need to force UTC here, so the // signatures match return t.UTC().Format(TimeFormat) diff --git a/types/evidence.go b/types/evidence.go index b793f7d88..d4916e32a 100644 --- a/types/evidence.go +++ b/types/evidence.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/tendermint/go-crypto" - wire "github.com/tendermint/go-wire" + wire "github.com/tendermint/tendermint/wire" "github.com/tendermint/tmlibs/merkle" ) @@ -80,13 +80,13 @@ func (evl EvidenceList) Has(evidence Evidence) bool { //------------------------------------------- const ( - evidenceTypeDuplicateVote = byte(0x01) + wireTypeEvidenceDuplicateVote = "com.tendermint.types.evidence.duplicate_vote" ) -var _ = wire.RegisterInterface( - struct{ Evidence }{}, - wire.ConcreteType{&DuplicateVoteEvidence{}, evidenceTypeDuplicateVote}, -) +func init() { + wire.RegisterInterface((*Evidence)(nil), nil) + wire.RegisterConcrete(&DuplicateVoteEvidence{}, wireTypeEvidenceDuplicateVote, nil) +} //------------------------------------------- diff --git a/types/heartbeat.go b/types/heartbeat.go index 81a497a45..fc5f8ad7f 100644 --- a/types/heartbeat.go +++ b/types/heartbeat.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/tendermint/go-crypto" - "github.com/tendermint/go-wire" + "github.com/tendermint/tendermint/wire" cmn "github.com/tendermint/tmlibs/common" ) diff --git a/types/proposal.go b/types/proposal.go index cd928ea43..c240756bb 100644 --- a/types/proposal.go +++ b/types/proposal.go @@ -6,7 +6,7 @@ import ( "time" "github.com/tendermint/go-crypto" - "github.com/tendermint/go-wire" + "github.com/tendermint/tendermint/wire" ) var ( diff --git a/types/proposal_test.go b/types/proposal_test.go index bebf37ca5..610f76855 100644 --- a/types/proposal_test.go +++ b/types/proposal_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" - wire "github.com/tendermint/go-wire" + wire "github.com/tendermint/tendermint/wire" ) var testProposal *Proposal diff --git a/types/results.go b/types/results.go index 27486c989..71834664d 100644 --- a/types/results.go +++ b/types/results.go @@ -2,7 +2,7 @@ package types import ( abci "github.com/tendermint/abci/types" - wire "github.com/tendermint/go-wire" + wire "github.com/tendermint/tendermint/wire" cmn "github.com/tendermint/tmlibs/common" "github.com/tendermint/tmlibs/merkle" ) @@ -18,7 +18,7 @@ type ABCIResult struct { // Hash returns the canonical hash of the ABCIResult func (a ABCIResult) Hash() []byte { - return merkle.SimpleHashFromBinary(a) + return tmHash(a) } // ABCIResults wraps the deliver tx results to return a proof @@ -40,7 +40,7 @@ func NewResultFromResponse(response *abci.ResponseDeliverTx) ABCIResult { } } -// Bytes serializes the ABCIResponse using go-wire +// Bytes serializes the ABCIResponse using wire func (a ABCIResults) Bytes() []byte { bz, err := wire.MarshalBinary(a) if err != nil { diff --git a/types/signable.go b/types/signable.go index 1edaf020c..19829ede7 100644 --- a/types/signable.go +++ b/types/signable.go @@ -1,9 +1,5 @@ package types -import ( - "github.com/tendermint/tmlibs/merkle" -) - // Signable is an interface for all signable things. // It typically removes signatures before serializing. // SignBytes returns the bytes to be signed @@ -16,5 +12,5 @@ type Signable interface { // HashSignBytes is a convenience method for getting the hash of the bytes of a signable func HashSignBytes(chainID string, o Signable) []byte { - return merkle.SimpleHashFromBinary(o.SignBytes(chainID)) + return tmHash(o.SignBytes(chainID)) } diff --git a/types/tx.go b/types/tx.go index d9e2e2ebd..fc1d27212 100644 --- a/types/tx.go +++ b/types/tx.go @@ -11,12 +11,12 @@ import ( ) // Tx is an arbitrary byte array. -// NOTE: Tx has no types at this level, so when go-wire encoded it's just length-prefixed. +// NOTE: Tx has no types at this level, so when wire encoded it's just length-prefixed. // Alternatively, it may make sense to add types here and let // []byte be type 0x1 so we can have versioned txs if need be in the future. type Tx []byte -// Hash computes the RIPEMD160 hash of the go-wire encoded transaction. +// Hash computes the RIPEMD160 hash of the wire encoded transaction. func (tx Tx) Hash() []byte { return wireHasher(tx).Hash() } diff --git a/types/tx_test.go b/types/tx_test.go index 2f51a6129..340bd5a6b 100644 --- a/types/tx_test.go +++ b/types/tx_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" - wire "github.com/tendermint/go-wire" + wire "github.com/tendermint/tendermint/wire" cmn "github.com/tendermint/tmlibs/common" ctest "github.com/tendermint/tmlibs/test" ) diff --git a/types/validator_set_test.go b/types/validator_set_test.go index 3a8649ef0..03c483d26 100644 --- a/types/validator_set_test.go +++ b/types/validator_set_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/assert" crypto "github.com/tendermint/go-crypto" - wire "github.com/tendermint/go-wire" + wire "github.com/tendermint/tendermint/wire" cmn "github.com/tendermint/tmlibs/common" ) diff --git a/types/vote.go b/types/vote.go index b013d1ce3..6b36e0f4f 100644 --- a/types/vote.go +++ b/types/vote.go @@ -7,7 +7,7 @@ import ( "time" "github.com/tendermint/go-crypto" - "github.com/tendermint/go-wire" + "github.com/tendermint/tendermint/wire" cmn "github.com/tendermint/tmlibs/common" ) diff --git a/types/vote_test.go b/types/vote_test.go index 1da1ec7fa..a4a0f309f 100644 --- a/types/vote_test.go +++ b/types/vote_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" - wire "github.com/tendermint/go-wire" + wire "github.com/tendermint/tendermint/wire" ) func examplePrevote() *Vote {