From 46b3feabe1e82b7a125b2195af9e84291e4b2eec Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Thu, 1 Apr 2021 17:35:40 +0300 Subject: [PATCH] [#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 --- v2/reputation/types.go | 217 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 214 insertions(+), 3 deletions(-) diff --git a/v2/reputation/types.go b/v2/reputation/types.go index 12cb3de..3b67c13 100644 --- a/v2/reputation/types.go +++ b/v2/reputation/types.go @@ -1,19 +1,42 @@ package reputation import ( + "github.com/nspcc-dev/neofs-api-go/v2/refs" "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 // from NeoFS API v2. type Trust struct { val float64 - peer []byte + peer *PeerID } // GetPeer returns trusted peer's ID. -func (x *Trust) GetPeer() []byte { +func (x *Trust) GetPeer() *PeerID { if x != nil { return x.peer } @@ -22,7 +45,7 @@ func (x *Trust) GetPeer() []byte { } // SetPeer sets trusted peer's ID. -func (x *Trust) SetPeer(v []byte) { +func (x *Trust) SetPeer(v *PeerID) { if x != nil { 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. type SendLocalTrustRequestBody struct { epoch uint64 @@ -133,3 +254,93 @@ func (x *SendLocalTrustResponse) SetBody(v *SendLocalTrustResponseBody) { 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 + } +}