Update neofs-api-go to v1.26.0

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-05-07 14:13:11 +03:00 committed by Alex Vanin
parent bd6d5e7f7b
commit d49bd4b94a
13 changed files with 40 additions and 40 deletions

View file

@ -259,7 +259,7 @@ type reputationServer struct {
routeBuilder reputationrouter.Builder
}
func (s *reputationServer) SendLocalTrust(ctx context.Context, req *v2reputation.SendLocalTrustRequest) (*v2reputation.SendLocalTrustResponse, error) {
func (s *reputationServer) AnnounceLocalTrust(ctx context.Context, req *v2reputation.AnnounceLocalTrustRequest) (*v2reputation.AnnounceLocalTrustResponse, error) {
passedRoute := reverseRoute(req.GetVerificationHeader())
passedRoute = append(passedRoute, s)
@ -282,13 +282,13 @@ func (s *reputationServer) SendLocalTrust(ctx context.Context, req *v2reputation
}
}
resp := new(v2reputation.SendLocalTrustResponse)
resp.SetBody(new(v2reputation.SendLocalTrustResponseBody))
resp := new(v2reputation.AnnounceLocalTrustResponse)
resp.SetBody(new(v2reputation.AnnounceLocalTrustResponseBody))
return resp, nil
}
func (s *reputationServer) SendIntermediateResult(ctx context.Context, req *v2reputation.SendIntermediateResultRequest) (*v2reputation.SendIntermediateResultResponse, error) {
func (s *reputationServer) AnnounceIntermediateResult(ctx context.Context, req *v2reputation.AnnounceIntermediateResultRequest) (*v2reputation.AnnounceIntermediateResultResponse, error) {
passedRoute := reverseRoute(req.GetVerificationHeader())
passedRoute = append(passedRoute, s)
@ -303,15 +303,15 @@ func (s *reputationServer) SendIntermediateResult(ctx context.Context, req *v2re
v2Trust := body.GetTrust()
trust := apiToLocalTrust(v2Trust.GetTrust(), v2Trust.GetTrustingPeer().GetValue())
trust := apiToLocalTrust(v2Trust.GetTrust(), v2Trust.GetTrustingPeer().GetPublicKey())
err = w.Write(trust)
if err != nil {
return nil, errors.Wrap(err, "could not write intermediate trust")
}
resp := new(v2reputation.SendIntermediateResultResponse)
resp.SetBody(new(v2reputation.SendIntermediateResultResponseBody))
resp := new(v2reputation.AnnounceIntermediateResultResponse)
resp.SetBody(new(v2reputation.AnnounceIntermediateResultResponseBody))
return resp, nil
}
@ -331,7 +331,7 @@ func apiToLocalTrust(t *v2reputation.Trust, trustingPeer []byte) reputation.Trus
localTrust := reputation.Trust{}
localTrust.SetValue(reputation.TrustValueFromFloat64(t.GetValue()))
localTrust.SetPeer(reputation.PeerIDFromBytes(t.GetPeer().GetValue()))
localTrust.SetPeer(reputation.PeerIDFromBytes(t.GetPeer().GetPublicKey()))
localTrust.SetTrustingPeer(reputation.PeerIDFromBytes(trustingPeer))
return localTrust

View file

@ -73,7 +73,7 @@ type RemoteTrustWriter struct {
client apiClient.Client
key *ecdsa.PrivateKey
buf []*apiClient.SendIntermediateTrustPrm
buf []*apiClient.AnnounceIntermediateTrustPrm
}
// Write check if passed context contains required
@ -94,7 +94,7 @@ func (rtp *RemoteTrustWriter) Write(t reputation.Trust) error {
apiPeerToPeerTrust.SetTrustingPeer(apiTrustingPeer)
apiPeerToPeerTrust.SetTrust(apiTrust)
p := &apiClient.SendIntermediateTrustPrm{}
p := &apiClient.AnnounceIntermediateTrustPrm{}
p.SetEpoch(rtp.eiCtx.Epoch())
p.SetIteration(rtp.eiCtx.I())
p.SetTrust(apiPeerToPeerTrust)
@ -108,7 +108,7 @@ func (rtp *RemoteTrustWriter) Write(t reputation.Trust) error {
// If error occurs, returns in immediately and stops iteration.
func (rtp *RemoteTrustWriter) Close() (err error) {
for _, prm := range rtp.buf {
_, err = rtp.client.SendIntermediateTrust(
_, err = rtp.client.AnnounceIntermediateTrust(
rtp.eiCtx,
*prm,
apiClient.WithKey(rtp.key),

View file

@ -84,12 +84,12 @@ func (rtp *RemoteTrustWriter) Write(t reputation.Trust) error {
}
func (rtp *RemoteTrustWriter) Close() error {
prm := apiClient.SendLocalTrustPrm{}
prm := apiClient.AnnounceLocalTrustPrm{}
prm.SetEpoch(rtp.ctx.Epoch())
prm.SetTrusts(rtp.buf)
_, err := rtp.client.SendLocalTrust(
_, err := rtp.client.AnnounceLocalTrust(
rtp.ctx,
prm,
apiClient.WithKey(rtp.key),

2
go.mod
View file

@ -16,7 +16,7 @@ require (
github.com/multiformats/go-multihash v0.0.13 // indirect
github.com/nspcc-dev/hrw v1.0.9
github.com/nspcc-dev/neo-go v0.94.1
github.com/nspcc-dev/neofs-api-go v1.25.1-0.20210427074637-bb217067f442
github.com/nspcc-dev/neofs-api-go v1.26.0
github.com/nspcc-dev/neofs-crypto v0.3.0
github.com/nspcc-dev/tzhash v1.4.0
github.com/panjf2000/ants/v2 v2.3.0

BIN
go.sum

Binary file not shown.

View file

@ -14,7 +14,7 @@ func (rp *Processor) handlePutReputation(ev event.Event) {
rp.log.Info("notification",
zap.String("type", "reputation put"),
zap.String("peer_id", hex.EncodeToString(peerID.ToV2().GetValue())))
zap.String("peer_id", hex.EncodeToString(peerID.ToV2().GetPublicKey())))
// send event to the worker pool

View file

@ -51,7 +51,7 @@ func (rp *Processor) processPut(epoch uint64, id reputation.PeerID, value reputa
if err != nil {
rp.log.Warn("can't send approval tx for reputation value",
zap.String("peer_id", hex.EncodeToString(id.ToV2().GetValue())),
zap.String("peer_id", hex.EncodeToString(id.ToV2().GetPublicKey())),
zap.String("error", err.Error()))
}
}

View file

@ -50,7 +50,7 @@ func (g GetResult) Reputations() []reputation.GlobalTrust {
func (w *ClientWrapper) Get(v GetArgs) (*GetResult, error) {
args := reputationClient.GetArgs{}
args.SetEpoch(v.epoch)
args.SetPeerID(v.peerID.ToV2().GetValue())
args.SetPeerID(v.peerID.ToV2().GetPublicKey())
data, err := (*reputationClient.Client)(w).Get(args)
if err != nil {

View file

@ -60,7 +60,7 @@ func preparePutArgs(v PutArgs) (reputationClient.PutArgs, error) {
}
args.SetEpoch(v.epoch)
args.SetPeerID(v.peerID.ToV2().GetValue())
args.SetPeerID(v.peerID.ToV2().GetPublicKey())
args.SetValue(data)
return args, nil

View file

@ -21,32 +21,32 @@ func New(srv reputationrpc.Server) *Server {
}
}
func (s *Server) SendLocalTrust(ctx context.Context, r *reputation2.SendLocalTrustRequest) (*reputation2.SendLocalTrustResponse, error) {
req := new(reputation.SendLocalTrustRequest)
func (s *Server) AnnounceLocalTrust(ctx context.Context, r *reputation2.AnnounceLocalTrustRequest) (*reputation2.AnnounceLocalTrustResponse, error) {
req := new(reputation.AnnounceLocalTrustRequest)
if err := req.FromGRPCMessage(r); err != nil {
return nil, err
}
resp, err := s.srv.SendLocalTrust(ctx, req)
resp, err := s.srv.AnnounceLocalTrust(ctx, req)
if err != nil {
// TODO: think about how we transport errors through gRPC
return nil, err
}
return resp.ToGRPCMessage().(*reputation2.SendLocalTrustResponse), nil
return resp.ToGRPCMessage().(*reputation2.AnnounceLocalTrustResponse), nil
}
func (s *Server) SendIntermediateResult(ctx context.Context, r *reputation2.SendIntermediateResultRequest) (*reputation2.SendIntermediateResultResponse, error) {
req := new(reputation.SendIntermediateResultRequest)
func (s *Server) AnnounceIntermediateResult(ctx context.Context, r *reputation2.AnnounceIntermediateResultRequest) (*reputation2.AnnounceIntermediateResultResponse, error) {
req := new(reputation.AnnounceIntermediateResultRequest)
if err := req.FromGRPCMessage(r); err != nil {
return nil, err
}
resp, err := s.srv.SendIntermediateResult(ctx, req)
resp, err := s.srv.AnnounceIntermediateResult(ctx, req)
if err != nil {
// TODO: think about how we transport errors through gRPC
return nil, err
}
return resp.ToGRPCMessage().(*reputation2.SendIntermediateResultResponse), nil
return resp.ToGRPCMessage().(*reputation2.AnnounceIntermediateResultResponse), nil
}

View file

@ -23,28 +23,28 @@ func NewResponseService(cnrSvc Server, respSvc *response.Service) Server {
}
}
func (s *responseService) SendLocalTrust(ctx context.Context, req *reputation.SendLocalTrustRequest) (*reputation.SendLocalTrustResponse, error) {
func (s *responseService) AnnounceLocalTrust(ctx context.Context, req *reputation.AnnounceLocalTrustRequest) (*reputation.AnnounceLocalTrustResponse, error) {
resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.SendLocalTrust(ctx, req.(*reputation.SendLocalTrustRequest))
return s.svc.AnnounceLocalTrust(ctx, req.(*reputation.AnnounceLocalTrustRequest))
},
)
if err != nil {
return nil, err
}
return resp.(*reputation.SendLocalTrustResponse), nil
return resp.(*reputation.AnnounceLocalTrustResponse), nil
}
func (s *responseService) SendIntermediateResult(ctx context.Context, req *reputation.SendIntermediateResultRequest) (*reputation.SendIntermediateResultResponse, error) {
func (s *responseService) AnnounceIntermediateResult(ctx context.Context, req *reputation.AnnounceIntermediateResultRequest) (*reputation.AnnounceIntermediateResultResponse, error) {
resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.SendIntermediateResult(ctx, req.(*reputation.SendIntermediateResultRequest))
return s.svc.AnnounceIntermediateResult(ctx, req.(*reputation.AnnounceIntermediateResultRequest))
},
)
if err != nil {
return nil, err
}
return resp.(*reputation.SendIntermediateResultResponse), nil
return resp.(*reputation.AnnounceIntermediateResultResponse), nil
}

View file

@ -8,6 +8,6 @@ import (
// Server is an interface of the NeoFS API v2 Reputation service server.
type Server interface {
SendLocalTrust(context.Context, *reputation.SendLocalTrustRequest) (*reputation.SendLocalTrustResponse, error)
SendIntermediateResult(context.Context, *reputation.SendIntermediateResultRequest) (*reputation.SendIntermediateResultResponse, error)
AnnounceLocalTrust(context.Context, *reputation.AnnounceLocalTrustRequest) (*reputation.AnnounceLocalTrustResponse, error)
AnnounceIntermediateResult(context.Context, *reputation.AnnounceIntermediateResultRequest) (*reputation.AnnounceIntermediateResultResponse, error)
}

View file

@ -21,28 +21,28 @@ func NewSignService(key *ecdsa.PrivateKey, svc Server) Server {
}
}
func (s *signService) SendLocalTrust(ctx context.Context, req *reputation.SendLocalTrustRequest) (*reputation.SendLocalTrustResponse, error) {
func (s *signService) AnnounceLocalTrust(ctx context.Context, req *reputation.AnnounceLocalTrustRequest) (*reputation.AnnounceLocalTrustResponse, error) {
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.SendLocalTrust(ctx, req.(*reputation.SendLocalTrustRequest))
return s.svc.AnnounceLocalTrust(ctx, req.(*reputation.AnnounceLocalTrustRequest))
},
)
if err != nil {
return nil, err
}
return resp.(*reputation.SendLocalTrustResponse), nil
return resp.(*reputation.AnnounceLocalTrustResponse), nil
}
func (s *signService) SendIntermediateResult(ctx context.Context, req *reputation.SendIntermediateResultRequest) (*reputation.SendIntermediateResultResponse, error) {
func (s *signService) AnnounceIntermediateResult(ctx context.Context, req *reputation.AnnounceIntermediateResultRequest) (*reputation.AnnounceIntermediateResultResponse, error) {
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.SendIntermediateResult(ctx, req.(*reputation.SendIntermediateResultRequest))
return s.svc.AnnounceIntermediateResult(ctx, req.(*reputation.AnnounceIntermediateResultRequest))
},
)
if err != nil {
return nil, err
}
return resp.(*reputation.SendIntermediateResultResponse), nil
return resp.(*reputation.AnnounceIntermediateResultResponse), nil
}