mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-08 06:15:33 +00:00
proto: add proto files for ibc unblock (#4853)
## Description these proto files are meant to help unblock ibc in their quest of migrating the ibc module to proto. Closes: #XXX
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user