rewrites encode methods for readability (#2084)
This commit is contained in:
parent
4b75752d6b
commit
24c8132975
@ -9,26 +9,29 @@ import (
|
|||||||
"storj.io/storj/pkg/pb"
|
"storj.io/storj/pkg/pb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// EncodeOrderLimit encodes order limit into bytes for signing.
|
// EncodeOrderLimit encodes order limit into bytes for signing. Removes signature from serialized limit.
|
||||||
func EncodeOrderLimit(limit *pb.OrderLimit2) ([]byte, error) {
|
func EncodeOrderLimit(limit *pb.OrderLimit2) ([]byte, error) {
|
||||||
signature := limit.SatelliteSignature
|
signature := limit.SatelliteSignature
|
||||||
limit.SatelliteSignature = nil
|
limit.SatelliteSignature = nil
|
||||||
defer func() { limit.SatelliteSignature = signature }()
|
out, err := proto.Marshal(limit)
|
||||||
return proto.Marshal(limit)
|
limit.SatelliteSignature = signature
|
||||||
|
return out, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// EncodeOrder encodes order into bytes for signing.
|
// EncodeOrder encodes order into bytes for signing. Removes signature from serialized order.
|
||||||
func EncodeOrder(order *pb.Order2) ([]byte, error) {
|
func EncodeOrder(order *pb.Order2) ([]byte, error) {
|
||||||
signature := order.UplinkSignature
|
signature := order.UplinkSignature
|
||||||
order.UplinkSignature = nil
|
order.UplinkSignature = nil
|
||||||
defer func() { order.UplinkSignature = signature }()
|
out, err := proto.Marshal(order)
|
||||||
return proto.Marshal(order)
|
order.UplinkSignature = signature
|
||||||
|
return out, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// EncodePieceHash encodes piece hash into bytes for signing.
|
// EncodePieceHash encodes piece hash into bytes for signing. Removes signature from serialized hash.
|
||||||
func EncodePieceHash(hash *pb.PieceHash) ([]byte, error) {
|
func EncodePieceHash(hash *pb.PieceHash) ([]byte, error) {
|
||||||
signature := hash.Signature
|
signature := hash.Signature
|
||||||
hash.Signature = nil
|
hash.Signature = nil
|
||||||
defer func() { hash.Signature = signature }()
|
out, err := proto.Marshal(hash)
|
||||||
return proto.Marshal(hash)
|
hash.Signature = signature
|
||||||
|
return out, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user