consensus: proto migration (#4984)

## Description

migrate consensus to protobuf

Closes: #XXX
This commit is contained in:
Marko
2020-06-10 14:08:47 +02:00
committed by GitHub
parent 5697e144a7
commit d54de61bf6
20 changed files with 873 additions and 217 deletions

View File

@@ -1,13 +0,0 @@
package types
import (
amino "github.com/tendermint/go-amino"
"github.com/tendermint/tendermint/types"
)
var cdc = amino.NewCodec()
func init() {
types.RegisterBlockAmino(cdc)
}

View File

@@ -65,31 +65,3 @@ func (prs PeerRoundState) StringIndented(indent string) string {
indent, prs.CatchupCommit, prs.CatchupCommitRound,
indent)
}
//-----------------------------------------------------------
// These methods are for Protobuf Compatibility
// Size returns the size of the amino encoding, in bytes.
func (prs *PeerRoundState) Size() int {
bs, _ := prs.Marshal()
return len(bs)
}
// Marshal returns the amino encoding.
func (prs *PeerRoundState) Marshal() ([]byte, error) {
return cdc.MarshalBinaryBare(prs)
}
// MarshalTo calls Marshal and copies to the given buffer.
func (prs *PeerRoundState) MarshalTo(data []byte) (int, error) {
bs, err := prs.Marshal()
if err != nil {
return -1, err
}
return copy(data, bs), nil
}
// Unmarshal deserializes from amino encoded form.
func (prs *PeerRoundState) Unmarshal(bs []byte) error {
return cdc.UnmarshalBinaryBare(bs, prs)
}

View File

@@ -213,31 +213,3 @@ func (rs *RoundState) StringShort() string {
return fmt.Sprintf(`RoundState{H:%v R:%v S:%v ST:%v}`,
rs.Height, rs.Round, rs.Step, rs.StartTime)
}
//-----------------------------------------------------------
// These methods are for Protobuf Compatibility
// Size returns the size of the amino encoding, in bytes.
func (rs *RoundStateSimple) Size() int {
bs, _ := rs.Marshal()
return len(bs)
}
// Marshal returns the amino encoding.
func (rs *RoundStateSimple) Marshal() ([]byte, error) {
return cdc.MarshalBinaryBare(rs)
}
// MarshalTo calls Marshal and copies to the given buffer.
func (rs *RoundStateSimple) MarshalTo(data []byte) (int, error) {
bs, err := rs.Marshal()
if err != nil {
return -1, err
}
return copy(data, bs), nil
}
// Unmarshal deserializes from amino encoded form.
func (rs *RoundStateSimple) Unmarshal(bs []byte) error {
return cdc.UnmarshalBinaryBare(bs, rs)
}

View File

@@ -84,6 +84,7 @@ func BenchmarkRoundStateDeepCopy(b *testing.B) {
LastCommit: nil, // TODO
LastValidators: vset,
}
b.StartTimer()
for i := 0; i < b.N; i++ {