[#265] reputation: Define structures of protobuf messages

Define Go structures of `SendIntermediateResult` RPC-related messages from
reputation package of NeoFS API. Implement getters and setters of message
fields.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-04-01 17:35:40 +03:00 committed by Leonard Lyubich
parent ca2e272d42
commit 46b3feabe1

View file

@ -1,19 +1,42 @@
package reputation package reputation
import ( import (
"github.com/nspcc-dev/neofs-api-go/v2/refs"
"github.com/nspcc-dev/neofs-api-go/v2/session" "github.com/nspcc-dev/neofs-api-go/v2/session"
) )
// PeerID represents reputation.PeerID message
// from NeoFS API v2.
type PeerID struct {
val []byte
}
// GetValue returns peer's binary ID.
func (x *PeerID) GetValue() []byte {
if x != nil {
return x.val
}
return nil
}
// SetValue sets peer's binary ID.
func (x *PeerID) SetValue(v []byte) {
if x != nil {
x.val = v
}
}
// Trust represents reputation.Trust message // Trust represents reputation.Trust message
// from NeoFS API v2. // from NeoFS API v2.
type Trust struct { type Trust struct {
val float64 val float64
peer []byte peer *PeerID
} }
// GetPeer returns trusted peer's ID. // GetPeer returns trusted peer's ID.
func (x *Trust) GetPeer() []byte { func (x *Trust) GetPeer() *PeerID {
if x != nil { if x != nil {
return x.peer return x.peer
} }
@ -22,7 +45,7 @@ func (x *Trust) GetPeer() []byte {
} }
// SetPeer sets trusted peer's ID. // SetPeer sets trusted peer's ID.
func (x *Trust) SetPeer(v []byte) { func (x *Trust) SetPeer(v *PeerID) {
if x != nil { if x != nil {
x.peer = v x.peer = v
} }
@ -44,6 +67,104 @@ func (x *Trust) SetValue(v float64) {
} }
} }
// GlobalTrustBody represents reputation.GlobalTrust.Body message
// from NeoFS API v2.
type GlobalTrustBody struct {
manager *PeerID
trust *Trust
}
// GetManager returns node manager ID.
func (x *GlobalTrustBody) GetManager() *PeerID {
if x != nil {
return x.manager
}
return nil
}
// SetManager sets node manager ID.
func (x *GlobalTrustBody) SetManager(v *PeerID) {
if x != nil {
x.manager = v
}
}
// GetTrust returns global trust value.
func (x *GlobalTrustBody) GetTrust() *Trust {
if x != nil {
return x.trust
}
return nil
}
// SetTrust sets global trust value.
func (x *GlobalTrustBody) SetTrust(v *Trust) {
if x != nil {
x.trust = v
}
}
// GlobalTrust represents reputation.GlobalTrust message
// from NeoFS API v2.
type GlobalTrust struct {
version *refs.Version
body *GlobalTrustBody
sig *refs.Signature
}
// GetVersion returns message format version.
func (x *GlobalTrust) GetVersion() *refs.Version {
if x != nil {
return x.version
}
return nil
}
// SetVersion sets message format version.
func (x *GlobalTrust) SetVersion(v *refs.Version) {
if x != nil {
x.version = v
}
}
// GetBody returns message body.
func (x *GlobalTrust) GetBody() *GlobalTrustBody {
if x != nil {
return x.body
}
return nil
}
// SetBody sets message body.
func (x *GlobalTrust) SetBody(v *GlobalTrustBody) {
if x != nil {
x.body = v
}
}
// GetSignature returns body signature.
func (x *GlobalTrust) GetSignature() *refs.Signature {
if x != nil {
return x.sig
}
return nil
}
// SetSignature sets body signature.
func (x *GlobalTrust) SetSignature(v *refs.Signature) {
if x != nil {
x.sig = v
}
}
// SendLocalTrustRequestBody is a structure of SendLocalTrust request body. // SendLocalTrustRequestBody is a structure of SendLocalTrust request body.
type SendLocalTrustRequestBody struct { type SendLocalTrustRequestBody struct {
epoch uint64 epoch uint64
@ -133,3 +254,93 @@ func (x *SendLocalTrustResponse) SetBody(v *SendLocalTrustResponseBody) {
x.body = v x.body = v
} }
} }
// SendIntermediateResultRequestBody is a structure of SendIntermediateResult request body.
type SendIntermediateResultRequestBody struct {
iter uint32
trust *Trust
}
// GetIteration returns sequence number of the iteration.
func (x *SendIntermediateResultRequestBody) GetIteration() uint32 {
if x != nil {
return x.iter
}
return 0
}
// SetIteration sets sequence number of the iteration.
func (x *SendIntermediateResultRequestBody) SetIteration(v uint32) {
if x != nil {
x.iter = v
}
}
// GetTrust returns current global trust value.
func (x *SendIntermediateResultRequestBody) GetTrust() *Trust {
if x != nil {
return x.trust
}
return nil
}
// SetTrust sets current global trust value.
func (x *SendIntermediateResultRequestBody) SetTrust(v *Trust) {
if x != nil {
x.trust = v
}
}
// SendLocalTrustResponseBody is a structure of SendIntermediateResult response body.
type SendIntermediateResultResponseBody struct{}
// SendIntermediateResultRequest represents reputation.SendIntermediateResult
// message from NeoFS API v2.
type SendIntermediateResultRequest struct {
body *SendIntermediateResultRequestBody
session.RequestHeaders
}
// GetBody returns request body.
func (x *SendIntermediateResultRequest) GetBody() *SendIntermediateResultRequestBody {
if x != nil {
return x.body
}
return nil
}
// SetBody sets request body.
func (x *SendIntermediateResultRequest) SetBody(v *SendIntermediateResultRequestBody) {
if x != nil {
x.body = v
}
}
// SendIntermediateResultResponse represents reputation.SendIntermediateResultResponse
// message from NeoFS API v2.
type SendIntermediateResultResponse struct {
body *SendIntermediateResultResponseBody
session.ResponseHeaders
}
// GetBody returns response body.
func (x *SendIntermediateResultResponse) GetBody() *SendIntermediateResultResponseBody {
if x != nil {
return x.body
}
return nil
}
// SetBody sets response body.
func (x *SendIntermediateResultResponse) SetBody(v *SendIntermediateResultResponseBody) {
if x != nil {
x.body = v
}
}