mirror of
https://github.com/fluencelabs/tendermint
synced 2025-07-31 20:21:56 +00:00
Updated Marshal and unmarshal methods to make compatible with protobuf (#2918)
* upadtes in grpc Marshal and unmarshal * update comments
This commit is contained in:
committed by
Ethan Buchman
parent
94e63be922
commit
bef39f3346
@@ -275,6 +275,28 @@ func (b *Block) StringShort() string {
|
||||
return fmt.Sprintf("Block#%v", b.Hash())
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// These methods are for Protobuf Compatibility
|
||||
|
||||
// Marshal returns the amino encoding.
|
||||
func (b *Block) Marshal() ([]byte, error) {
|
||||
return cdc.MarshalBinaryBare(b)
|
||||
}
|
||||
|
||||
// MarshalTo calls Marshal and copies to the given buffer.
|
||||
func (b *Block) MarshalTo(data []byte) (int, error) {
|
||||
bs, err := b.Marshal()
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
return copy(data, bs), nil
|
||||
}
|
||||
|
||||
// Unmarshal deserializes from amino encoded form.
|
||||
func (b *Block) Unmarshal(bs []byte) error {
|
||||
return cdc.UnmarshalBinaryBare(bs, b)
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// MaxDataBytes returns the maximum size of block's data.
|
||||
|
Reference in New Issue
Block a user