update for sdk2 libs. need to fix kv test

NOTE we only updating for tmlibs and abci
This commit is contained in:
Ethan Buchman
2018-01-06 01:26:51 -05:00
parent 4e3488c677
commit cd0fd06b0d
23 changed files with 130 additions and 346 deletions

View File

@@ -40,11 +40,11 @@ type CanonicalJSONVote struct {
}
type CanonicalJSONHeartbeat struct {
Height int64 `json:"height"`
Round int `json:"round"`
Sequence int `json:"sequence"`
ValidatorAddress data.Bytes `json:"validator_address"`
ValidatorIndex int `json:"validator_index"`
Height int64 `json:"height"`
Round int `json:"round"`
Sequence int `json:"sequence"`
ValidatorAddress Address `json:"validator_address"`
ValidatorIndex int `json:"validator_index"`
}
//------------------------------------

View File

@@ -6,7 +6,6 @@ import (
"github.com/tendermint/go-crypto"
"github.com/tendermint/go-wire"
"github.com/tendermint/go-wire/data"
cmn "github.com/tendermint/tmlibs/common"
)
@@ -16,7 +15,7 @@ import (
// json field tags because we always want the JSON
// representation to be in its canonical form.
type Heartbeat struct {
ValidatorAddress data.Bytes `json:"validator_address"`
ValidatorAddress Address `json:"validator_address"`
ValidatorIndex int `json:"validator_index"`
Height int64 `json:"height"`
Round int `json:"round"`

View File

@@ -38,7 +38,7 @@ func voteToStep(vote *Vote) int8 {
// PrivValidator defines the functionality of a local Tendermint validator
// that signs votes, proposals, and heartbeats, and never double signs.
type PrivValidator interface {
GetAddress() data.Bytes // redundant since .PubKey().Address()
GetAddress() Address // redundant since .PubKey().Address()
GetPubKey() crypto.PubKey
SignVote(chainID string, vote *Vote) error
@@ -50,7 +50,7 @@ type PrivValidator interface {
// to prevent double signing. The Signer itself can be mutated to use
// something besides the default, for instance a hardware signer.
type PrivValidatorFS struct {
Address data.Bytes `json:"address"`
Address Address `json:"address"`
PubKey crypto.PubKey `json:"pub_key"`
LastHeight int64 `json:"last_height"`
LastRound int `json:"last_round"`
@@ -96,7 +96,7 @@ func (ds *DefaultSigner) Sign(msg []byte) (crypto.Signature, error) {
// GetAddress returns the address of the validator.
// Implements PrivValidator.
func (pv *PrivValidatorFS) GetAddress() data.Bytes {
func (pv *PrivValidatorFS) GetAddress() Address {
return pv.Address
}

View File

@@ -11,7 +11,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
crypto "github.com/tendermint/go-crypto"
"github.com/tendermint/go-wire/data"
cmn "github.com/tendermint/tmlibs/common"
)
@@ -225,7 +224,7 @@ func TestDifferByTimestamp(t *testing.T) {
}
}
func newVote(addr data.Bytes, idx int, height int64, round int, typ byte, blockID BlockID) *Vote {
func newVote(addr Address, idx int, height int64, round int, typ byte, blockID BlockID) *Vote {
return &Vote{
ValidatorAddress: addr,
ValidatorIndex: idx,

View File

@@ -10,8 +10,8 @@ var TM2PB = tm2pb{}
type tm2pb struct{}
func (tm2pb) Header(header *Header) *types.Header {
return &types.Header{
func (tm2pb) Header(header *Header) types.Header {
return types.Header{
ChainID: header.ChainID,
Height: header.Height,
Time: header.Time.Unix(),
@@ -37,15 +37,15 @@ func (tm2pb) PartSetHeader(partSetHeader PartSetHeader) types.PartSetHeader {
}
}
func (tm2pb) Validator(val *Validator) *types.Validator {
return &types.Validator{
func (tm2pb) Validator(val *Validator) types.Validator {
return types.Validator{
PubKey: val.PubKey.Bytes(),
Power: val.VotingPower,
}
}
func (tm2pb) Validators(vals *ValidatorSet) []*types.Validator {
validators := make([]*types.Validator, len(vals.Validators))
func (tm2pb) Validators(vals *ValidatorSet) []types.Validator {
validators := make([]types.Validator, len(vals.Validators))
for i, val := range vals.Validators {
validators[i] = TM2PB.Validator(val)
}

View File

@@ -7,7 +7,6 @@ import (
"github.com/tendermint/go-crypto"
"github.com/tendermint/go-wire"
"github.com/tendermint/go-wire/data"
cmn "github.com/tendermint/tmlibs/common"
)
@@ -15,9 +14,9 @@ import (
// NOTE: The Accum is not included in Validator.Hash();
// make sure to update that method if changes are made here
type Validator struct {
Address data.Bytes `json:"address"`
PubKey crypto.PubKey `json:"pub_key"`
VotingPower int64 `json:"voting_power"`
Address Address `json:"address"`
PubKey crypto.PubKey `json:"pub_key"`
VotingPower int64 `json:"voting_power"`
Accum int64 `json:"accum"`
}
@@ -74,7 +73,7 @@ func (v *Validator) String() string {
// It excludes the Accum value, which changes with every round.
func (v *Validator) Hash() []byte {
return wire.BinaryRipemd160(struct {
Address data.Bytes
Address Address
PubKey crypto.PubKey
VotingPower int64
}{

View File

@@ -9,7 +9,6 @@ import (
"github.com/tendermint/go-crypto"
"github.com/tendermint/go-wire"
"github.com/tendermint/go-wire/data"
cmn "github.com/tendermint/tmlibs/common"
)
@@ -59,9 +58,12 @@ func IsVoteTypeValid(type_ byte) bool {
}
}
// Address is hex bytes. TODO: crypto.Address
type Address = cmn.HexBytes
// Represents a prevote, precommit, or commit vote from validators for consensus.
type Vote struct {
ValidatorAddress data.Bytes `json:"validator_address"`
ValidatorAddress Address `json:"validator_address"`
ValidatorIndex int `json:"validator_index"`
Height int64 `json:"height"`
Round int `json:"round"`