From 2edc68c59bea3e242011b5bb308df2f399d5548b Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Wed, 6 Jun 2018 13:07:17 -0700 Subject: [PATCH] use all fields in abci types --- types/protobuf.go | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/types/protobuf.go b/types/protobuf.go index bfe3df343..d1b0ae7fb 100644 --- a/types/protobuf.go +++ b/types/protobuf.go @@ -32,20 +32,26 @@ type tm2pb struct{} func (tm2pb) Header(header *Header) abci.Header { return abci.Header{ - ChainID: header.ChainID, - Height: header.Height, - Time: header.Time.Unix(), - NumTxs: int32(header.NumTxs), // XXX: overflow + ChainID: header.ChainID, + Height: header.Height, + + Time: header.Time.Unix(), + NumTxs: int32(header.NumTxs), // XXX: overflow + TotalTxs: header.NumTxs, + LastBlockHash: header.LastBlockID.Hash, ValidatorsHash: header.ValidatorsHash, AppHash: header.AppHash, + + // Proposer: TODO } } func (tm2pb) Validator(val *Validator) abci.Validator { return abci.Validator{ - PubKey: TM2PB.PubKey(val.PubKey), - Power: val.VotingPower, + Address: val.PubKey.Address(), + PubKey: TM2PB.PubKey(val.PubKey), + Power: val.VotingPower, } } @@ -101,28 +107,24 @@ func (tm2pb) Evidence(ev Evidence, valSet *ValidatorSet, evTime time.Time) abci. panic(val) } - abciEvidence := abci.Evidence{ - Validator: abci.Validator{ - Address: ev.Address(), - PubKey: TM2PB.PubKey(val.PubKey), - Power: val.VotingPower, - }, - Height: ev.Height(), - Time: evTime.Unix(), - TotalVotingPower: valSet.TotalVotingPower(), - } - // set type + var evType string switch ev.(type) { case *DuplicateVoteEvidence: - abciEvidence.Type = ABCIEvidenceTypeDuplicateVote + evType = ABCIEvidenceTypeDuplicateVote case *MockGoodEvidence, MockGoodEvidence: - abciEvidence.Type = ABCIEvidenceTypeMockGood + evType = ABCIEvidenceTypeMockGood default: panic(fmt.Sprintf("Unknown evidence type: %v %v", ev, reflect.TypeOf(ev))) } - return abciEvidence + return abci.Evidence{ + Type: evType, + Validator: TM2PB.Validator(val), + Height: ev.Height(), + Time: evTime.Unix(), + TotalVotingPower: valSet.TotalVotingPower(), + } } func (tm2pb) ValidatorFromPubKeyAndPower(pubkey crypto.PubKey, power int64) abci.Validator {