From e75ddb05492f494046b56d2aca677a62981897f5 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Wed, 13 Jan 2021 15:48:33 +0300 Subject: [PATCH] [#306] private: Implement setters on generated proto messages Signed-off-by: Leonard Lyubich --- pkg/services/private/service.go | 60 +++++++++++++++++++++++++++++++++ pkg/services/private/types.go | 15 +++++++++ 2 files changed, 75 insertions(+) create mode 100644 pkg/services/private/service.go create mode 100644 pkg/services/private/types.go diff --git a/pkg/services/private/service.go b/pkg/services/private/service.go new file mode 100644 index 000000000..0c7555140 --- /dev/null +++ b/pkg/services/private/service.go @@ -0,0 +1,60 @@ +package private + +// SetBody sets health check request body. +func (m *HealthCheckRequest) SetBody(v *HealthCheckRequest_Body) { + if m != nil { + m.Body = v + } +} + +// SetSignature sets signature of the health check request body. +func (m *HealthCheckRequest) SetSignature(body *Signature) { + if m != nil { + m.Signature = body + } +} + +// ReadSignedData marshals request body to buf. +func (m *HealthCheckRequest) ReadSignedData(buf []byte) ([]byte, error) { + _, err := m.GetBody().MarshalTo(buf) + + return buf, err +} + +// SignedDataSize returns binary size of the request body. +func (m *HealthCheckRequest) SignedDataSize() int { + return m.GetBody().Size() +} + +// SetStatus sets health status of storage node. +func (m *HealthCheckResponse_Body) SetStatus(v HealthStatus) { + if m != nil { + m.Status = v + } +} + +// SetBody sets health check response body. +func (m *HealthCheckResponse) SetBody(v *HealthCheckResponse_Body) { + if m != nil { + m.Body = v + } +} + +// SetSignature sets signature of the health check response body. +func (m *HealthCheckResponse) SetSignature(v *Signature) { + if m != nil { + m.Signature = v + } +} + +// ReadSignedData marshals response body to buf. +func (m *HealthCheckResponse) ReadSignedData(buf []byte) ([]byte, error) { + _, err := m.GetBody().MarshalTo(buf) + + return buf, err +} + +// SignedDataSize returns binary size of the response body. +func (m *HealthCheckResponse) SignedDataSize() int { + return m.GetBody().Size() +} diff --git a/pkg/services/private/types.go b/pkg/services/private/types.go new file mode 100644 index 000000000..cc559852b --- /dev/null +++ b/pkg/services/private/types.go @@ -0,0 +1,15 @@ +package private + +// SetKey sets public key used for signing. +func (m *Signature) SetKey(v []byte) { + if m != nil { + m.Key = v + } +} + +// SetSign sets binary signature. +func (m *Signature) SetSign(v []byte) { + if m != nil { + m.Sign = v + } +}