2021-03-24 07:10:51 +00:00
|
|
|
package reputation
|
|
|
|
|
|
|
|
import (
|
2022-12-09 11:16:24 +00:00
|
|
|
"github.com/TrueCloudLab/frostfs-api-go/v2/refs"
|
|
|
|
refsGRPC "github.com/TrueCloudLab/frostfs-api-go/v2/refs/grpc"
|
|
|
|
reputation "github.com/TrueCloudLab/frostfs-api-go/v2/reputation/grpc"
|
|
|
|
"github.com/TrueCloudLab/frostfs-api-go/v2/rpc/grpc"
|
|
|
|
"github.com/TrueCloudLab/frostfs-api-go/v2/rpc/message"
|
2021-03-24 07:10:51 +00:00
|
|
|
)
|
|
|
|
|
2021-04-01 14:53:14 +00:00
|
|
|
// ToGRPCMessage converts PeerID to gRPC-generated
|
|
|
|
// reputation.PeerID message.
|
|
|
|
func (x *PeerID) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *reputation.PeerID
|
|
|
|
|
|
|
|
if x != nil {
|
|
|
|
m = new(reputation.PeerID)
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
m.SetPublicKey(x.publicKey)
|
2021-04-01 14:53:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
// FromGRPCMessage tries to restore PeerID from grpc.Message.
|
|
|
|
//
|
|
|
|
// Returns message.ErrUnexpectedMessageType if m is not
|
|
|
|
// a gRPC-generated reputation.PeerID message.
|
|
|
|
func (x *PeerID) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*reputation.PeerID)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
x.publicKey = v.GetPublicKey()
|
2021-04-01 14:53:14 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-03-24 07:10:51 +00:00
|
|
|
// ToGRPCMessage converts Trust to gRPC-generated
|
|
|
|
// reputation.Trust message.
|
|
|
|
func (x *Trust) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *reputation.Trust
|
|
|
|
|
|
|
|
if x != nil {
|
|
|
|
m = new(reputation.Trust)
|
|
|
|
|
|
|
|
m.SetValue(x.val)
|
2021-04-01 14:53:14 +00:00
|
|
|
m.SetPeer(x.peer.ToGRPCMessage().(*reputation.PeerID))
|
2021-03-24 07:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
// FromGRPCMessage tries to restore Trust from grpc.Message.
|
|
|
|
//
|
|
|
|
// Returns message.ErrUnexpectedMessageType if m is not
|
|
|
|
// a gRPC-generated reputation.Trust message.
|
|
|
|
func (x *Trust) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*reputation.Trust)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
2021-04-01 14:53:14 +00:00
|
|
|
peer := v.GetPeer()
|
|
|
|
if peer == nil {
|
|
|
|
x.peer = nil
|
|
|
|
} else {
|
|
|
|
if x.peer == nil {
|
|
|
|
x.peer = new(PeerID)
|
|
|
|
}
|
|
|
|
|
|
|
|
err := x.peer.FromGRPCMessage(peer)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-24 07:10:51 +00:00
|
|
|
x.val = v.GetValue()
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-04-09 08:28:06 +00:00
|
|
|
// ToGRPCMessage converts PeerToPeerTrust to gRPC-generated
|
|
|
|
// reputation.PeerToPeerTrust message.
|
|
|
|
func (x *PeerToPeerTrust) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *reputation.PeerToPeerTrust
|
|
|
|
|
|
|
|
if x != nil {
|
|
|
|
m = new(reputation.PeerToPeerTrust)
|
|
|
|
|
|
|
|
m.SetTrustingPeer(x.trusting.ToGRPCMessage().(*reputation.PeerID))
|
|
|
|
m.SetTrust(x.trust.ToGRPCMessage().(*reputation.Trust))
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
// FromGRPCMessage tries to restore PeerToPeerTrust from grpc.Message.
|
|
|
|
//
|
|
|
|
// Returns message.ErrUnexpectedMessageType if m is not
|
|
|
|
// a gRPC-generated reputation.PeerToPeerTrust message.
|
|
|
|
func (x *PeerToPeerTrust) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*reputation.PeerToPeerTrust)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
trusting := v.GetTrustingPeer()
|
|
|
|
if trusting == nil {
|
|
|
|
x.trusting = nil
|
|
|
|
} else {
|
|
|
|
if x.trusting == nil {
|
|
|
|
x.trusting = new(PeerID)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = x.trusting.FromGRPCMessage(trusting)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
trust := v.GetTrust()
|
|
|
|
if trust == nil {
|
|
|
|
x.trust = nil
|
|
|
|
} else {
|
|
|
|
if x.trust == nil {
|
|
|
|
x.trust = new(Trust)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = x.trust.FromGRPCMessage(trust)
|
|
|
|
}
|
|
|
|
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-03-24 07:10:51 +00:00
|
|
|
// TrustsToGRPC converts slice of Trust structures
|
|
|
|
// to slice of gRPC-generated Trust messages.
|
2022-03-02 08:40:47 +00:00
|
|
|
func TrustsToGRPC(xs []Trust) (res []*reputation.Trust) {
|
2021-03-24 07:10:51 +00:00
|
|
|
if xs != nil {
|
|
|
|
res = make([]*reputation.Trust, 0, len(xs))
|
|
|
|
|
|
|
|
for i := range xs {
|
|
|
|
res = append(res, xs[i].ToGRPCMessage().(*reputation.Trust))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// TrustsFromGRPC tries to restore slice of Trust structures from
|
|
|
|
// slice of gRPC-generated reputation.Trust messages.
|
2022-03-02 08:40:47 +00:00
|
|
|
func TrustsFromGRPC(xs []*reputation.Trust) (res []Trust, err error) {
|
2021-03-24 07:10:51 +00:00
|
|
|
if xs != nil {
|
2022-03-02 08:40:47 +00:00
|
|
|
res = make([]Trust, len(xs))
|
2021-03-24 07:10:51 +00:00
|
|
|
|
|
|
|
for i := range xs {
|
|
|
|
if xs[i] != nil {
|
2022-03-02 08:40:47 +00:00
|
|
|
err = res[i].FromGRPCMessage(xs[i])
|
2021-03-24 07:10:51 +00:00
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-04-01 14:53:14 +00:00
|
|
|
// ToGRPCMessage converts GlobalTrustBody to gRPC-generated
|
|
|
|
// reputation.GlobalTrust_Body message.
|
|
|
|
func (x *GlobalTrustBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *reputation.GlobalTrust_Body
|
|
|
|
|
|
|
|
if x != nil {
|
|
|
|
m = new(reputation.GlobalTrust_Body)
|
|
|
|
|
|
|
|
m.SetManager(x.manager.ToGRPCMessage().(*reputation.PeerID))
|
|
|
|
m.SetTrust(x.trust.ToGRPCMessage().(*reputation.Trust))
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
// FromGRPCMessage tries to restore GlobalTrustBody from grpc.Message.
|
|
|
|
//
|
|
|
|
// Returns message.ErrUnexpectedMessageType if m is not
|
|
|
|
// a gRPC-generated reputation.GlobalTrust_Body message.
|
|
|
|
func (x *GlobalTrustBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*reputation.GlobalTrust_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
manager := v.GetManager()
|
|
|
|
if manager == nil {
|
|
|
|
x.manager = nil
|
|
|
|
} else {
|
|
|
|
if x.manager == nil {
|
|
|
|
x.manager = new(PeerID)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = x.manager.FromGRPCMessage(manager)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
trust := v.GetTrust()
|
|
|
|
if trust == nil {
|
|
|
|
x.trust = nil
|
|
|
|
} else {
|
|
|
|
if x.trust == nil {
|
|
|
|
x.trust = new(Trust)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = x.trust.FromGRPCMessage(trust)
|
|
|
|
}
|
|
|
|
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// ToGRPCMessage converts GlobalTrust to gRPC-generated
|
|
|
|
// reputation.GlobalTrust message.
|
|
|
|
func (x *GlobalTrust) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *reputation.GlobalTrust
|
|
|
|
|
|
|
|
if x != nil {
|
|
|
|
m = new(reputation.GlobalTrust)
|
|
|
|
|
|
|
|
m.SetVersion(x.version.ToGRPCMessage().(*refsGRPC.Version))
|
|
|
|
m.SetBody(x.body.ToGRPCMessage().(*reputation.GlobalTrust_Body))
|
|
|
|
m.SetSignature(x.sig.ToGRPCMessage().(*refsGRPC.Signature))
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
// FromGRPCMessage tries to restore GlobalTrust from grpc.Message.
|
|
|
|
//
|
|
|
|
// Returns message.ErrUnexpectedMessageType if m is not
|
|
|
|
// a gRPC-generated reputation.GlobalTrust message.
|
|
|
|
func (x *GlobalTrust) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*reputation.GlobalTrust)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
version := v.GetVersion()
|
|
|
|
if version == nil {
|
|
|
|
x.version = nil
|
|
|
|
} else {
|
|
|
|
if x.version == nil {
|
|
|
|
x.version = new(refs.Version)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = x.version.FromGRPCMessage(version)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
|
|
|
x.body = nil
|
|
|
|
} else {
|
|
|
|
if x.body == nil {
|
|
|
|
x.body = new(GlobalTrustBody)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = x.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sig := v.GetSignature()
|
|
|
|
if sig == nil {
|
|
|
|
x.sig = nil
|
|
|
|
} else {
|
|
|
|
if x.sig == nil {
|
|
|
|
x.sig = new(refs.Signature)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = x.sig.FromGRPCMessage(sig)
|
|
|
|
}
|
|
|
|
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// ToGRPCMessage converts AnnounceLocalTrustRequestBody to gRPC-generated
|
|
|
|
// reputation.AnnounceLocalTrustRequest_Body message.
|
|
|
|
func (x *AnnounceLocalTrustRequestBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *reputation.AnnounceLocalTrustRequest_Body
|
2021-03-24 07:10:51 +00:00
|
|
|
|
|
|
|
if x != nil {
|
2021-05-07 09:34:24 +00:00
|
|
|
m = new(reputation.AnnounceLocalTrustRequest_Body)
|
2021-03-24 07:10:51 +00:00
|
|
|
|
|
|
|
m.SetEpoch(x.epoch)
|
|
|
|
m.SetTrusts(TrustsToGRPC(x.trusts))
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// FromGRPCMessage tries to restore AnnounceLocalTrustRequestBody from grpc.Message.
|
2021-03-24 07:10:51 +00:00
|
|
|
//
|
|
|
|
// Returns message.ErrUnexpectedMessageType if m is not
|
2021-05-07 09:34:24 +00:00
|
|
|
// a gRPC-generated reputation.AnnounceLocalTrustRequest_Body message.
|
|
|
|
func (x *AnnounceLocalTrustRequestBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*reputation.AnnounceLocalTrustRequest_Body)
|
2021-03-24 07:10:51 +00:00
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
x.trusts, err = TrustsFromGRPC(v.GetTrusts())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
x.epoch = v.GetEpoch()
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// ToGRPCMessage converts AnnounceLocalTrustRequest to gRPC-generated
|
|
|
|
// reputation.AnnounceLocalTrustRequest message.
|
|
|
|
func (x *AnnounceLocalTrustRequest) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *reputation.AnnounceLocalTrustRequest
|
2021-03-24 07:10:51 +00:00
|
|
|
|
|
|
|
if x != nil {
|
2021-05-07 09:34:24 +00:00
|
|
|
m = new(reputation.AnnounceLocalTrustRequest)
|
2021-03-24 07:10:51 +00:00
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
m.SetBody(x.body.ToGRPCMessage().(*reputation.AnnounceLocalTrustRequest_Body))
|
2021-03-24 07:10:51 +00:00
|
|
|
x.RequestHeaders.ToMessage(m)
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// FromGRPCMessage tries to restore AnnounceLocalTrustRequest from grpc.Message.
|
2021-03-24 07:10:51 +00:00
|
|
|
//
|
|
|
|
// Returns message.ErrUnexpectedMessageType if m is not
|
2021-05-07 09:34:24 +00:00
|
|
|
// a gRPC-generated reputation.AnnounceLocalTrustRequest message.
|
|
|
|
func (x *AnnounceLocalTrustRequest) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*reputation.AnnounceLocalTrustRequest)
|
2021-03-24 07:10:51 +00:00
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
|
|
|
x.body = nil
|
|
|
|
} else {
|
|
|
|
if x.body == nil {
|
2021-05-07 09:34:24 +00:00
|
|
|
x.body = new(AnnounceLocalTrustRequestBody)
|
2021-03-24 07:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = x.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return x.RequestHeaders.FromMessage(v)
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// ToGRPCMessage converts AnnounceLocalTrustResponseBody to gRPC-generated
|
|
|
|
// reputation.AnnounceLocalTrustResponse_Body message.
|
|
|
|
func (x *AnnounceLocalTrustResponseBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *reputation.AnnounceLocalTrustResponse_Body
|
2021-03-24 07:10:51 +00:00
|
|
|
|
|
|
|
if x != nil {
|
2021-05-07 09:34:24 +00:00
|
|
|
m = new(reputation.AnnounceLocalTrustResponse_Body)
|
2021-03-24 07:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// FromGRPCMessage tries to restore AnnounceLocalTrustResponseBody from grpc.Message.
|
2021-03-24 07:10:51 +00:00
|
|
|
//
|
|
|
|
// Returns message.ErrUnexpectedMessageType if m is not
|
2021-05-07 09:34:24 +00:00
|
|
|
// a gRPC-generated reputation.AnnounceLocalTrustResponse_Body message.
|
|
|
|
func (x *AnnounceLocalTrustResponseBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*reputation.AnnounceLocalTrustResponse_Body)
|
2021-03-24 07:10:51 +00:00
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// ToGRPCMessage converts AnnounceLocalTrustResponse to gRPC-generated
|
|
|
|
// reputation.AnnounceLocalTrustResponse message.
|
|
|
|
func (x *AnnounceLocalTrustResponse) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *reputation.AnnounceLocalTrustResponse
|
2021-03-24 07:10:51 +00:00
|
|
|
|
|
|
|
if x != nil {
|
2021-05-07 09:34:24 +00:00
|
|
|
m = new(reputation.AnnounceLocalTrustResponse)
|
2021-03-24 07:10:51 +00:00
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
m.SetBody(x.body.ToGRPCMessage().(*reputation.AnnounceLocalTrustResponse_Body))
|
2021-03-24 07:10:51 +00:00
|
|
|
x.ResponseHeaders.ToMessage(m)
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// FromGRPCMessage tries to restore AnnounceLocalTrustResponse from grpc.Message.
|
2021-03-24 07:10:51 +00:00
|
|
|
//
|
|
|
|
// Returns message.ErrUnexpectedMessageType if m is not
|
2021-05-07 09:34:24 +00:00
|
|
|
// a gRPC-generated reputation.AnnounceLocalTrustResponse message.
|
|
|
|
func (x *AnnounceLocalTrustResponse) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*reputation.AnnounceLocalTrustResponse)
|
2021-03-24 07:10:51 +00:00
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
|
|
|
x.body = nil
|
|
|
|
} else {
|
|
|
|
if x.body == nil {
|
2021-05-07 09:34:24 +00:00
|
|
|
x.body = new(AnnounceLocalTrustResponseBody)
|
2021-03-24 07:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = x.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return x.ResponseHeaders.FromMessage(v)
|
|
|
|
}
|
2021-04-01 14:53:14 +00:00
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// ToGRPCMessage converts AnnounceIntermediateResultRequestBody to gRPC-generated
|
|
|
|
// reputation.AnnounceIntermediateResultRequest_Body message.
|
|
|
|
func (x *AnnounceIntermediateResultRequestBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *reputation.AnnounceIntermediateResultRequest_Body
|
2021-04-01 14:53:14 +00:00
|
|
|
|
|
|
|
if x != nil {
|
2021-05-07 09:34:24 +00:00
|
|
|
m = new(reputation.AnnounceIntermediateResultRequest_Body)
|
2021-04-01 14:53:14 +00:00
|
|
|
|
2021-04-22 07:40:12 +00:00
|
|
|
m.SetEpoch(x.epoch)
|
2021-04-01 14:53:14 +00:00
|
|
|
m.SetIteration(x.iter)
|
2021-04-09 08:28:06 +00:00
|
|
|
m.SetTrust(x.trust.ToGRPCMessage().(*reputation.PeerToPeerTrust))
|
2021-04-01 14:53:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// FromGRPCMessage tries to restore AnnounceIntermediateResultRequestBody from grpc.Message.
|
2021-04-01 14:53:14 +00:00
|
|
|
//
|
|
|
|
// Returns message.ErrUnexpectedMessageType if m is not
|
2021-05-07 09:34:24 +00:00
|
|
|
// a gRPC-generated reputation.AnnounceIntermediateResultRequest_Body message.
|
|
|
|
func (x *AnnounceIntermediateResultRequestBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*reputation.AnnounceIntermediateResultRequest_Body)
|
2021-04-01 14:53:14 +00:00
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
2021-04-27 06:52:23 +00:00
|
|
|
trust := v.GetTrust()
|
|
|
|
if trust == nil {
|
|
|
|
x.trust = nil
|
|
|
|
} else {
|
|
|
|
if x.trust == nil {
|
|
|
|
x.trust = new(PeerToPeerTrust)
|
|
|
|
}
|
|
|
|
|
|
|
|
err := x.trust.FromGRPCMessage(trust)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-04-01 14:53:14 +00:00
|
|
|
}
|
|
|
|
|
2021-04-22 07:40:12 +00:00
|
|
|
x.epoch = v.GetEpoch()
|
2021-04-01 14:53:14 +00:00
|
|
|
x.iter = v.GetIteration()
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// ToGRPCMessage converts AnnounceIntermediateResultRequest to gRPC-generated
|
|
|
|
// reputation.AnnounceIntermediateResultRequest message.
|
|
|
|
func (x *AnnounceIntermediateResultRequest) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *reputation.AnnounceIntermediateResultRequest
|
2021-04-01 14:53:14 +00:00
|
|
|
|
|
|
|
if x != nil {
|
2021-05-07 09:34:24 +00:00
|
|
|
m = new(reputation.AnnounceIntermediateResultRequest)
|
2021-04-01 14:53:14 +00:00
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
m.SetBody(x.body.ToGRPCMessage().(*reputation.AnnounceIntermediateResultRequest_Body))
|
2021-04-01 14:53:14 +00:00
|
|
|
x.RequestHeaders.ToMessage(m)
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// FromGRPCMessage tries to restore AnnounceIntermediateResultRequest from grpc.Message.
|
2021-04-01 14:53:14 +00:00
|
|
|
//
|
|
|
|
// Returns message.ErrUnexpectedMessageType if m is not
|
2021-05-07 09:34:24 +00:00
|
|
|
// a gRPC-generated reputation.AnnounceIntermediateResultRequest message.
|
|
|
|
func (x *AnnounceIntermediateResultRequest) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*reputation.AnnounceIntermediateResultRequest)
|
2021-04-01 14:53:14 +00:00
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
|
|
|
x.body = nil
|
|
|
|
} else {
|
|
|
|
if x.body == nil {
|
2021-05-07 09:34:24 +00:00
|
|
|
x.body = new(AnnounceIntermediateResultRequestBody)
|
2021-04-01 14:53:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = x.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return x.RequestHeaders.FromMessage(v)
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// ToGRPCMessage converts AnnounceIntermediateResultResponseBody to gRPC-generated
|
|
|
|
// reputation.AnnounceIntermediateResultResponse_Body message.
|
|
|
|
func (x *AnnounceIntermediateResultResponseBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *reputation.AnnounceIntermediateResultResponse_Body
|
2021-04-01 14:53:14 +00:00
|
|
|
|
|
|
|
if x != nil {
|
2021-05-07 09:34:24 +00:00
|
|
|
m = new(reputation.AnnounceIntermediateResultResponse_Body)
|
2021-04-01 14:53:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// FromGRPCMessage tries to restore AnnounceIntermediateResultResponseBody from grpc.Message.
|
2021-04-01 14:53:14 +00:00
|
|
|
//
|
|
|
|
// Returns message.ErrUnexpectedMessageType if m is not
|
2021-05-07 09:34:24 +00:00
|
|
|
// a gRPC-generated reputation.AnnounceIntermediateResultResponse_Body message.
|
|
|
|
func (x *AnnounceIntermediateResultResponseBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*reputation.AnnounceIntermediateResultResponse_Body)
|
2021-04-01 14:53:14 +00:00
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// ToGRPCMessage converts AnnounceIntermediateResultResponse to gRPC-generated
|
|
|
|
// reputation.AnnounceIntermediateResultResponse message.
|
|
|
|
func (x *AnnounceIntermediateResultResponse) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *reputation.AnnounceIntermediateResultResponse
|
2021-04-01 14:53:14 +00:00
|
|
|
|
|
|
|
if x != nil {
|
2021-05-07 09:34:24 +00:00
|
|
|
m = new(reputation.AnnounceIntermediateResultResponse)
|
2021-04-01 14:53:14 +00:00
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
m.SetBody(x.body.ToGRPCMessage().(*reputation.AnnounceIntermediateResultResponse_Body))
|
2021-04-01 14:53:14 +00:00
|
|
|
x.ResponseHeaders.ToMessage(m)
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// FromGRPCMessage tries to restore AnnounceIntermediateResultResponse from grpc.Message.
|
2021-04-01 14:53:14 +00:00
|
|
|
//
|
|
|
|
// Returns message.ErrUnexpectedMessageType if m is not
|
2021-05-07 09:34:24 +00:00
|
|
|
// a gRPC-generated reputation.AnnounceIntermediateResultResponse message.
|
|
|
|
func (x *AnnounceIntermediateResultResponse) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*reputation.AnnounceIntermediateResultResponse)
|
2021-04-01 14:53:14 +00:00
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
|
|
|
x.body = nil
|
|
|
|
} else {
|
|
|
|
if x.body == nil {
|
2021-05-07 09:34:24 +00:00
|
|
|
x.body = new(AnnounceIntermediateResultResponseBody)
|
2021-04-01 14:53:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = x.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return x.ResponseHeaders.FromMessage(v)
|
|
|
|
}
|