github.com/TrueCloudLab/frostfs-api-go/v2@v2.0.0-20230228134343-196241c4e79a/reputation/types.go (about)

     1  package reputation
     2  
     3  import (
     4  	"github.com/TrueCloudLab/frostfs-api-go/v2/refs"
     5  	"github.com/TrueCloudLab/frostfs-api-go/v2/session"
     6  )
     7  
     8  // PeerID represents reputation.PeerID message
     9  // from NeoFS API v2.
    10  type PeerID struct {
    11  	publicKey []byte
    12  }
    13  
    14  // GetPublicKey returns peer's binary public key of ID.
    15  func (x *PeerID) GetPublicKey() []byte {
    16  	if x != nil {
    17  		return x.publicKey
    18  	}
    19  
    20  	return nil
    21  }
    22  
    23  // SetPublicKey sets peer's binary public key of ID.
    24  func (x *PeerID) SetPublicKey(v []byte) {
    25  	x.publicKey = v
    26  }
    27  
    28  // Trust represents reputation.Trust message
    29  // from NeoFS API v2.
    30  type Trust struct {
    31  	val float64
    32  
    33  	peer *PeerID
    34  }
    35  
    36  // GetPeer returns trusted peer's ID.
    37  func (x *Trust) GetPeer() *PeerID {
    38  	if x != nil {
    39  		return x.peer
    40  	}
    41  
    42  	return nil
    43  }
    44  
    45  // SetPeer sets trusted peer's ID.
    46  func (x *Trust) SetPeer(v *PeerID) {
    47  	x.peer = v
    48  }
    49  
    50  // GetValue returns trust value.
    51  func (x *Trust) GetValue() float64 {
    52  	if x != nil {
    53  		return x.val
    54  	}
    55  
    56  	return 0
    57  }
    58  
    59  // SetValue sets trust value.
    60  func (x *Trust) SetValue(v float64) {
    61  	x.val = v
    62  }
    63  
    64  // PeerToPeerTrust represents reputation.PeerToPeerTrust message
    65  // from NeoFS API v2.
    66  type PeerToPeerTrust struct {
    67  	trusting *PeerID
    68  
    69  	trust *Trust
    70  }
    71  
    72  // GetTrustingPeer returns trusting peer ID.
    73  func (x *PeerToPeerTrust) GetTrustingPeer() *PeerID {
    74  	if x != nil {
    75  		return x.trusting
    76  	}
    77  
    78  	return nil
    79  }
    80  
    81  // SetTrustingPeer sets trusting peer ID.
    82  func (x *PeerToPeerTrust) SetTrustingPeer(v *PeerID) {
    83  	x.trusting = v
    84  }
    85  
    86  // GetTrust returns trust value of trusting peer to the trusted one.
    87  func (x *PeerToPeerTrust) GetTrust() *Trust {
    88  	if x != nil {
    89  		return x.trust
    90  	}
    91  
    92  	return nil
    93  }
    94  
    95  // SetTrust sets trust value of trusting peer to the trusted one.
    96  func (x *PeerToPeerTrust) SetTrust(v *Trust) {
    97  	x.trust = v
    98  }
    99  
   100  // GlobalTrustBody represents reputation.GlobalTrust.Body message
   101  // from NeoFS API v2.
   102  type GlobalTrustBody struct {
   103  	manager *PeerID
   104  
   105  	trust *Trust
   106  }
   107  
   108  // GetManager returns node manager ID.
   109  func (x *GlobalTrustBody) GetManager() *PeerID {
   110  	if x != nil {
   111  		return x.manager
   112  	}
   113  
   114  	return nil
   115  }
   116  
   117  // SetManager sets node manager ID.
   118  func (x *GlobalTrustBody) SetManager(v *PeerID) {
   119  	x.manager = v
   120  }
   121  
   122  // GetTrust returns global trust value.
   123  func (x *GlobalTrustBody) GetTrust() *Trust {
   124  	if x != nil {
   125  		return x.trust
   126  	}
   127  
   128  	return nil
   129  }
   130  
   131  // SetTrust sets global trust value.
   132  func (x *GlobalTrustBody) SetTrust(v *Trust) {
   133  	x.trust = v
   134  }
   135  
   136  // GlobalTrust represents reputation.GlobalTrust message
   137  // from NeoFS API v2.
   138  type GlobalTrust struct {
   139  	version *refs.Version
   140  
   141  	body *GlobalTrustBody
   142  
   143  	sig *refs.Signature
   144  }
   145  
   146  // GetVersion returns message format version.
   147  func (x *GlobalTrust) GetVersion() *refs.Version {
   148  	if x != nil {
   149  		return x.version
   150  	}
   151  
   152  	return nil
   153  }
   154  
   155  // SetVersion sets message format version.
   156  func (x *GlobalTrust) SetVersion(v *refs.Version) {
   157  	x.version = v
   158  }
   159  
   160  // GetBody returns message body.
   161  func (x *GlobalTrust) GetBody() *GlobalTrustBody {
   162  	if x != nil {
   163  		return x.body
   164  	}
   165  
   166  	return nil
   167  }
   168  
   169  // SetBody sets message body.
   170  func (x *GlobalTrust) SetBody(v *GlobalTrustBody) {
   171  	x.body = v
   172  }
   173  
   174  // GetSignature returns body signature.
   175  func (x *GlobalTrust) GetSignature() *refs.Signature {
   176  	if x != nil {
   177  		return x.sig
   178  	}
   179  
   180  	return nil
   181  }
   182  
   183  // SetSignature sets body signature.
   184  func (x *GlobalTrust) SetSignature(v *refs.Signature) {
   185  	x.sig = v
   186  }
   187  
   188  // AnnounceLocalTrustRequestBody is a structure of AnnounceLocalTrust request body.
   189  type AnnounceLocalTrustRequestBody struct {
   190  	epoch uint64
   191  
   192  	trusts []Trust
   193  }
   194  
   195  // GetEpoch returns epoch in which the trust was assessed.
   196  func (x *AnnounceLocalTrustRequestBody) GetEpoch() uint64 {
   197  	if x != nil {
   198  		return x.epoch
   199  	}
   200  
   201  	return 0
   202  }
   203  
   204  // SetEpoch sets epoch in which the trust was assessed.
   205  func (x *AnnounceLocalTrustRequestBody) SetEpoch(v uint64) {
   206  	x.epoch = v
   207  }
   208  
   209  // GetTrusts returns list of normalized trust values.
   210  func (x *AnnounceLocalTrustRequestBody) GetTrusts() []Trust {
   211  	if x != nil {
   212  		return x.trusts
   213  	}
   214  
   215  	return nil
   216  }
   217  
   218  // SetTrusts sets list of normalized trust values.
   219  func (x *AnnounceLocalTrustRequestBody) SetTrusts(v []Trust) {
   220  	x.trusts = v
   221  }
   222  
   223  // AnnounceLocalTrustResponseBody is a structure of AnnounceLocalTrust response body.
   224  type AnnounceLocalTrustResponseBody struct{}
   225  
   226  // AnnounceLocalTrustRequest represents reputation.AnnounceLocalTrustRequest
   227  // message from NeoFS API v2.
   228  type AnnounceLocalTrustRequest struct {
   229  	body *AnnounceLocalTrustRequestBody
   230  
   231  	session.RequestHeaders
   232  }
   233  
   234  // GetBody returns request body.
   235  func (x *AnnounceLocalTrustRequest) GetBody() *AnnounceLocalTrustRequestBody {
   236  	if x != nil {
   237  		return x.body
   238  	}
   239  
   240  	return nil
   241  }
   242  
   243  // SetBody sets request body.
   244  func (x *AnnounceLocalTrustRequest) SetBody(v *AnnounceLocalTrustRequestBody) {
   245  	x.body = v
   246  }
   247  
   248  // AnnounceLocalTrustResponse represents reputation.AnnounceLocalTrustResponse
   249  // message from NeoFS API v2.
   250  type AnnounceLocalTrustResponse struct {
   251  	body *AnnounceLocalTrustResponseBody
   252  
   253  	session.ResponseHeaders
   254  }
   255  
   256  // GetBody returns response body.
   257  func (x *AnnounceLocalTrustResponse) GetBody() *AnnounceLocalTrustResponseBody {
   258  	if x != nil {
   259  		return x.body
   260  	}
   261  
   262  	return nil
   263  }
   264  
   265  // SetBody sets response body.
   266  func (x *AnnounceLocalTrustResponse) SetBody(v *AnnounceLocalTrustResponseBody) {
   267  	x.body = v
   268  }
   269  
   270  // AnnounceIntermediateResultRequestBody is a structure of AnnounceIntermediateResult request body.
   271  type AnnounceIntermediateResultRequestBody struct {
   272  	epoch uint64
   273  
   274  	iter uint32
   275  
   276  	trust *PeerToPeerTrust
   277  }
   278  
   279  // GetEpoch returns epoch number in which the intermediate trust was assessed.
   280  func (x *AnnounceIntermediateResultRequestBody) GetEpoch() uint64 {
   281  	if x != nil {
   282  		return x.epoch
   283  	}
   284  
   285  	return 0
   286  }
   287  
   288  // SetEpoch sets epoch number in which the intermediate trust was assessed.
   289  func (x *AnnounceIntermediateResultRequestBody) SetEpoch(v uint64) {
   290  	x.epoch = v
   291  }
   292  
   293  // GetIteration returns sequence number of the iteration.
   294  func (x *AnnounceIntermediateResultRequestBody) GetIteration() uint32 {
   295  	if x != nil {
   296  		return x.iter
   297  	}
   298  
   299  	return 0
   300  }
   301  
   302  // SetIteration sets sequence number of the iteration.
   303  func (x *AnnounceIntermediateResultRequestBody) SetIteration(v uint32) {
   304  	x.iter = v
   305  }
   306  
   307  // GetTrust returns current global trust value.
   308  func (x *AnnounceIntermediateResultRequestBody) GetTrust() *PeerToPeerTrust {
   309  	if x != nil {
   310  		return x.trust
   311  	}
   312  
   313  	return nil
   314  }
   315  
   316  // SetTrust sets current global trust value.
   317  func (x *AnnounceIntermediateResultRequestBody) SetTrust(v *PeerToPeerTrust) {
   318  	x.trust = v
   319  }
   320  
   321  // AnnounceIntermediateResultResponseBody is a structure of AnnounceIntermediateResult response body.
   322  type AnnounceIntermediateResultResponseBody struct{}
   323  
   324  // AnnounceIntermediateResultRequest represents reputation.AnnounceIntermediateResult
   325  // message from NeoFS API v2.
   326  type AnnounceIntermediateResultRequest struct {
   327  	body *AnnounceIntermediateResultRequestBody
   328  
   329  	session.RequestHeaders
   330  }
   331  
   332  // GetBody returns request body.
   333  func (x *AnnounceIntermediateResultRequest) GetBody() *AnnounceIntermediateResultRequestBody {
   334  	if x != nil {
   335  		return x.body
   336  	}
   337  
   338  	return nil
   339  }
   340  
   341  // SetBody sets request body.
   342  func (x *AnnounceIntermediateResultRequest) SetBody(v *AnnounceIntermediateResultRequestBody) {
   343  	x.body = v
   344  }
   345  
   346  // AnnounceIntermediateResultResponse represents reputation.AnnounceIntermediateResultResponse
   347  // message from NeoFS API v2.
   348  type AnnounceIntermediateResultResponse struct {
   349  	body *AnnounceIntermediateResultResponseBody
   350  
   351  	session.ResponseHeaders
   352  }
   353  
   354  // GetBody returns response body.
   355  func (x *AnnounceIntermediateResultResponse) GetBody() *AnnounceIntermediateResultResponseBody {
   356  	if x != nil {
   357  		return x.body
   358  	}
   359  
   360  	return nil
   361  }
   362  
   363  // SetBody sets response body.
   364  func (x *AnnounceIntermediateResultResponse) SetBody(v *AnnounceIntermediateResultResponseBody) {
   365  	x.body = v
   366  }