Browse Source

types: builds

pull/1265/head
Ethan Buchman 6 years ago
parent
commit
3395f5fb0e
13 changed files with 30 additions and 30 deletions
  1. +8
    -4
      types/block.go
  2. +3
    -3
      types/canonical_json.go
  3. +6
    -6
      types/evidence.go
  4. +1
    -1
      types/heartbeat.go
  5. +1
    -1
      types/proposal.go
  6. +1
    -1
      types/proposal_test.go
  7. +3
    -3
      types/results.go
  8. +1
    -5
      types/signable.go
  9. +2
    -2
      types/tx.go
  10. +1
    -1
      types/tx_test.go
  11. +1
    -1
      types/validator_set_test.go
  12. +1
    -1
      types/vote.go
  13. +1
    -1
      types/vote_test.go

+ 8
- 4
types/block.go View File

@ -7,7 +7,7 @@ import (
"strings" "strings"
"time" "time"
wire "github.com/tendermint/go-wire"
wire "github.com/tendermint/tendermint/wire"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tmlibs/merkle" "github.com/tendermint/tmlibs/merkle"
"golang.org/x/crypto/ripemd160" "golang.org/x/crypto/ripemd160"
@ -515,9 +515,13 @@ type hasher struct {
} }
func (h hasher) Hash() []byte { 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) panic(err)
} }
return hasher.Sum(nil) return hasher.Sum(nil)


+ 3
- 3
types/canonical_json.go View File

@ -3,11 +3,11 @@ package types
import ( import (
"time" "time"
wire "github.com/tendermint/go-wire"
wire "github.com/tendermint/tendermint/wire"
cmn "github.com/tendermint/tmlibs/common" 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 // TimeFormat is used for generating the sigs
const TimeFormat = wire.RFC3339Millis const TimeFormat = wire.RFC3339Millis
@ -114,7 +114,7 @@ func CanonicalHeartbeat(heartbeat *Heartbeat) CanonicalJSONHeartbeat {
} }
func CanonicalTime(t time.Time) string { 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 // local time, we need to force UTC here, so the
// signatures match // signatures match
return t.UTC().Format(TimeFormat) return t.UTC().Format(TimeFormat)


+ 6
- 6
types/evidence.go View File

@ -5,7 +5,7 @@ import (
"fmt" "fmt"
"github.com/tendermint/go-crypto" "github.com/tendermint/go-crypto"
wire "github.com/tendermint/go-wire"
wire "github.com/tendermint/tendermint/wire"
"github.com/tendermint/tmlibs/merkle" "github.com/tendermint/tmlibs/merkle"
) )
@ -80,13 +80,13 @@ func (evl EvidenceList) Has(evidence Evidence) bool {
//------------------------------------------- //-------------------------------------------
const ( 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)
}
//------------------------------------------- //-------------------------------------------


+ 1
- 1
types/heartbeat.go View File

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"github.com/tendermint/go-crypto" "github.com/tendermint/go-crypto"
"github.com/tendermint/go-wire"
"github.com/tendermint/tendermint/wire"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tmlibs/common"
) )


+ 1
- 1
types/proposal.go View File

@ -6,7 +6,7 @@ import (
"time" "time"
"github.com/tendermint/go-crypto" "github.com/tendermint/go-crypto"
"github.com/tendermint/go-wire"
"github.com/tendermint/tendermint/wire"
) )
var ( var (


+ 1
- 1
types/proposal_test.go View File

@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
wire "github.com/tendermint/go-wire"
wire "github.com/tendermint/tendermint/wire"
) )
var testProposal *Proposal var testProposal *Proposal


+ 3
- 3
types/results.go View File

@ -2,7 +2,7 @@ package types
import ( import (
abci "github.com/tendermint/abci/types" abci "github.com/tendermint/abci/types"
wire "github.com/tendermint/go-wire"
wire "github.com/tendermint/tendermint/wire"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tmlibs/merkle" "github.com/tendermint/tmlibs/merkle"
) )
@ -18,7 +18,7 @@ type ABCIResult struct {
// Hash returns the canonical hash of the ABCIResult // Hash returns the canonical hash of the ABCIResult
func (a ABCIResult) Hash() []byte { func (a ABCIResult) Hash() []byte {
return merkle.SimpleHashFromBinary(a)
return tmHash(a)
} }
// ABCIResults wraps the deliver tx results to return a proof // 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 { func (a ABCIResults) Bytes() []byte {
bz, err := wire.MarshalBinary(a) bz, err := wire.MarshalBinary(a)
if err != nil { if err != nil {


+ 1
- 5
types/signable.go View File

@ -1,9 +1,5 @@
package types package types
import (
"github.com/tendermint/tmlibs/merkle"
)
// Signable is an interface for all signable things. // Signable is an interface for all signable things.
// It typically removes signatures before serializing. // It typically removes signatures before serializing.
// SignBytes returns the bytes to be signed // 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 // HashSignBytes is a convenience method for getting the hash of the bytes of a signable
func HashSignBytes(chainID string, o Signable) []byte { func HashSignBytes(chainID string, o Signable) []byte {
return merkle.SimpleHashFromBinary(o.SignBytes(chainID))
return tmHash(o.SignBytes(chainID))
} }

+ 2
- 2
types/tx.go View File

@ -11,12 +11,12 @@ import (
) )
// Tx is an arbitrary byte array. // 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 // 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. // []byte be type 0x1 so we can have versioned txs if need be in the future.
type Tx []byte 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 { func (tx Tx) Hash() []byte {
return wireHasher(tx).Hash() return wireHasher(tx).Hash()
} }


+ 1
- 1
types/tx_test.go View File

@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
wire "github.com/tendermint/go-wire"
wire "github.com/tendermint/tendermint/wire"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tmlibs/common"
ctest "github.com/tendermint/tmlibs/test" ctest "github.com/tendermint/tmlibs/test"
) )


+ 1
- 1
types/validator_set_test.go View File

@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
crypto "github.com/tendermint/go-crypto" crypto "github.com/tendermint/go-crypto"
wire "github.com/tendermint/go-wire"
wire "github.com/tendermint/tendermint/wire"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tmlibs/common"
) )


+ 1
- 1
types/vote.go View File

@ -7,7 +7,7 @@ import (
"time" "time"
"github.com/tendermint/go-crypto" "github.com/tendermint/go-crypto"
"github.com/tendermint/go-wire"
"github.com/tendermint/tendermint/wire"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tmlibs/common"
) )


+ 1
- 1
types/vote_test.go View File

@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
wire "github.com/tendermint/go-wire"
wire "github.com/tendermint/tendermint/wire"
) )
func examplePrevote() *Vote { func examplePrevote() *Vote {


Loading…
Cancel
Save