forked from TrueCloudLab/frostfs-api-go
Synchronize namings with NeoFS API v2.6.0
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
fcb2cce8a0
commit
099347d3bc
13 changed files with 586 additions and 577 deletions
|
@ -13,45 +13,45 @@ import (
|
|||
|
||||
// Reputation contains methods for working with Reputation system values.
|
||||
type Reputation interface {
|
||||
// SendLocalTrust sends local trust values of local peer.
|
||||
SendLocalTrust(context.Context, SendLocalTrustPrm, ...CallOption) (*SendLocalTrustRes, error)
|
||||
// AnnounceLocalTrust announces local trust values of local peer.
|
||||
AnnounceLocalTrust(context.Context, AnnounceLocalTrustPrm, ...CallOption) (*AnnounceLocalTrustRes, error)
|
||||
|
||||
// SendIntermediateTrust sends the intermediate result of the iterative algorithm for calculating
|
||||
// AnnounceIntermediateTrust announces the intermediate result of the iterative algorithm for calculating
|
||||
// the global reputation of the node.
|
||||
SendIntermediateTrust(context.Context, SendIntermediateTrustPrm, ...CallOption) (*SendIntermediateTrustRes, error)
|
||||
AnnounceIntermediateTrust(context.Context, AnnounceIntermediateTrustPrm, ...CallOption) (*AnnounceIntermediateTrustRes, error)
|
||||
}
|
||||
|
||||
// SendLocalTrustPrm groups parameters of SendLocalTrust operation.
|
||||
type SendLocalTrustPrm struct {
|
||||
// AnnounceLocalTrustPrm groups parameters of AnnounceLocalTrust operation.
|
||||
type AnnounceLocalTrustPrm struct {
|
||||
epoch uint64
|
||||
|
||||
trusts []*reputation.Trust
|
||||
}
|
||||
|
||||
// Epoch returns epoch in which the trust was assessed.
|
||||
func (x SendLocalTrustPrm) Epoch() uint64 {
|
||||
func (x AnnounceLocalTrustPrm) Epoch() uint64 {
|
||||
return x.epoch
|
||||
}
|
||||
|
||||
// SetEpoch sets epoch in which the trust was assessed.
|
||||
func (x *SendLocalTrustPrm) SetEpoch(epoch uint64) {
|
||||
func (x *AnnounceLocalTrustPrm) SetEpoch(epoch uint64) {
|
||||
x.epoch = epoch
|
||||
}
|
||||
|
||||
// Trusts returns list of local trust values.
|
||||
func (x SendLocalTrustPrm) Trusts() []*reputation.Trust {
|
||||
func (x AnnounceLocalTrustPrm) Trusts() []*reputation.Trust {
|
||||
return x.trusts
|
||||
}
|
||||
|
||||
// SetTrusts sets list of local trust values.
|
||||
func (x *SendLocalTrustPrm) SetTrusts(trusts []*reputation.Trust) {
|
||||
func (x *AnnounceLocalTrustPrm) SetTrusts(trusts []*reputation.Trust) {
|
||||
x.trusts = trusts
|
||||
}
|
||||
|
||||
// SendLocalTrustPrm groups results of SendLocalTrust operation.
|
||||
type SendLocalTrustRes struct{}
|
||||
// AnnounceLocalTrustRes groups results of AnnounceLocalTrust operation.
|
||||
type AnnounceLocalTrustRes struct{}
|
||||
|
||||
func (c *clientImpl) SendLocalTrust(ctx context.Context, prm SendLocalTrustPrm, opts ...CallOption) (*SendLocalTrustRes, error) {
|
||||
func (c *clientImpl) AnnounceLocalTrust(ctx context.Context, prm AnnounceLocalTrustPrm, opts ...CallOption) (*AnnounceLocalTrustRes, error) {
|
||||
// apply all available options
|
||||
callOptions := c.defaultCallOptions()
|
||||
|
||||
|
@ -59,11 +59,11 @@ func (c *clientImpl) SendLocalTrust(ctx context.Context, prm SendLocalTrustPrm,
|
|||
opts[i](callOptions)
|
||||
}
|
||||
|
||||
reqBody := new(v2reputation.SendLocalTrustRequestBody)
|
||||
reqBody := new(v2reputation.AnnounceLocalTrustRequestBody)
|
||||
reqBody.SetEpoch(prm.Epoch())
|
||||
reqBody.SetTrusts(reputation.TrustsToV2(prm.Trusts()))
|
||||
|
||||
req := new(v2reputation.SendLocalTrustRequest)
|
||||
req := new(v2reputation.AnnounceLocalTrustRequest)
|
||||
req.SetBody(reqBody)
|
||||
req.SetMetaHeader(v2MetaHeaderFromOpts(callOptions))
|
||||
|
||||
|
@ -72,7 +72,7 @@ func (c *clientImpl) SendLocalTrust(ctx context.Context, prm SendLocalTrustPrm,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := rpcapi.SendLocalTrust(c.Raw(), req, client.WithContext(ctx))
|
||||
resp, err := rpcapi.AnnounceLocalTrust(c.Raw(), req, client.WithContext(ctx))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -82,11 +82,11 @@ func (c *clientImpl) SendLocalTrust(ctx context.Context, prm SendLocalTrustPrm,
|
|||
return nil, errors.Wrap(err, "can't verify response message")
|
||||
}
|
||||
|
||||
return new(SendLocalTrustRes), nil
|
||||
return new(AnnounceLocalTrustRes), nil
|
||||
}
|
||||
|
||||
// SendIntermediateTrustPrm groups parameters of SendIntermediateTrust operation.
|
||||
type SendIntermediateTrustPrm struct {
|
||||
// AnnounceIntermediateTrustPrm groups parameters of AnnounceIntermediateTrust operation.
|
||||
type AnnounceIntermediateTrustPrm struct {
|
||||
epoch uint64
|
||||
|
||||
iter uint32
|
||||
|
@ -94,38 +94,38 @@ type SendIntermediateTrustPrm struct {
|
|||
trust *reputation.PeerToPeerTrust
|
||||
}
|
||||
|
||||
func (x *SendIntermediateTrustPrm) Epoch() uint64 {
|
||||
func (x *AnnounceIntermediateTrustPrm) Epoch() uint64 {
|
||||
return x.epoch
|
||||
}
|
||||
|
||||
func (x *SendIntermediateTrustPrm) SetEpoch(epoch uint64) {
|
||||
func (x *AnnounceIntermediateTrustPrm) SetEpoch(epoch uint64) {
|
||||
x.epoch = epoch
|
||||
}
|
||||
|
||||
// Iteration returns sequence number of the iteration.
|
||||
func (x SendIntermediateTrustPrm) Iteration() uint32 {
|
||||
func (x AnnounceIntermediateTrustPrm) Iteration() uint32 {
|
||||
return x.iter
|
||||
}
|
||||
|
||||
// SetIteration sets sequence number of the iteration.
|
||||
func (x *SendIntermediateTrustPrm) SetIteration(iter uint32) {
|
||||
func (x *AnnounceIntermediateTrustPrm) SetIteration(iter uint32) {
|
||||
x.iter = iter
|
||||
}
|
||||
|
||||
// Trust returns current global trust value computed at the specified iteration.
|
||||
func (x SendIntermediateTrustPrm) Trust() *reputation.PeerToPeerTrust {
|
||||
func (x AnnounceIntermediateTrustPrm) Trust() *reputation.PeerToPeerTrust {
|
||||
return x.trust
|
||||
}
|
||||
|
||||
// SetTrust sets current global trust value computed at the specified iteration.
|
||||
func (x *SendIntermediateTrustPrm) SetTrust(trust *reputation.PeerToPeerTrust) {
|
||||
func (x *AnnounceIntermediateTrustPrm) SetTrust(trust *reputation.PeerToPeerTrust) {
|
||||
x.trust = trust
|
||||
}
|
||||
|
||||
// SendIntermediateTrustRes groups results of SendIntermediateTrust operation.
|
||||
type SendIntermediateTrustRes struct{}
|
||||
// AnnounceIntermediateTrustRes groups results of AnnounceIntermediateTrust operation.
|
||||
type AnnounceIntermediateTrustRes struct{}
|
||||
|
||||
func (c *clientImpl) SendIntermediateTrust(ctx context.Context, prm SendIntermediateTrustPrm, opts ...CallOption) (*SendIntermediateTrustRes, error) {
|
||||
func (c *clientImpl) AnnounceIntermediateTrust(ctx context.Context, prm AnnounceIntermediateTrustPrm, opts ...CallOption) (*AnnounceIntermediateTrustRes, error) {
|
||||
// apply all available options
|
||||
callOptions := c.defaultCallOptions()
|
||||
|
||||
|
@ -133,12 +133,12 @@ func (c *clientImpl) SendIntermediateTrust(ctx context.Context, prm SendIntermed
|
|||
opts[i](callOptions)
|
||||
}
|
||||
|
||||
reqBody := new(v2reputation.SendIntermediateResultRequestBody)
|
||||
reqBody := new(v2reputation.AnnounceIntermediateResultRequestBody)
|
||||
reqBody.SetEpoch(prm.Epoch())
|
||||
reqBody.SetIteration(prm.Iteration())
|
||||
reqBody.SetTrust(prm.Trust().ToV2())
|
||||
|
||||
req := new(v2reputation.SendIntermediateResultRequest)
|
||||
req := new(v2reputation.AnnounceIntermediateResultRequest)
|
||||
req.SetBody(reqBody)
|
||||
req.SetMetaHeader(v2MetaHeaderFromOpts(callOptions))
|
||||
|
||||
|
@ -147,7 +147,7 @@ func (c *clientImpl) SendIntermediateTrust(ctx context.Context, prm SendIntermed
|
|||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := rpcapi.SendIntermediateResult(c.Raw(), req, client.WithContext(ctx))
|
||||
resp, err := rpcapi.AnnounceIntermediateResult(c.Raw(), req, client.WithContext(ctx))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -157,5 +157,5 @@ func (c *clientImpl) SendIntermediateTrust(ctx context.Context, prm SendIntermed
|
|||
return nil, errors.Wrap(err, "can't verify response message")
|
||||
}
|
||||
|
||||
return new(SendIntermediateTrustRes), nil
|
||||
return new(AnnounceIntermediateTrustRes), nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue