proto: add proto files for ibc unblock (#4853) (#4906)

these proto files are meant to help unblock ibc in their quest of migrating the ibc module to proto.
This commit is contained in:
Marko
2020-05-28 12:41:32 +02:00
committed by Tess Rinearson
parent 64c7771966
commit d9c2f01bb5
59 changed files with 8914 additions and 13 deletions
+26
View File
@@ -9,6 +9,7 @@ import (
tmmath "github.com/tendermint/tendermint/libs/math"
tmrand "github.com/tendermint/tendermint/libs/rand"
tmprotobits "github.com/tendermint/tendermint/proto/libs/bits"
)
// BitArray is a thread-safe implementation of a bit array.
@@ -418,3 +419,28 @@ func (bA *BitArray) UnmarshalJSON(bz []byte) error {
*bA = *bA2 //nolint:govet
return nil
}
// ToProto converts BitArray to protobuf
func (bA *BitArray) ToProto() *tmprotobits.BitArray {
if bA == nil || len(bA.Elems) == 0 {
return nil
}
return &tmprotobits.BitArray{
Bits: int64(bA.Bits),
Elems: bA.Elems,
}
}
// FromProto sets a protobuf BitArray to the given pointer.
func (bA *BitArray) FromProto(protoBitArray *tmprotobits.BitArray) {
if protoBitArray == nil {
bA = nil
return
}
bA.Bits = int(protoBitArray.Bits)
if len(protoBitArray.Elems) > 0 {
bA.Elems = protoBitArray.Elems
}
}