2021-03-24 05:59:37 +00:00
|
|
|
package reputation
|
|
|
|
|
|
|
|
import (
|
2023-03-07 10:38:56 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session"
|
2021-03-24 05:59:37 +00:00
|
|
|
)
|
|
|
|
|
2021-04-01 14:35:40 +00:00
|
|
|
// PeerID represents reputation.PeerID message
|
|
|
|
// from NeoFS API v2.
|
|
|
|
type PeerID struct {
|
2021-05-07 09:34:24 +00:00
|
|
|
publicKey []byte
|
2021-04-01 14:35:40 +00:00
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// GetPublicKey returns peer's binary public key of ID.
|
|
|
|
func (x *PeerID) GetPublicKey() []byte {
|
2021-04-01 14:35:40 +00:00
|
|
|
if x != nil {
|
2021-05-07 09:34:24 +00:00
|
|
|
return x.publicKey
|
2021-04-01 14:35:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// SetPublicKey sets peer's binary public key of ID.
|
|
|
|
func (x *PeerID) SetPublicKey(v []byte) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.publicKey = v
|
2021-04-01 14:35:40 +00:00
|
|
|
}
|
|
|
|
|
2021-03-24 05:59:37 +00:00
|
|
|
// Trust represents reputation.Trust message
|
|
|
|
// from NeoFS API v2.
|
|
|
|
type Trust struct {
|
|
|
|
val float64
|
|
|
|
|
2021-04-01 14:35:40 +00:00
|
|
|
peer *PeerID
|
2021-03-24 05:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetPeer returns trusted peer's ID.
|
2021-04-01 14:35:40 +00:00
|
|
|
func (x *Trust) GetPeer() *PeerID {
|
2021-03-24 05:59:37 +00:00
|
|
|
if x != nil {
|
|
|
|
return x.peer
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetPeer sets trusted peer's ID.
|
2021-04-01 14:35:40 +00:00
|
|
|
func (x *Trust) SetPeer(v *PeerID) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.peer = v
|
2021-03-24 05:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.val = v
|
2021-03-24 05:59:37 +00:00
|
|
|
}
|
|
|
|
|
2021-04-09 08:28:06 +00:00
|
|
|
// 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) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.trusting = v
|
2021-04-09 08:28:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.trust = v
|
2021-04-09 08:28:06 +00:00
|
|
|
}
|
|
|
|
|
2021-04-01 14:35:40 +00:00
|
|
|
// 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) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.manager = v
|
2021-04-01 14:35:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.trust = v
|
2021-04-01 14:35:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.version = v
|
2021-04-01 14:35:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.body = v
|
2021-04-01 14:35:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.sig = v
|
2021-04-01 14:35:40 +00:00
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// AnnounceLocalTrustRequestBody is a structure of AnnounceLocalTrust request body.
|
|
|
|
type AnnounceLocalTrustRequestBody struct {
|
2021-03-24 05:59:37 +00:00
|
|
|
epoch uint64
|
|
|
|
|
2022-03-02 08:40:47 +00:00
|
|
|
trusts []Trust
|
2021-03-24 05:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetEpoch returns epoch in which the trust was assessed.
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceLocalTrustRequestBody) GetEpoch() uint64 {
|
2021-03-24 05:59:37 +00:00
|
|
|
if x != nil {
|
|
|
|
return x.epoch
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetEpoch sets epoch in which the trust was assessed.
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceLocalTrustRequestBody) SetEpoch(v uint64) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.epoch = v
|
2021-03-24 05:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetTrusts returns list of normalized trust values.
|
2022-03-02 08:40:47 +00:00
|
|
|
func (x *AnnounceLocalTrustRequestBody) GetTrusts() []Trust {
|
2021-03-24 05:59:37 +00:00
|
|
|
if x != nil {
|
|
|
|
return x.trusts
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetTrusts sets list of normalized trust values.
|
2022-03-02 08:40:47 +00:00
|
|
|
func (x *AnnounceLocalTrustRequestBody) SetTrusts(v []Trust) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.trusts = v
|
2021-03-24 05:59:37 +00:00
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// AnnounceLocalTrustResponseBody is a structure of AnnounceLocalTrust response body.
|
|
|
|
type AnnounceLocalTrustResponseBody struct{}
|
2021-03-24 05:59:37 +00:00
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// AnnounceLocalTrustRequest represents reputation.AnnounceLocalTrustRequest
|
2021-03-24 05:59:37 +00:00
|
|
|
// message from NeoFS API v2.
|
2021-05-07 09:34:24 +00:00
|
|
|
type AnnounceLocalTrustRequest struct {
|
|
|
|
body *AnnounceLocalTrustRequestBody
|
2021-03-24 05:59:37 +00:00
|
|
|
|
|
|
|
session.RequestHeaders
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetBody returns request body.
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceLocalTrustRequest) GetBody() *AnnounceLocalTrustRequestBody {
|
2021-03-24 05:59:37 +00:00
|
|
|
if x != nil {
|
|
|
|
return x.body
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetBody sets request body.
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceLocalTrustRequest) SetBody(v *AnnounceLocalTrustRequestBody) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.body = v
|
2021-03-24 05:59:37 +00:00
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// AnnounceLocalTrustResponse represents reputation.AnnounceLocalTrustResponse
|
2021-03-24 05:59:37 +00:00
|
|
|
// message from NeoFS API v2.
|
2021-05-07 09:34:24 +00:00
|
|
|
type AnnounceLocalTrustResponse struct {
|
|
|
|
body *AnnounceLocalTrustResponseBody
|
2021-03-24 05:59:37 +00:00
|
|
|
|
|
|
|
session.ResponseHeaders
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetBody returns response body.
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceLocalTrustResponse) GetBody() *AnnounceLocalTrustResponseBody {
|
2021-03-24 05:59:37 +00:00
|
|
|
if x != nil {
|
|
|
|
return x.body
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetBody sets response body.
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceLocalTrustResponse) SetBody(v *AnnounceLocalTrustResponseBody) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.body = v
|
2021-03-24 05:59:37 +00:00
|
|
|
}
|
2021-04-01 14:35:40 +00:00
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// AnnounceIntermediateResultRequestBody is a structure of AnnounceIntermediateResult request body.
|
|
|
|
type AnnounceIntermediateResultRequestBody struct {
|
2021-04-22 07:40:12 +00:00
|
|
|
epoch uint64
|
|
|
|
|
2021-04-01 14:35:40 +00:00
|
|
|
iter uint32
|
|
|
|
|
2021-04-09 08:28:06 +00:00
|
|
|
trust *PeerToPeerTrust
|
2021-04-01 14:35:40 +00:00
|
|
|
}
|
|
|
|
|
2021-04-22 07:40:12 +00:00
|
|
|
// GetEpoch returns epoch number in which the intermediate trust was assessed.
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceIntermediateResultRequestBody) GetEpoch() uint64 {
|
2021-04-22 07:40:12 +00:00
|
|
|
if x != nil {
|
|
|
|
return x.epoch
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetEpoch sets epoch number in which the intermediate trust was assessed.
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceIntermediateResultRequestBody) SetEpoch(v uint64) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.epoch = v
|
2021-04-22 07:40:12 +00:00
|
|
|
}
|
|
|
|
|
2021-04-01 14:35:40 +00:00
|
|
|
// GetIteration returns sequence number of the iteration.
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceIntermediateResultRequestBody) GetIteration() uint32 {
|
2021-04-01 14:35:40 +00:00
|
|
|
if x != nil {
|
|
|
|
return x.iter
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetIteration sets sequence number of the iteration.
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceIntermediateResultRequestBody) SetIteration(v uint32) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.iter = v
|
2021-04-01 14:35:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetTrust returns current global trust value.
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceIntermediateResultRequestBody) GetTrust() *PeerToPeerTrust {
|
2021-04-01 14:35:40 +00:00
|
|
|
if x != nil {
|
|
|
|
return x.trust
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetTrust sets current global trust value.
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceIntermediateResultRequestBody) SetTrust(v *PeerToPeerTrust) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.trust = v
|
2021-04-01 14:35:40 +00:00
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// AnnounceIntermediateResultResponseBody is a structure of AnnounceIntermediateResult response body.
|
|
|
|
type AnnounceIntermediateResultResponseBody struct{}
|
2021-04-01 14:35:40 +00:00
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// AnnounceIntermediateResultRequest represents reputation.AnnounceIntermediateResult
|
2021-04-01 14:35:40 +00:00
|
|
|
// message from NeoFS API v2.
|
2021-05-07 09:34:24 +00:00
|
|
|
type AnnounceIntermediateResultRequest struct {
|
|
|
|
body *AnnounceIntermediateResultRequestBody
|
2021-04-01 14:35:40 +00:00
|
|
|
|
|
|
|
session.RequestHeaders
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetBody returns request body.
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceIntermediateResultRequest) GetBody() *AnnounceIntermediateResultRequestBody {
|
2021-04-01 14:35:40 +00:00
|
|
|
if x != nil {
|
|
|
|
return x.body
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetBody sets request body.
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceIntermediateResultRequest) SetBody(v *AnnounceIntermediateResultRequestBody) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.body = v
|
2021-04-01 14:35:40 +00:00
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
// AnnounceIntermediateResultResponse represents reputation.AnnounceIntermediateResultResponse
|
2021-04-01 14:35:40 +00:00
|
|
|
// message from NeoFS API v2.
|
2021-05-07 09:34:24 +00:00
|
|
|
type AnnounceIntermediateResultResponse struct {
|
|
|
|
body *AnnounceIntermediateResultResponseBody
|
2021-04-01 14:35:40 +00:00
|
|
|
|
|
|
|
session.ResponseHeaders
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetBody returns response body.
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceIntermediateResultResponse) GetBody() *AnnounceIntermediateResultResponseBody {
|
2021-04-01 14:35:40 +00:00
|
|
|
if x != nil {
|
|
|
|
return x.body
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetBody sets response body.
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceIntermediateResultResponse) SetBody(v *AnnounceIntermediateResultResponseBody) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.body = v
|
2021-04-01 14:35:40 +00:00
|
|
|
}
|