types: builds
This commit is contained in:
parent
d2cd079541
commit
3395f5fb0e
|
@ -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)
|
hasher := ripemd160.New()
|
||||||
wire.WriteBinary(h.item, hasher, n, err)
|
bz, err := wire.MarshalBinary(h.item)
|
||||||
if *err != nil {
|
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,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)
|
||||||
|
|
|
@ -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(
|
func init() {
|
||||||
struct{ Evidence }{},
|
wire.RegisterInterface((*Evidence)(nil), nil)
|
||||||
wire.ConcreteType{&DuplicateVoteEvidence{}, evidenceTypeDuplicateVote},
|
wire.RegisterConcrete(&DuplicateVoteEvidence{}, wireTypeEvidenceDuplicateVote, nil)
|
||||||
)
|
}
|
||||||
|
|
||||||
//-------------------------------------------
|
//-------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -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 (
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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,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))
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"
|
||||||
)
|
)
|
||||||
|
|
|
@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -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…
Reference in New Issue