tendermint/types/encoding_helper.go
Dev Ojha 12fa9d1cab crypto/merkle: Remove byter in favor of plain byte slices (#2595)
* crypto/merkle: Remove byter in favor of plain byte slices

This PR is fully backwards compatible in terms of function output!
(The Go API differs though) The only test case changes was to refactor
it to be table driven.

* Update godocs per review comments
2018-10-10 12:46:09 -04:00

15 lines
343 B
Go

package types
import (
cmn "github.com/tendermint/tendermint/libs/common"
)
// cdcEncode returns nil if the input is nil, otherwise returns
// cdc.MustMarshalBinaryBare(item)
func cdcEncode(item interface{}) []byte {
if item != nil && !cmn.IsTypedNil(item) && !cmn.IsEmpty(item) {
return cdc.MustMarshalBinaryBare(item)
}
return nil
}