You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
942 B

8 years ago
8 years ago
8 years ago
  1. package types
  2. import (
  3. "github.com/tendermint/tmsp/types"
  4. )
  5. // Convert tendermint types to protobuf types
  6. var TM2PB = tm2pb{}
  7. type tm2pb struct{}
  8. func (tm2pb) Header(header *Header) *types.Header {
  9. return &types.Header{
  10. ChainId: header.ChainID,
  11. Height: uint64(header.Height),
  12. Time: uint64(header.Time.Unix()),
  13. NumTxs: uint64(header.NumTxs),
  14. LastBlockHash: header.LastBlockHash,
  15. LastBlockParts: TM2PB.PartSetHeader(header.LastBlockParts),
  16. LastCommitHash: header.LastCommitHash,
  17. DataHash: header.DataHash,
  18. AppHash: header.AppHash,
  19. }
  20. }
  21. func (tm2pb) PartSetHeader(partSetHeader PartSetHeader) *types.PartSetHeader {
  22. return &types.PartSetHeader{
  23. Total: uint64(partSetHeader.Total),
  24. Hash: partSetHeader.Hash,
  25. }
  26. }
  27. func (tm2pb) Validator(val *Validator) *types.Validator {
  28. return &types.Validator{
  29. PubKey: val.PubKey.Bytes(),
  30. Power: uint64(val.VotingPower),
  31. }
  32. }