mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-12 04:41:22 +00:00
Add helper methods for nil checks in structs
This commit is contained in:
@ -53,6 +53,10 @@ func (p *PrivKeyS) UnmarshalJSON(data []byte) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p PrivKeyS) Empty() bool {
|
||||||
|
return p.PrivKey == nil
|
||||||
|
}
|
||||||
|
|
||||||
func PrivKeyFromBytes(privKeyBytes []byte) (privKey PrivKey, err error) {
|
func PrivKeyFromBytes(privKeyBytes []byte) (privKey PrivKey, err error) {
|
||||||
err = wire.ReadBinaryBytes(privKeyBytes, &privKey)
|
err = wire.ReadBinaryBytes(privKeyBytes, &privKey)
|
||||||
return
|
return
|
||||||
|
@ -55,6 +55,10 @@ func (p *PubKeyS) UnmarshalJSON(data []byte) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p PubKeyS) Empty() bool {
|
||||||
|
return p.PubKey == nil
|
||||||
|
}
|
||||||
|
|
||||||
func PubKeyFromBytes(pubKeyBytes []byte) (pubKey PubKey, err error) {
|
func PubKeyFromBytes(pubKeyBytes []byte) (pubKey PubKey, err error) {
|
||||||
err = wire.ReadBinaryBytes(pubKeyBytes, &pubKey)
|
err = wire.ReadBinaryBytes(pubKeyBytes, &pubKey)
|
||||||
return
|
return
|
||||||
|
@ -51,6 +51,10 @@ func (p *SignatureS) UnmarshalJSON(data []byte) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p SignatureS) Empty() bool {
|
||||||
|
return p.Signature == nil
|
||||||
|
}
|
||||||
|
|
||||||
func SignatureFromBytes(sigBytes []byte) (sig Signature, err error) {
|
func SignatureFromBytes(sigBytes []byte) (sig Signature, err error) {
|
||||||
err = wire.ReadBinaryBytes(sigBytes, &sig)
|
err = wire.ReadBinaryBytes(sigBytes, &sig)
|
||||||
return
|
return
|
||||||
|
Reference in New Issue
Block a user