4 "github.com/tendermint/abci/types"
7 // Convert tendermint types to protobuf types
12 func (tm2pb) Header(header *Header) *types.Header {
14 ChainId: header.ChainID,
15 Height: uint64(header.Height),
16 Time: uint64(header.Time.Unix()),
17 NumTxs: uint64(header.NumTxs),
18 LastBlockId: TM2PB.BlockID(header.LastBlockID),
19 LastCommitHash: header.LastCommitHash,
20 DataHash: header.DataHash,
21 AppHash: header.AppHash,
25 func (tm2pb) BlockID(blockID BlockID) *types.BlockID {
26 return &types.BlockID{
28 Parts: TM2PB.PartSetHeader(blockID.PartsHeader),
32 func (tm2pb) PartSetHeader(partSetHeader PartSetHeader) *types.PartSetHeader {
33 return &types.PartSetHeader{
34 Total: uint64(partSetHeader.Total),
35 Hash: partSetHeader.Hash,
39 func (tm2pb) Validator(val *Validator) *types.Validator {
40 return &types.Validator{
41 PubKey: val.PubKey.Bytes(),
42 Power: uint64(val.VotingPower),
46 func (tm2pb) Validators(vals *ValidatorSet) []*types.Validator {
47 validators := make([]*types.Validator, len(vals.Validators))
48 for i, val := range vals.Validators {
49 validators[i] = TM2PB.Validator(val)