types: builds
This commit is contained in:
parent
d2cd079541
commit
3395f5fb0e
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
//-------------------------------------------
|
||||
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/tendermint/go-crypto"
|
||||
"github.com/tendermint/go-wire"
|
||||
"github.com/tendermint/tendermint/wire"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue