state: proto migration (#4951)

This commit is contained in:
Marko
2020-06-05 10:47:16 +02:00
committed by GitHub
parent ee91312d34
commit b9af87c4ea
45 changed files with 5222 additions and 1471 deletions
+10 -10
View File
@@ -16,7 +16,6 @@ import (
tmmath "github.com/tendermint/tendermint/libs/math"
tmproto "github.com/tendermint/tendermint/proto/types"
tmversion "github.com/tendermint/tendermint/proto/version"
"github.com/tendermint/tendermint/version"
)
const (
@@ -333,10 +332,10 @@ func MaxDataBytesUnknownEvidence(maxBytes int64, valsCount int, maxNumEvidence u
// - https://github.com/tendermint/spec/blob/master/spec/blockchain/blockchain.md
type Header struct {
// basic block info
Version version.Consensus `json:"version"`
ChainID string `json:"chain_id"`
Height int64 `json:"height"`
Time time.Time `json:"time"`
Version tmversion.Consensus `json:"version"`
ChainID string `json:"chain_id"`
Height int64 `json:"height"`
Time time.Time `json:"time"`
// prev block info
LastBlockID BlockID `json:"last_block_id"`
@@ -361,7 +360,7 @@ type Header struct {
// Populate the Header with state-derived data.
// Call this after MakeBlock to complete the Header.
func (h *Header) Populate(
version version.Consensus, chainID string,
version tmversion.Consensus, chainID string,
timestamp time.Time, lastBlockID BlockID,
valHash, nextValHash []byte,
consensusHash, appHash, lastResultsHash []byte,
@@ -507,12 +506,13 @@ func (h *Header) ToProto() *tmproto.Header {
if h == nil {
return nil
}
return &tmproto.Header{
Version: tmversion.Consensus{Block: h.Version.App.Uint64(), App: h.Version.App.Uint64()},
Version: h.Version,
ChainID: h.ChainID,
Height: h.Height,
Time: h.Time,
LastBlockID: h.LastBlockID.ToProto(),
LastBlockId: h.LastBlockID.ToProto(),
ValidatorsHash: h.ValidatorsHash,
NextValidatorsHash: h.NextValidatorsHash,
ConsensusHash: h.ConsensusHash,
@@ -534,12 +534,12 @@ func HeaderFromProto(ph *tmproto.Header) (Header, error) {
h := new(Header)
bi, err := BlockIDFromProto(&ph.LastBlockID)
bi, err := BlockIDFromProto(&ph.LastBlockId)
if err != nil {
return Header{}, err
}
h.Version = version.Consensus{Block: version.Protocol(ph.Version.Block), App: version.Protocol(ph.Version.App)}
h.Version = ph.Version
h.ChainID = ph.ChainID
h.Height = ph.Height
h.Time = ph.Time