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.

44 lines
1.0 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. package types
  2. import (
  3. "github.com/tendermint/abci/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. LastBlockId: TM2PB.BlockID(header.LastBlockID),
  15. LastCommitHash: header.LastCommitHash,
  16. DataHash: header.DataHash,
  17. AppHash: header.AppHash,
  18. }
  19. }
  20. func (tm2pb) BlockID(blockID BlockID) *types.BlockID {
  21. return &types.BlockID{
  22. Hash: blockID.Hash,
  23. Parts: TM2PB.PartSetHeader(blockID.PartsHeader),
  24. }
  25. }
  26. func (tm2pb) PartSetHeader(partSetHeader PartSetHeader) *types.PartSetHeader {
  27. return &types.PartSetHeader{
  28. Total: uint64(partSetHeader.Total),
  29. Hash: partSetHeader.Hash,
  30. }
  31. }
  32. func (tm2pb) Validator(val *Validator) *types.Validator {
  33. return &types.Validator{
  34. PubKey: val.PubKey.Bytes(),
  35. Power: uint64(val.VotingPower),
  36. }
  37. }