Del/Drop reputation system #21
38 changed files with 3 additions and 1680 deletions
|
@ -7,6 +7,9 @@
|
|||
|
||||
### Fixed
|
||||
### Changed
|
||||
### Removed
|
||||
- Reputation system (#21)
|
||||
|
||||
### Updated
|
||||
|
||||
## 2.15.0 - 2023-04-11
|
||||
|
|
BIN
accounting/grpc/service.pb.go
generated
BIN
accounting/grpc/service.pb.go
generated
Binary file not shown.
BIN
accounting/grpc/service_grpc.pb.go
generated
BIN
accounting/grpc/service_grpc.pb.go
generated
Binary file not shown.
BIN
accounting/grpc/types.pb.go
generated
BIN
accounting/grpc/types.pb.go
generated
Binary file not shown.
BIN
acl/grpc/types.pb.go
generated
BIN
acl/grpc/types.pb.go
generated
Binary file not shown.
BIN
audit/grpc/types.pb.go
generated
BIN
audit/grpc/types.pb.go
generated
Binary file not shown.
BIN
container/grpc/service.pb.go
generated
BIN
container/grpc/service.pb.go
generated
Binary file not shown.
BIN
container/grpc/service_grpc.pb.go
generated
BIN
container/grpc/service_grpc.pb.go
generated
Binary file not shown.
BIN
container/grpc/types.pb.go
generated
BIN
container/grpc/types.pb.go
generated
Binary file not shown.
BIN
lock/grpc/types.pb.go
generated
BIN
lock/grpc/types.pb.go
generated
Binary file not shown.
BIN
netmap/grpc/service.pb.go
generated
BIN
netmap/grpc/service.pb.go
generated
Binary file not shown.
BIN
netmap/grpc/service_grpc.pb.go
generated
BIN
netmap/grpc/service_grpc.pb.go
generated
Binary file not shown.
BIN
netmap/grpc/types.pb.go
generated
BIN
netmap/grpc/types.pb.go
generated
Binary file not shown.
BIN
object/grpc/service.pb.go
generated
BIN
object/grpc/service.pb.go
generated
Binary file not shown.
BIN
object/grpc/service_grpc.pb.go
generated
BIN
object/grpc/service_grpc.pb.go
generated
Binary file not shown.
BIN
object/grpc/types.pb.go
generated
BIN
object/grpc/types.pb.go
generated
Binary file not shown.
BIN
refs/grpc/types.pb.go
generated
BIN
refs/grpc/types.pb.go
generated
Binary file not shown.
|
@ -1,604 +0,0 @@
|
|||
package reputation
|
||||
|
||||
import (
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs"
|
||||
refsGRPC "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs/grpc"
|
||||
reputation "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/reputation/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message"
|
||||
)
|
||||
|
||||
// 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)
|
||||
|
||||
m.SetPublicKey(x.publicKey)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
x.publicKey = v.GetPublicKey()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// 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)
|
||||
m.SetPeer(x.peer.ToGRPCMessage().(*reputation.PeerID))
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
x.val = v.GetValue()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// TrustsToGRPC converts slice of Trust structures
|
||||
// to slice of gRPC-generated Trust messages.
|
||||
func TrustsToGRPC(xs []Trust) (res []*reputation.Trust) {
|
||||
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.
|
||||
func TrustsFromGRPC(xs []*reputation.Trust) (res []Trust, err error) {
|
||||
if xs != nil {
|
||||
res = make([]Trust, len(xs))
|
||||
|
||||
for i := range xs {
|
||||
if xs[i] != nil {
|
||||
err = res[i].FromGRPCMessage(xs[i])
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// ToGRPCMessage converts AnnounceLocalTrustRequestBody to gRPC-generated
|
||||
// reputation.AnnounceLocalTrustRequest_Body message.
|
||||
func (x *AnnounceLocalTrustRequestBody) ToGRPCMessage() grpc.Message {
|
||||
var m *reputation.AnnounceLocalTrustRequest_Body
|
||||
|
||||
if x != nil {
|
||||
m = new(reputation.AnnounceLocalTrustRequest_Body)
|
||||
|
||||
m.SetEpoch(x.epoch)
|
||||
m.SetTrusts(TrustsToGRPC(x.trusts))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
// FromGRPCMessage tries to restore AnnounceLocalTrustRequestBody from grpc.Message.
|
||||
//
|
||||
// Returns message.ErrUnexpectedMessageType if m is not
|
||||
// a gRPC-generated reputation.AnnounceLocalTrustRequest_Body message.
|
||||
func (x *AnnounceLocalTrustRequestBody) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*reputation.AnnounceLocalTrustRequest_Body)
|
||||
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
|
||||
}
|
||||
|
||||
// ToGRPCMessage converts AnnounceLocalTrustRequest to gRPC-generated
|
||||
// reputation.AnnounceLocalTrustRequest message.
|
||||
func (x *AnnounceLocalTrustRequest) ToGRPCMessage() grpc.Message {
|
||||
var m *reputation.AnnounceLocalTrustRequest
|
||||
|
||||
if x != nil {
|
||||
m = new(reputation.AnnounceLocalTrustRequest)
|
||||
|
||||
m.SetBody(x.body.ToGRPCMessage().(*reputation.AnnounceLocalTrustRequest_Body))
|
||||
x.RequestHeaders.ToMessage(m)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
// FromGRPCMessage tries to restore AnnounceLocalTrustRequest from grpc.Message.
|
||||
//
|
||||
// Returns message.ErrUnexpectedMessageType if m is not
|
||||
// a gRPC-generated reputation.AnnounceLocalTrustRequest message.
|
||||
func (x *AnnounceLocalTrustRequest) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*reputation.AnnounceLocalTrustRequest)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
body := v.GetBody()
|
||||
if body == nil {
|
||||
x.body = nil
|
||||
} else {
|
||||
if x.body == nil {
|
||||
x.body = new(AnnounceLocalTrustRequestBody)
|
||||
}
|
||||
|
||||
err = x.body.FromGRPCMessage(body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return x.RequestHeaders.FromMessage(v)
|
||||
}
|
||||
|
||||
// ToGRPCMessage converts AnnounceLocalTrustResponseBody to gRPC-generated
|
||||
// reputation.AnnounceLocalTrustResponse_Body message.
|
||||
func (x *AnnounceLocalTrustResponseBody) ToGRPCMessage() grpc.Message {
|
||||
var m *reputation.AnnounceLocalTrustResponse_Body
|
||||
|
||||
if x != nil {
|
||||
m = new(reputation.AnnounceLocalTrustResponse_Body)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
// FromGRPCMessage tries to restore AnnounceLocalTrustResponseBody from grpc.Message.
|
||||
//
|
||||
// Returns message.ErrUnexpectedMessageType if m is not
|
||||
// a gRPC-generated reputation.AnnounceLocalTrustResponse_Body message.
|
||||
func (x *AnnounceLocalTrustResponseBody) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*reputation.AnnounceLocalTrustResponse_Body)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ToGRPCMessage converts AnnounceLocalTrustResponse to gRPC-generated
|
||||
// reputation.AnnounceLocalTrustResponse message.
|
||||
func (x *AnnounceLocalTrustResponse) ToGRPCMessage() grpc.Message {
|
||||
var m *reputation.AnnounceLocalTrustResponse
|
||||
|
||||
if x != nil {
|
||||
m = new(reputation.AnnounceLocalTrustResponse)
|
||||
|
||||
m.SetBody(x.body.ToGRPCMessage().(*reputation.AnnounceLocalTrustResponse_Body))
|
||||
x.ResponseHeaders.ToMessage(m)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
// FromGRPCMessage tries to restore AnnounceLocalTrustResponse from grpc.Message.
|
||||
//
|
||||
// Returns message.ErrUnexpectedMessageType if m is not
|
||||
// a gRPC-generated reputation.AnnounceLocalTrustResponse message.
|
||||
func (x *AnnounceLocalTrustResponse) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*reputation.AnnounceLocalTrustResponse)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
body := v.GetBody()
|
||||
if body == nil {
|
||||
x.body = nil
|
||||
} else {
|
||||
if x.body == nil {
|
||||
x.body = new(AnnounceLocalTrustResponseBody)
|
||||
}
|
||||
|
||||
err = x.body.FromGRPCMessage(body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return x.ResponseHeaders.FromMessage(v)
|
||||
}
|
||||
|
||||
// ToGRPCMessage converts AnnounceIntermediateResultRequestBody to gRPC-generated
|
||||
// reputation.AnnounceIntermediateResultRequest_Body message.
|
||||
func (x *AnnounceIntermediateResultRequestBody) ToGRPCMessage() grpc.Message {
|
||||
var m *reputation.AnnounceIntermediateResultRequest_Body
|
||||
|
||||
if x != nil {
|
||||
m = new(reputation.AnnounceIntermediateResultRequest_Body)
|
||||
|
||||
m.SetEpoch(x.epoch)
|
||||
m.SetIteration(x.iter)
|
||||
m.SetTrust(x.trust.ToGRPCMessage().(*reputation.PeerToPeerTrust))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
// FromGRPCMessage tries to restore AnnounceIntermediateResultRequestBody from grpc.Message.
|
||||
//
|
||||
// Returns message.ErrUnexpectedMessageType if m is not
|
||||
// a gRPC-generated reputation.AnnounceIntermediateResultRequest_Body message.
|
||||
func (x *AnnounceIntermediateResultRequestBody) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*reputation.AnnounceIntermediateResultRequest_Body)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
x.epoch = v.GetEpoch()
|
||||
x.iter = v.GetIteration()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ToGRPCMessage converts AnnounceIntermediateResultRequest to gRPC-generated
|
||||
// reputation.AnnounceIntermediateResultRequest message.
|
||||
func (x *AnnounceIntermediateResultRequest) ToGRPCMessage() grpc.Message {
|
||||
var m *reputation.AnnounceIntermediateResultRequest
|
||||
|
||||
if x != nil {
|
||||
m = new(reputation.AnnounceIntermediateResultRequest)
|
||||
|
||||
m.SetBody(x.body.ToGRPCMessage().(*reputation.AnnounceIntermediateResultRequest_Body))
|
||||
x.RequestHeaders.ToMessage(m)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
// FromGRPCMessage tries to restore AnnounceIntermediateResultRequest from grpc.Message.
|
||||
//
|
||||
// Returns message.ErrUnexpectedMessageType if m is not
|
||||
// a gRPC-generated reputation.AnnounceIntermediateResultRequest message.
|
||||
func (x *AnnounceIntermediateResultRequest) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*reputation.AnnounceIntermediateResultRequest)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
body := v.GetBody()
|
||||
if body == nil {
|
||||
x.body = nil
|
||||
} else {
|
||||
if x.body == nil {
|
||||
x.body = new(AnnounceIntermediateResultRequestBody)
|
||||
}
|
||||
|
||||
err = x.body.FromGRPCMessage(body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return x.RequestHeaders.FromMessage(v)
|
||||
}
|
||||
|
||||
// ToGRPCMessage converts AnnounceIntermediateResultResponseBody to gRPC-generated
|
||||
// reputation.AnnounceIntermediateResultResponse_Body message.
|
||||
func (x *AnnounceIntermediateResultResponseBody) ToGRPCMessage() grpc.Message {
|
||||
var m *reputation.AnnounceIntermediateResultResponse_Body
|
||||
|
||||
if x != nil {
|
||||
m = new(reputation.AnnounceIntermediateResultResponse_Body)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
// FromGRPCMessage tries to restore AnnounceIntermediateResultResponseBody from grpc.Message.
|
||||
//
|
||||
// Returns message.ErrUnexpectedMessageType if m is not
|
||||
// a gRPC-generated reputation.AnnounceIntermediateResultResponse_Body message.
|
||||
func (x *AnnounceIntermediateResultResponseBody) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*reputation.AnnounceIntermediateResultResponse_Body)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ToGRPCMessage converts AnnounceIntermediateResultResponse to gRPC-generated
|
||||
// reputation.AnnounceIntermediateResultResponse message.
|
||||
func (x *AnnounceIntermediateResultResponse) ToGRPCMessage() grpc.Message {
|
||||
var m *reputation.AnnounceIntermediateResultResponse
|
||||
|
||||
if x != nil {
|
||||
m = new(reputation.AnnounceIntermediateResultResponse)
|
||||
|
||||
m.SetBody(x.body.ToGRPCMessage().(*reputation.AnnounceIntermediateResultResponse_Body))
|
||||
x.ResponseHeaders.ToMessage(m)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
// FromGRPCMessage tries to restore AnnounceIntermediateResultResponse from grpc.Message.
|
||||
//
|
||||
// Returns message.ErrUnexpectedMessageType if m is not
|
||||
// a gRPC-generated reputation.AnnounceIntermediateResultResponse message.
|
||||
func (x *AnnounceIntermediateResultResponse) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*reputation.AnnounceIntermediateResultResponse)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
body := v.GetBody()
|
||||
if body == nil {
|
||||
x.body = nil
|
||||
} else {
|
||||
if x.body == nil {
|
||||
x.body = new(AnnounceIntermediateResultResponseBody)
|
||||
}
|
||||
|
||||
err = x.body.FromGRPCMessage(body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return x.ResponseHeaders.FromMessage(v)
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
package reputation
|
||||
|
||||
import (
|
||||
session "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session/grpc"
|
||||
)
|
||||
|
||||
// SetEpoch sets epoch in which the trust was assessed.
|
||||
func (x *AnnounceLocalTrustRequest_Body) SetEpoch(v uint64) {
|
||||
x.Epoch = v
|
||||
}
|
||||
|
||||
// SetTrusts sets list of normalized trust values.
|
||||
func (x *AnnounceLocalTrustRequest_Body) SetTrusts(v []*Trust) {
|
||||
x.Trusts = v
|
||||
}
|
||||
|
||||
// SetBody sets body of the request.
|
||||
func (x *AnnounceLocalTrustRequest) SetBody(v *AnnounceLocalTrustRequest_Body) {
|
||||
x.Body = v
|
||||
}
|
||||
|
||||
// SetMetaHeader sets meta header of the request.
|
||||
func (x *AnnounceLocalTrustRequest) SetMetaHeader(v *session.RequestMetaHeader) {
|
||||
x.MetaHeader = v
|
||||
}
|
||||
|
||||
// SetVerifyHeader sets verification header of the request.
|
||||
func (x *AnnounceLocalTrustRequest) SetVerifyHeader(v *session.RequestVerificationHeader) {
|
||||
x.VerifyHeader = v
|
||||
}
|
||||
|
||||
// SetBody sets body of the response.
|
||||
func (x *AnnounceLocalTrustResponse) SetBody(v *AnnounceLocalTrustResponse_Body) {
|
||||
x.Body = v
|
||||
}
|
||||
|
||||
// SetMetaHeader sets meta header of the response.
|
||||
func (x *AnnounceLocalTrustResponse) SetMetaHeader(v *session.ResponseMetaHeader) {
|
||||
x.MetaHeader = v
|
||||
}
|
||||
|
||||
// SetVerifyHeader sets verification header of the response.
|
||||
func (x *AnnounceLocalTrustResponse) SetVerifyHeader(v *session.ResponseVerificationHeader) {
|
||||
x.VerifyHeader = v
|
||||
}
|
||||
|
||||
// SetEpoch sets epoch in which the intermediate trust was assessed.
|
||||
func (x *AnnounceIntermediateResultRequest_Body) SetEpoch(v uint64) {
|
||||
x.Epoch = v
|
||||
}
|
||||
|
||||
// SetIteration sets sequence number of the iteration.
|
||||
func (x *AnnounceIntermediateResultRequest_Body) SetIteration(v uint32) {
|
||||
x.Iteration = v
|
||||
}
|
||||
|
||||
// SetTrust sets current global trust value.
|
||||
func (x *AnnounceIntermediateResultRequest_Body) SetTrust(v *PeerToPeerTrust) {
|
||||
x.Trust = v
|
||||
}
|
||||
|
||||
// SetBody sets body of the request.
|
||||
func (x *AnnounceIntermediateResultRequest) SetBody(v *AnnounceIntermediateResultRequest_Body) {
|
||||
x.Body = v
|
||||
}
|
||||
|
||||
// SetMetaHeader sets meta header of the request.
|
||||
func (x *AnnounceIntermediateResultRequest) SetMetaHeader(v *session.RequestMetaHeader) {
|
||||
x.MetaHeader = v
|
||||
}
|
||||
|
||||
// SetVerifyHeader sets verification header of the request.
|
||||
func (x *AnnounceIntermediateResultRequest) SetVerifyHeader(v *session.RequestVerificationHeader) {
|
||||
x.VerifyHeader = v
|
||||
}
|
||||
|
||||
// SetBody sets body of the response.
|
||||
func (x *AnnounceIntermediateResultResponse) SetBody(v *AnnounceIntermediateResultResponse_Body) {
|
||||
x.Body = v
|
||||
}
|
||||
|
||||
// SetMetaHeader sets meta header of the response.
|
||||
func (x *AnnounceIntermediateResultResponse) SetMetaHeader(v *session.ResponseMetaHeader) {
|
||||
x.MetaHeader = v
|
||||
}
|
||||
|
||||
// SetVerifyHeader sets verification header of the response.
|
||||
func (x *AnnounceIntermediateResultResponse) SetVerifyHeader(v *session.ResponseVerificationHeader) {
|
||||
x.VerifyHeader = v
|
||||
}
|
BIN
reputation/grpc/service.pb.go
generated
BIN
reputation/grpc/service.pb.go
generated
Binary file not shown.
BIN
reputation/grpc/service_grpc.pb.go
generated
BIN
reputation/grpc/service_grpc.pb.go
generated
Binary file not shown.
|
@ -1,55 +0,0 @@
|
|||
package reputation
|
||||
|
||||
import (
|
||||
refs "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs/grpc"
|
||||
)
|
||||
|
||||
// SetPublicKey sets binary public key of ID.
|
||||
func (x *PeerID) SetPublicKey(v []byte) {
|
||||
x.PublicKey = v
|
||||
}
|
||||
|
||||
// SetPeer sets trusted peer's ID.
|
||||
func (x *Trust) SetPeer(v *PeerID) {
|
||||
x.Peer = v
|
||||
}
|
||||
|
||||
// SetValue sets trust value.
|
||||
func (x *Trust) SetValue(v float64) {
|
||||
x.Value = v
|
||||
}
|
||||
|
||||
// SetTrustingPeer sets trusting peer ID.
|
||||
func (x *PeerToPeerTrust) SetTrustingPeer(v *PeerID) {
|
||||
x.TrustingPeer = v
|
||||
}
|
||||
|
||||
// SetTrust sets trust value of trusting peer to the trusted one.
|
||||
func (x *PeerToPeerTrust) SetTrust(v *Trust) {
|
||||
x.Trust = v
|
||||
}
|
||||
|
||||
// SetManager sets manager ID.
|
||||
func (x *GlobalTrust_Body) SetManager(v *PeerID) {
|
||||
x.Manager = v
|
||||
}
|
||||
|
||||
// SetTrust sets global trust value.
|
||||
func (x *GlobalTrust_Body) SetTrust(v *Trust) {
|
||||
x.Trust = v
|
||||
}
|
||||
|
||||
// SetVersion sets message format version.
|
||||
func (x *GlobalTrust) SetVersion(v *refs.Version) {
|
||||
x.Version = v
|
||||
}
|
||||
|
||||
// SetBody sets message body.
|
||||
func (x *GlobalTrust) SetBody(v *GlobalTrust_Body) {
|
||||
x.Body = v
|
||||
}
|
||||
|
||||
// SetSignature sets body signature.
|
||||
func (x *GlobalTrust) SetSignature(v *refs.Signature) {
|
||||
x.Signature = v
|
||||
}
|
BIN
reputation/grpc/types.pb.go
generated
BIN
reputation/grpc/types.pb.go
generated
Binary file not shown.
|
@ -1,38 +0,0 @@
|
|||
package reputation
|
||||
|
||||
import (
|
||||
reputation "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/reputation/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message"
|
||||
)
|
||||
|
||||
func (x *PeerID) MarshalJSON() ([]byte, error) {
|
||||
return message.MarshalJSON(x)
|
||||
}
|
||||
|
||||
func (x *PeerID) UnmarshalJSON(data []byte) error {
|
||||
return message.UnmarshalJSON(x, data, new(reputation.PeerID))
|
||||
}
|
||||
|
||||
func (x *Trust) MarshalJSON() ([]byte, error) {
|
||||
return message.MarshalJSON(x)
|
||||
}
|
||||
|
||||
func (x *Trust) UnmarshalJSON(data []byte) error {
|
||||
return message.UnmarshalJSON(x, data, new(reputation.Trust))
|
||||
}
|
||||
|
||||
func (x *PeerToPeerTrust) MarshalJSON() ([]byte, error) {
|
||||
return message.MarshalJSON(x)
|
||||
}
|
||||
|
||||
func (x *PeerToPeerTrust) UnmarshalJSON(data []byte) error {
|
||||
return message.UnmarshalJSON(x, data, new(reputation.PeerToPeerTrust))
|
||||
}
|
||||
|
||||
func (x *GlobalTrust) MarshalJSON() ([]byte, error) {
|
||||
return message.MarshalJSON(x)
|
||||
}
|
||||
|
||||
func (x *GlobalTrust) UnmarshalJSON(data []byte) error {
|
||||
return message.UnmarshalJSON(x, data, new(reputation.GlobalTrust))
|
||||
}
|
|
@ -1,276 +0,0 @@
|
|||
package reputation
|
||||
|
||||
import (
|
||||
reputation "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/reputation/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message"
|
||||
protoutil "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/util/proto"
|
||||
)
|
||||
|
||||
const (
|
||||
_ = iota
|
||||
peerIDPubKeyFNum
|
||||
)
|
||||
|
||||
func (x *PeerID) StableMarshal(buf []byte) []byte {
|
||||
if x == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, x.StableSize())
|
||||
}
|
||||
|
||||
protoutil.BytesMarshal(peerIDPubKeyFNum, buf, x.publicKey)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (x *PeerID) StableSize() (size int) {
|
||||
size += protoutil.BytesSize(peerIDPubKeyFNum, x.publicKey)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (x *PeerID) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(x, data, new(reputation.PeerID))
|
||||
}
|
||||
|
||||
const (
|
||||
_ = iota
|
||||
trustPeerFNum
|
||||
trustValueFNum
|
||||
)
|
||||
|
||||
func (x *Trust) StableMarshal(buf []byte) []byte {
|
||||
if x == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, x.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
|
||||
offset += protoutil.NestedStructureMarshal(trustPeerFNum, buf[offset:], x.peer)
|
||||
protoutil.Float64Marshal(trustValueFNum, buf[offset:], x.val)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (x *Trust) StableSize() (size int) {
|
||||
size += protoutil.NestedStructureSize(trustPeerFNum, x.peer)
|
||||
size += protoutil.Float64Size(trustValueFNum, x.val)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (x *Trust) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(x, data, new(reputation.Trust))
|
||||
}
|
||||
|
||||
const (
|
||||
_ = iota
|
||||
p2pTrustTrustingFNum
|
||||
p2pTrustValueFNum
|
||||
)
|
||||
|
||||
func (x *PeerToPeerTrust) StableMarshal(buf []byte) []byte {
|
||||
if x == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, x.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
|
||||
offset += protoutil.NestedStructureMarshal(p2pTrustTrustingFNum, buf, x.trusting)
|
||||
protoutil.NestedStructureMarshal(p2pTrustValueFNum, buf[offset:], x.trust)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (x *PeerToPeerTrust) StableSize() (size int) {
|
||||
size += protoutil.NestedStructureSize(p2pTrustTrustingFNum, x.trusting)
|
||||
size += protoutil.NestedStructureSize(p2pTrustValueFNum, x.trust)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (x *PeerToPeerTrust) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(x, data, new(reputation.PeerToPeerTrust))
|
||||
}
|
||||
|
||||
const (
|
||||
_ = iota
|
||||
globalTrustBodyManagerFNum
|
||||
globalTrustBodyValueFNum
|
||||
)
|
||||
|
||||
func (x *GlobalTrustBody) StableMarshal(buf []byte) []byte {
|
||||
if x == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, x.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
|
||||
offset += protoutil.NestedStructureMarshal(globalTrustBodyManagerFNum, buf, x.manager)
|
||||
protoutil.NestedStructureMarshal(globalTrustBodyValueFNum, buf[offset:], x.trust)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (x *GlobalTrustBody) StableSize() (size int) {
|
||||
size += protoutil.NestedStructureSize(globalTrustBodyManagerFNum, x.manager)
|
||||
size += protoutil.NestedStructureSize(globalTrustBodyValueFNum, x.trust)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (x *GlobalTrustBody) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(x, data, new(reputation.GlobalTrust_Body))
|
||||
}
|
||||
|
||||
const (
|
||||
_ = iota
|
||||
globalTrustVersionFNum
|
||||
globalTrustBodyFNum
|
||||
globalTrustSigFNum
|
||||
)
|
||||
|
||||
func (x *GlobalTrust) StableMarshal(buf []byte) []byte {
|
||||
if x == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, x.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
|
||||
offset += protoutil.NestedStructureMarshal(globalTrustVersionFNum, buf, x.version)
|
||||
offset += protoutil.NestedStructureMarshal(globalTrustBodyFNum, buf[offset:], x.body)
|
||||
protoutil.NestedStructureMarshal(globalTrustSigFNum, buf[offset:], x.sig)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (x *GlobalTrust) StableSize() (size int) {
|
||||
size += protoutil.NestedStructureSize(globalTrustVersionFNum, x.version)
|
||||
size += protoutil.NestedStructureSize(globalTrustBodyFNum, x.body)
|
||||
size += protoutil.NestedStructureSize(globalTrustSigFNum, x.sig)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (x *GlobalTrust) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(x, data, new(reputation.GlobalTrust))
|
||||
}
|
||||
|
||||
const (
|
||||
_ = iota
|
||||
announceLocalTrustBodyEpochFNum
|
||||
announceLocalTrustBodyTrustsFNum
|
||||
)
|
||||
|
||||
func (x *AnnounceLocalTrustRequestBody) StableMarshal(buf []byte) []byte {
|
||||
if x == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, x.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
|
||||
offset += protoutil.UInt64Marshal(announceLocalTrustBodyEpochFNum, buf[offset:], x.epoch)
|
||||
|
||||
for i := range x.trusts {
|
||||
offset += protoutil.NestedStructureMarshal(announceLocalTrustBodyTrustsFNum, buf[offset:], &x.trusts[i])
|
||||
}
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (x *AnnounceLocalTrustRequestBody) StableSize() (size int) {
|
||||
size += protoutil.UInt64Size(announceLocalTrustBodyEpochFNum, x.epoch)
|
||||
|
||||
for i := range x.trusts {
|
||||
size += protoutil.NestedStructureSize(announceLocalTrustBodyTrustsFNum, &x.trusts[i])
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (x *AnnounceLocalTrustRequestBody) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(x, data, new(reputation.AnnounceLocalTrustRequest_Body))
|
||||
}
|
||||
|
||||
func (x *AnnounceLocalTrustResponseBody) StableMarshal(buf []byte) []byte {
|
||||
return buf
|
||||
}
|
||||
|
||||
func (x *AnnounceLocalTrustResponseBody) StableSize() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *AnnounceLocalTrustResponseBody) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(x, data, new(reputation.AnnounceLocalTrustResponse_Body))
|
||||
}
|
||||
|
||||
const (
|
||||
_ = iota
|
||||
announceInterResBodyEpochFNum
|
||||
announceInterResBodyIterFNum
|
||||
announceInterResBodyTrustFNum
|
||||
)
|
||||
|
||||
func (x *AnnounceIntermediateResultRequestBody) StableMarshal(buf []byte) []byte {
|
||||
if x == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, x.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
|
||||
offset += protoutil.UInt64Marshal(announceInterResBodyEpochFNum, buf, x.epoch)
|
||||
offset += protoutil.UInt32Marshal(announceInterResBodyIterFNum, buf[offset:], x.iter)
|
||||
protoutil.NestedStructureMarshal(announceInterResBodyTrustFNum, buf[offset:], x.trust)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (x *AnnounceIntermediateResultRequestBody) StableSize() (size int) {
|
||||
size += protoutil.UInt64Size(announceInterResBodyEpochFNum, x.epoch)
|
||||
size += protoutil.UInt32Size(announceInterResBodyIterFNum, x.iter)
|
||||
size += protoutil.NestedStructureSize(announceInterResBodyTrustFNum, x.trust)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (x *AnnounceIntermediateResultRequestBody) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(x, data, new(reputation.AnnounceIntermediateResultRequest_Body))
|
||||
}
|
||||
|
||||
func (x *AnnounceIntermediateResultResponseBody) StableMarshal(buf []byte) []byte {
|
||||
return buf
|
||||
}
|
||||
|
||||
func (x *AnnounceIntermediateResultResponseBody) StableSize() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *AnnounceIntermediateResultResponseBody) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(x, data, new(reputation.AnnounceIntermediateResultResponse_Body))
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
package reputation_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
reputationtest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/reputation/test"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message"
|
||||
messagetest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message/test"
|
||||
)
|
||||
|
||||
func TestMessageConvert(t *testing.T) {
|
||||
messagetest.TestRPCMessage(t,
|
||||
func(empty bool) message.Message { return reputationtest.GenerateTrust(empty) },
|
||||
func(empty bool) message.Message { return reputationtest.GenerateAnnounceLocalTrustRequestBody(empty) },
|
||||
func(empty bool) message.Message { return reputationtest.GenerateAnnounceLocalTrustRequest(empty) },
|
||||
func(empty bool) message.Message { return reputationtest.GenerateAnnounceLocalTrustResponseBody(empty) },
|
||||
func(empty bool) message.Message { return reputationtest.GenerateAnnounceLocalTrustResponse(empty) },
|
||||
func(empty bool) message.Message {
|
||||
return reputationtest.GenerateAnnounceIntermediateResultRequestBody(empty)
|
||||
},
|
||||
func(empty bool) message.Message {
|
||||
return reputationtest.GenerateAnnounceIntermediateResultRequest(empty)
|
||||
},
|
||||
func(empty bool) message.Message {
|
||||
return reputationtest.GenerateAnnounceIntermediateResultResponseBody(empty)
|
||||
},
|
||||
func(empty bool) message.Message {
|
||||
return reputationtest.GenerateAnnounceIntermediateResultResponse(empty)
|
||||
},
|
||||
func(empty bool) message.Message { return reputationtest.GenerateGlobalTrustBody(empty) },
|
||||
func(empty bool) message.Message { return reputationtest.GenerateGlobalTrust(empty) },
|
||||
func(empty bool) message.Message { return reputationtest.GeneratePeerToPeerTrust(empty) },
|
||||
)
|
||||
}
|
|
@ -1,160 +0,0 @@
|
|||
package reputationtest
|
||||
|
||||
import (
|
||||
refstest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs/test"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/reputation"
|
||||
sessiontest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session/test"
|
||||
)
|
||||
|
||||
func GeneratePeerID(empty bool) *reputation.PeerID {
|
||||
m := new(reputation.PeerID)
|
||||
|
||||
if !empty {
|
||||
m.SetPublicKey([]byte{1, 2, 3})
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateTrust(empty bool) *reputation.Trust {
|
||||
m := new(reputation.Trust)
|
||||
|
||||
if !empty {
|
||||
m.SetValue(1)
|
||||
m.SetPeer(GeneratePeerID(false))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GeneratePeerToPeerTrust(empty bool) *reputation.PeerToPeerTrust {
|
||||
m := new(reputation.PeerToPeerTrust)
|
||||
|
||||
if !empty {
|
||||
m.SetTrustingPeer(GeneratePeerID(false))
|
||||
m.SetTrust(GenerateTrust(false))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateGlobalTrustBody(empty bool) *reputation.GlobalTrustBody {
|
||||
m := new(reputation.GlobalTrustBody)
|
||||
|
||||
if !empty {
|
||||
m.SetManager(GeneratePeerID(false))
|
||||
m.SetTrust(GenerateTrust(false))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateGlobalTrust(empty bool) *reputation.GlobalTrust {
|
||||
m := new(reputation.GlobalTrust)
|
||||
|
||||
if !empty {
|
||||
m.SetVersion(refstest.GenerateVersion(false))
|
||||
m.SetBody(GenerateGlobalTrustBody(false))
|
||||
m.SetSignature(refstest.GenerateSignature(empty))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateTrusts(empty bool) []reputation.Trust {
|
||||
var res []reputation.Trust
|
||||
|
||||
if !empty {
|
||||
res = append(res,
|
||||
*GenerateTrust(false),
|
||||
*GenerateTrust(false),
|
||||
)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func GenerateAnnounceLocalTrustRequestBody(empty bool) *reputation.AnnounceLocalTrustRequestBody {
|
||||
m := new(reputation.AnnounceLocalTrustRequestBody)
|
||||
|
||||
if !empty {
|
||||
m.SetEpoch(13)
|
||||
m.SetTrusts(GenerateTrusts(false))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateAnnounceLocalTrustRequest(empty bool) *reputation.AnnounceLocalTrustRequest {
|
||||
m := new(reputation.AnnounceLocalTrustRequest)
|
||||
|
||||
if !empty {
|
||||
m.SetBody(GenerateAnnounceLocalTrustRequestBody(false))
|
||||
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
||||
m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateAnnounceLocalTrustResponseBody(empty bool) *reputation.AnnounceLocalTrustResponseBody {
|
||||
m := new(reputation.AnnounceLocalTrustResponseBody)
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateAnnounceLocalTrustResponse(empty bool) *reputation.AnnounceLocalTrustResponse {
|
||||
m := new(reputation.AnnounceLocalTrustResponse)
|
||||
|
||||
if !empty {
|
||||
m.SetBody(GenerateAnnounceLocalTrustResponseBody(false))
|
||||
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
||||
m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateAnnounceIntermediateResultRequestBody(empty bool) *reputation.AnnounceIntermediateResultRequestBody {
|
||||
m := new(reputation.AnnounceIntermediateResultRequestBody)
|
||||
|
||||
if !empty {
|
||||
m.SetEpoch(123)
|
||||
m.SetIteration(564)
|
||||
m.SetTrust(GeneratePeerToPeerTrust(false))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateAnnounceIntermediateResultRequest(empty bool) *reputation.AnnounceIntermediateResultRequest {
|
||||
m := new(reputation.AnnounceIntermediateResultRequest)
|
||||
|
||||
if !empty {
|
||||
m.SetBody(GenerateAnnounceIntermediateResultRequestBody(false))
|
||||
}
|
||||
|
||||
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
||||
m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateAnnounceIntermediateResultResponseBody(empty bool) *reputation.AnnounceIntermediateResultResponseBody {
|
||||
m := new(reputation.AnnounceIntermediateResultResponseBody)
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateAnnounceIntermediateResultResponse(empty bool) *reputation.AnnounceIntermediateResultResponse {
|
||||
m := new(reputation.AnnounceIntermediateResultResponse)
|
||||
|
||||
if !empty {
|
||||
m.SetBody(GenerateAnnounceIntermediateResultResponseBody(false))
|
||||
}
|
||||
|
||||
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
||||
m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
||||
|
||||
return m
|
||||
}
|
|
@ -1,366 +0,0 @@
|
|||
package reputation
|
||||
|
||||
import (
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session"
|
||||
)
|
||||
|
||||
// PeerID represents reputation.PeerID message
|
||||
// from NeoFS API v2.
|
||||
type PeerID struct {
|
||||
publicKey []byte
|
||||
}
|
||||
|
||||
// GetPublicKey returns peer's binary public key of ID.
|
||||
func (x *PeerID) GetPublicKey() []byte {
|
||||
if x != nil {
|
||||
return x.publicKey
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetPublicKey sets peer's binary public key of ID.
|
||||
func (x *PeerID) SetPublicKey(v []byte) {
|
||||
x.publicKey = v
|
||||
}
|
||||
|
||||
// Trust represents reputation.Trust message
|
||||
// from NeoFS API v2.
|
||||
type Trust struct {
|
||||
val float64
|
||||
|
||||
peer *PeerID
|
||||
}
|
||||
|
||||
// GetPeer returns trusted peer's ID.
|
||||
func (x *Trust) GetPeer() *PeerID {
|
||||
if x != nil {
|
||||
return x.peer
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetPeer sets trusted peer's ID.
|
||||
func (x *Trust) SetPeer(v *PeerID) {
|
||||
x.peer = v
|
||||
}
|
||||
|
||||
// GetValue returns trust value.
|
||||
func (x *Trust) GetValue() float64 {
|
||||
if x != nil {
|
||||
return x.val
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
// SetValue sets trust value.
|
||||
func (x *Trust) SetValue(v float64) {
|
||||
x.val = v
|
||||
}
|
||||
|
||||
// PeerToPeerTrust represents reputation.PeerToPeerTrust message
|
||||
// from NeoFS API v2.
|
||||
type PeerToPeerTrust struct {
|
||||
trusting *PeerID
|
||||
|
||||
trust *Trust
|
||||
}
|
||||
|
||||
// GetTrustingPeer returns trusting peer ID.
|
||||
func (x *PeerToPeerTrust) GetTrustingPeer() *PeerID {
|
||||
if x != nil {
|
||||
return x.trusting
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetTrustingPeer sets trusting peer ID.
|
||||
func (x *PeerToPeerTrust) SetTrustingPeer(v *PeerID) {
|
||||
x.trusting = v
|
||||
}
|
||||
|
||||
// GetTrust returns trust value of trusting peer to the trusted one.
|
||||
func (x *PeerToPeerTrust) GetTrust() *Trust {
|
||||
if x != nil {
|
||||
return x.trust
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetTrust sets trust value of trusting peer to the trusted one.
|
||||
func (x *PeerToPeerTrust) SetTrust(v *Trust) {
|
||||
x.trust = v
|
||||
}
|
||||
|
||||
// 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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
x.sig = v
|
||||
}
|
||||
|
||||
// AnnounceLocalTrustRequestBody is a structure of AnnounceLocalTrust request body.
|
||||
type AnnounceLocalTrustRequestBody struct {
|
||||
epoch uint64
|
||||
|
||||
trusts []Trust
|
||||
}
|
||||
|
||||
// GetEpoch returns epoch in which the trust was assessed.
|
||||
func (x *AnnounceLocalTrustRequestBody) GetEpoch() uint64 {
|
||||
if x != nil {
|
||||
return x.epoch
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
// SetEpoch sets epoch in which the trust was assessed.
|
||||
func (x *AnnounceLocalTrustRequestBody) SetEpoch(v uint64) {
|
||||
x.epoch = v
|
||||
}
|
||||
|
||||
// GetTrusts returns list of normalized trust values.
|
||||
func (x *AnnounceLocalTrustRequestBody) GetTrusts() []Trust {
|
||||
if x != nil {
|
||||
return x.trusts
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetTrusts sets list of normalized trust values.
|
||||
func (x *AnnounceLocalTrustRequestBody) SetTrusts(v []Trust) {
|
||||
x.trusts = v
|
||||
}
|
||||
|
||||
// AnnounceLocalTrustResponseBody is a structure of AnnounceLocalTrust response body.
|
||||
type AnnounceLocalTrustResponseBody struct{}
|
||||
|
||||
// AnnounceLocalTrustRequest represents reputation.AnnounceLocalTrustRequest
|
||||
// message from NeoFS API v2.
|
||||
type AnnounceLocalTrustRequest struct {
|
||||
body *AnnounceLocalTrustRequestBody
|
||||
|
||||
session.RequestHeaders
|
||||
}
|
||||
|
||||
// GetBody returns request body.
|
||||
func (x *AnnounceLocalTrustRequest) GetBody() *AnnounceLocalTrustRequestBody {
|
||||
if x != nil {
|
||||
return x.body
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetBody sets request body.
|
||||
func (x *AnnounceLocalTrustRequest) SetBody(v *AnnounceLocalTrustRequestBody) {
|
||||
x.body = v
|
||||
}
|
||||
|
||||
// AnnounceLocalTrustResponse represents reputation.AnnounceLocalTrustResponse
|
||||
// message from NeoFS API v2.
|
||||
type AnnounceLocalTrustResponse struct {
|
||||
body *AnnounceLocalTrustResponseBody
|
||||
|
||||
session.ResponseHeaders
|
||||
}
|
||||
|
||||
// GetBody returns response body.
|
||||
func (x *AnnounceLocalTrustResponse) GetBody() *AnnounceLocalTrustResponseBody {
|
||||
if x != nil {
|
||||
return x.body
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetBody sets response body.
|
||||
func (x *AnnounceLocalTrustResponse) SetBody(v *AnnounceLocalTrustResponseBody) {
|
||||
x.body = v
|
||||
}
|
||||
|
||||
// AnnounceIntermediateResultRequestBody is a structure of AnnounceIntermediateResult request body.
|
||||
type AnnounceIntermediateResultRequestBody struct {
|
||||
epoch uint64
|
||||
|
||||
iter uint32
|
||||
|
||||
trust *PeerToPeerTrust
|
||||
}
|
||||
|
||||
// GetEpoch returns epoch number in which the intermediate trust was assessed.
|
||||
func (x *AnnounceIntermediateResultRequestBody) GetEpoch() uint64 {
|
||||
if x != nil {
|
||||
return x.epoch
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
// SetEpoch sets epoch number in which the intermediate trust was assessed.
|
||||
func (x *AnnounceIntermediateResultRequestBody) SetEpoch(v uint64) {
|
||||
x.epoch = v
|
||||
}
|
||||
|
||||
// GetIteration returns sequence number of the iteration.
|
||||
func (x *AnnounceIntermediateResultRequestBody) GetIteration() uint32 {
|
||||
if x != nil {
|
||||
return x.iter
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
// SetIteration sets sequence number of the iteration.
|
||||
func (x *AnnounceIntermediateResultRequestBody) SetIteration(v uint32) {
|
||||
x.iter = v
|
||||
}
|
||||
|
||||
// GetTrust returns current global trust value.
|
||||
func (x *AnnounceIntermediateResultRequestBody) GetTrust() *PeerToPeerTrust {
|
||||
if x != nil {
|
||||
return x.trust
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetTrust sets current global trust value.
|
||||
func (x *AnnounceIntermediateResultRequestBody) SetTrust(v *PeerToPeerTrust) {
|
||||
x.trust = v
|
||||
}
|
||||
|
||||
// AnnounceIntermediateResultResponseBody is a structure of AnnounceIntermediateResult response body.
|
||||
type AnnounceIntermediateResultResponseBody struct{}
|
||||
|
||||
// AnnounceIntermediateResultRequest represents reputation.AnnounceIntermediateResult
|
||||
// message from NeoFS API v2.
|
||||
type AnnounceIntermediateResultRequest struct {
|
||||
body *AnnounceIntermediateResultRequestBody
|
||||
|
||||
session.RequestHeaders
|
||||
}
|
||||
|
||||
// GetBody returns request body.
|
||||
func (x *AnnounceIntermediateResultRequest) GetBody() *AnnounceIntermediateResultRequestBody {
|
||||
if x != nil {
|
||||
return x.body
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetBody sets request body.
|
||||
func (x *AnnounceIntermediateResultRequest) SetBody(v *AnnounceIntermediateResultRequestBody) {
|
||||
x.body = v
|
||||
}
|
||||
|
||||
// AnnounceIntermediateResultResponse represents reputation.AnnounceIntermediateResultResponse
|
||||
// message from NeoFS API v2.
|
||||
type AnnounceIntermediateResultResponse struct {
|
||||
body *AnnounceIntermediateResultResponseBody
|
||||
|
||||
session.ResponseHeaders
|
||||
}
|
||||
|
||||
// GetBody returns response body.
|
||||
func (x *AnnounceIntermediateResultResponse) GetBody() *AnnounceIntermediateResultResponseBody {
|
||||
if x != nil {
|
||||
return x.body
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetBody sets response body.
|
||||
func (x *AnnounceIntermediateResultResponse) SetBody(v *AnnounceIntermediateResultResponseBody) {
|
||||
x.body = v
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package rpc
|
||||
|
||||
import (
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/reputation"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/common"
|
||||
)
|
||||
|
||||
const serviceReputation = serviceNamePrefix + "reputation.ReputationService"
|
||||
|
||||
const (
|
||||
rpcReputationAnnounceLocalTrust = "AnnounceLocalTrust"
|
||||
rpcReputationAnnounceIntermediateResult = "AnnounceIntermediateResult"
|
||||
)
|
||||
|
||||
// AnnounceLocalTrust executes ReputationService.AnnounceLocalTrust RPC.
|
||||
func AnnounceLocalTrust(
|
||||
cli *client.Client,
|
||||
req *reputation.AnnounceLocalTrustRequest,
|
||||
opts ...client.CallOption,
|
||||
) (*reputation.AnnounceLocalTrustResponse, error) {
|
||||
resp := new(reputation.AnnounceLocalTrustResponse)
|
||||
|
||||
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceReputation, rpcReputationAnnounceLocalTrust), req, resp, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// AnnounceIntermediateResult executes ReputationService.AnnounceIntermediateResult RPC.
|
||||
func AnnounceIntermediateResult(
|
||||
cli *client.Client,
|
||||
req *reputation.AnnounceIntermediateResultRequest,
|
||||
opts ...client.CallOption,
|
||||
) (*reputation.AnnounceIntermediateResultResponse, error) {
|
||||
resp := new(reputation.AnnounceIntermediateResultResponse)
|
||||
|
||||
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceReputation, rpcReputationAnnounceIntermediateResult), req, resp, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
BIN
session/grpc/service.pb.go
generated
BIN
session/grpc/service.pb.go
generated
Binary file not shown.
BIN
session/grpc/service_grpc.pb.go
generated
BIN
session/grpc/service_grpc.pb.go
generated
Binary file not shown.
BIN
session/grpc/types.pb.go
generated
BIN
session/grpc/types.pb.go
generated
Binary file not shown.
|
@ -7,7 +7,6 @@ import (
|
|||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/container"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/netmap"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/object"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/reputation"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session"
|
||||
)
|
||||
|
||||
|
@ -101,15 +100,5 @@ func serviceMessageBody(req interface{}) stableMarshaler {
|
|||
return v.GetBody()
|
||||
case *netmap.SnapshotResponse:
|
||||
return v.GetBody()
|
||||
|
||||
/* Reputation */
|
||||
case *reputation.AnnounceLocalTrustRequest:
|
||||
return v.GetBody()
|
||||
case *reputation.AnnounceLocalTrustResponse:
|
||||
return v.GetBody()
|
||||
case *reputation.AnnounceIntermediateResultRequest:
|
||||
return v.GetBody()
|
||||
case *reputation.AnnounceIntermediateResultResponse:
|
||||
return v.GetBody()
|
||||
}
|
||||
}
|
||||
|
|
BIN
status/grpc/types.pb.go
generated
BIN
status/grpc/types.pb.go
generated
Binary file not shown.
BIN
storagegroup/grpc/types.pb.go
generated
BIN
storagegroup/grpc/types.pb.go
generated
Binary file not shown.
BIN
subnet/grpc/types.pb.go
generated
BIN
subnet/grpc/types.pb.go
generated
Binary file not shown.
BIN
tombstone/grpc/types.pb.go
generated
BIN
tombstone/grpc/types.pb.go
generated
Binary file not shown.
BIN
util/proto/test/test.pb.go
generated
BIN
util/proto/test/test.pb.go
generated
Binary file not shown.
Loading…
Reference in a new issue