forked from TrueCloudLab/frostfs-node
Update neofs-api-go to v1.26.0
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
bd6d5e7f7b
commit
d49bd4b94a
13 changed files with 40 additions and 40 deletions
|
@ -259,7 +259,7 @@ type reputationServer struct {
|
||||||
routeBuilder reputationrouter.Builder
|
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 := reverseRoute(req.GetVerificationHeader())
|
||||||
passedRoute = append(passedRoute, s)
|
passedRoute = append(passedRoute, s)
|
||||||
|
|
||||||
|
@ -282,13 +282,13 @@ func (s *reputationServer) SendLocalTrust(ctx context.Context, req *v2reputation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := new(v2reputation.SendLocalTrustResponse)
|
resp := new(v2reputation.AnnounceLocalTrustResponse)
|
||||||
resp.SetBody(new(v2reputation.SendLocalTrustResponseBody))
|
resp.SetBody(new(v2reputation.AnnounceLocalTrustResponseBody))
|
||||||
|
|
||||||
return resp, nil
|
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 := reverseRoute(req.GetVerificationHeader())
|
||||||
passedRoute = append(passedRoute, s)
|
passedRoute = append(passedRoute, s)
|
||||||
|
|
||||||
|
@ -303,15 +303,15 @@ func (s *reputationServer) SendIntermediateResult(ctx context.Context, req *v2re
|
||||||
|
|
||||||
v2Trust := body.GetTrust()
|
v2Trust := body.GetTrust()
|
||||||
|
|
||||||
trust := apiToLocalTrust(v2Trust.GetTrust(), v2Trust.GetTrustingPeer().GetValue())
|
trust := apiToLocalTrust(v2Trust.GetTrust(), v2Trust.GetTrustingPeer().GetPublicKey())
|
||||||
|
|
||||||
err = w.Write(trust)
|
err = w.Write(trust)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "could not write intermediate trust")
|
return nil, errors.Wrap(err, "could not write intermediate trust")
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := new(v2reputation.SendIntermediateResultResponse)
|
resp := new(v2reputation.AnnounceIntermediateResultResponse)
|
||||||
resp.SetBody(new(v2reputation.SendIntermediateResultResponseBody))
|
resp.SetBody(new(v2reputation.AnnounceIntermediateResultResponseBody))
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
@ -331,7 +331,7 @@ func apiToLocalTrust(t *v2reputation.Trust, trustingPeer []byte) reputation.Trus
|
||||||
localTrust := reputation.Trust{}
|
localTrust := reputation.Trust{}
|
||||||
|
|
||||||
localTrust.SetValue(reputation.TrustValueFromFloat64(t.GetValue()))
|
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))
|
localTrust.SetTrustingPeer(reputation.PeerIDFromBytes(trustingPeer))
|
||||||
|
|
||||||
return localTrust
|
return localTrust
|
||||||
|
|
|
@ -73,7 +73,7 @@ type RemoteTrustWriter struct {
|
||||||
client apiClient.Client
|
client apiClient.Client
|
||||||
key *ecdsa.PrivateKey
|
key *ecdsa.PrivateKey
|
||||||
|
|
||||||
buf []*apiClient.SendIntermediateTrustPrm
|
buf []*apiClient.AnnounceIntermediateTrustPrm
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write check if passed context contains required
|
// Write check if passed context contains required
|
||||||
|
@ -94,7 +94,7 @@ func (rtp *RemoteTrustWriter) Write(t reputation.Trust) error {
|
||||||
apiPeerToPeerTrust.SetTrustingPeer(apiTrustingPeer)
|
apiPeerToPeerTrust.SetTrustingPeer(apiTrustingPeer)
|
||||||
apiPeerToPeerTrust.SetTrust(apiTrust)
|
apiPeerToPeerTrust.SetTrust(apiTrust)
|
||||||
|
|
||||||
p := &apiClient.SendIntermediateTrustPrm{}
|
p := &apiClient.AnnounceIntermediateTrustPrm{}
|
||||||
p.SetEpoch(rtp.eiCtx.Epoch())
|
p.SetEpoch(rtp.eiCtx.Epoch())
|
||||||
p.SetIteration(rtp.eiCtx.I())
|
p.SetIteration(rtp.eiCtx.I())
|
||||||
p.SetTrust(apiPeerToPeerTrust)
|
p.SetTrust(apiPeerToPeerTrust)
|
||||||
|
@ -108,7 +108,7 @@ func (rtp *RemoteTrustWriter) Write(t reputation.Trust) error {
|
||||||
// If error occurs, returns in immediately and stops iteration.
|
// If error occurs, returns in immediately and stops iteration.
|
||||||
func (rtp *RemoteTrustWriter) Close() (err error) {
|
func (rtp *RemoteTrustWriter) Close() (err error) {
|
||||||
for _, prm := range rtp.buf {
|
for _, prm := range rtp.buf {
|
||||||
_, err = rtp.client.SendIntermediateTrust(
|
_, err = rtp.client.AnnounceIntermediateTrust(
|
||||||
rtp.eiCtx,
|
rtp.eiCtx,
|
||||||
*prm,
|
*prm,
|
||||||
apiClient.WithKey(rtp.key),
|
apiClient.WithKey(rtp.key),
|
||||||
|
|
|
@ -84,12 +84,12 @@ func (rtp *RemoteTrustWriter) Write(t reputation.Trust) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rtp *RemoteTrustWriter) Close() error {
|
func (rtp *RemoteTrustWriter) Close() error {
|
||||||
prm := apiClient.SendLocalTrustPrm{}
|
prm := apiClient.AnnounceLocalTrustPrm{}
|
||||||
|
|
||||||
prm.SetEpoch(rtp.ctx.Epoch())
|
prm.SetEpoch(rtp.ctx.Epoch())
|
||||||
prm.SetTrusts(rtp.buf)
|
prm.SetTrusts(rtp.buf)
|
||||||
|
|
||||||
_, err := rtp.client.SendLocalTrust(
|
_, err := rtp.client.AnnounceLocalTrust(
|
||||||
rtp.ctx,
|
rtp.ctx,
|
||||||
prm,
|
prm,
|
||||||
apiClient.WithKey(rtp.key),
|
apiClient.WithKey(rtp.key),
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -16,7 +16,7 @@ require (
|
||||||
github.com/multiformats/go-multihash v0.0.13 // indirect
|
github.com/multiformats/go-multihash v0.0.13 // indirect
|
||||||
github.com/nspcc-dev/hrw v1.0.9
|
github.com/nspcc-dev/hrw v1.0.9
|
||||||
github.com/nspcc-dev/neo-go v0.94.1
|
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/neofs-crypto v0.3.0
|
||||||
github.com/nspcc-dev/tzhash v1.4.0
|
github.com/nspcc-dev/tzhash v1.4.0
|
||||||
github.com/panjf2000/ants/v2 v2.3.0
|
github.com/panjf2000/ants/v2 v2.3.0
|
||||||
|
|
BIN
go.sum
BIN
go.sum
Binary file not shown.
|
@ -14,7 +14,7 @@ func (rp *Processor) handlePutReputation(ev event.Event) {
|
||||||
|
|
||||||
rp.log.Info("notification",
|
rp.log.Info("notification",
|
||||||
zap.String("type", "reputation put"),
|
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
|
// send event to the worker pool
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ func (rp *Processor) processPut(epoch uint64, id reputation.PeerID, value reputa
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rp.log.Warn("can't send approval tx for reputation value",
|
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()))
|
zap.String("error", err.Error()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ func (g GetResult) Reputations() []reputation.GlobalTrust {
|
||||||
func (w *ClientWrapper) Get(v GetArgs) (*GetResult, error) {
|
func (w *ClientWrapper) Get(v GetArgs) (*GetResult, error) {
|
||||||
args := reputationClient.GetArgs{}
|
args := reputationClient.GetArgs{}
|
||||||
args.SetEpoch(v.epoch)
|
args.SetEpoch(v.epoch)
|
||||||
args.SetPeerID(v.peerID.ToV2().GetValue())
|
args.SetPeerID(v.peerID.ToV2().GetPublicKey())
|
||||||
|
|
||||||
data, err := (*reputationClient.Client)(w).Get(args)
|
data, err := (*reputationClient.Client)(w).Get(args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -60,7 +60,7 @@ func preparePutArgs(v PutArgs) (reputationClient.PutArgs, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
args.SetEpoch(v.epoch)
|
args.SetEpoch(v.epoch)
|
||||||
args.SetPeerID(v.peerID.ToV2().GetValue())
|
args.SetPeerID(v.peerID.ToV2().GetPublicKey())
|
||||||
args.SetValue(data)
|
args.SetValue(data)
|
||||||
|
|
||||||
return args, nil
|
return args, nil
|
||||||
|
|
|
@ -21,32 +21,32 @@ func New(srv reputationrpc.Server) *Server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) SendLocalTrust(ctx context.Context, r *reputation2.SendLocalTrustRequest) (*reputation2.SendLocalTrustResponse, error) {
|
func (s *Server) AnnounceLocalTrust(ctx context.Context, r *reputation2.AnnounceLocalTrustRequest) (*reputation2.AnnounceLocalTrustResponse, error) {
|
||||||
req := new(reputation.SendLocalTrustRequest)
|
req := new(reputation.AnnounceLocalTrustRequest)
|
||||||
if err := req.FromGRPCMessage(r); err != nil {
|
if err := req.FromGRPCMessage(r); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := s.srv.SendLocalTrust(ctx, req)
|
resp, err := s.srv.AnnounceLocalTrust(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: think about how we transport errors through gRPC
|
// TODO: think about how we transport errors through gRPC
|
||||||
return nil, err
|
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) {
|
func (s *Server) AnnounceIntermediateResult(ctx context.Context, r *reputation2.AnnounceIntermediateResultRequest) (*reputation2.AnnounceIntermediateResultResponse, error) {
|
||||||
req := new(reputation.SendIntermediateResultRequest)
|
req := new(reputation.AnnounceIntermediateResultRequest)
|
||||||
if err := req.FromGRPCMessage(r); err != nil {
|
if err := req.FromGRPCMessage(r); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := s.srv.SendIntermediateResult(ctx, req)
|
resp, err := s.srv.AnnounceIntermediateResult(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: think about how we transport errors through gRPC
|
// TODO: think about how we transport errors through gRPC
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.ToGRPCMessage().(*reputation2.SendIntermediateResultResponse), nil
|
return resp.ToGRPCMessage().(*reputation2.AnnounceIntermediateResultResponse), nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,
|
resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
|
||||||
func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
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,
|
resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
|
||||||
func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.(*reputation.SendIntermediateResultResponse), nil
|
return resp.(*reputation.AnnounceIntermediateResultResponse), nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,6 @@ import (
|
||||||
|
|
||||||
// Server is an interface of the NeoFS API v2 Reputation service server.
|
// Server is an interface of the NeoFS API v2 Reputation service server.
|
||||||
type Server interface {
|
type Server interface {
|
||||||
SendLocalTrust(context.Context, *reputation.SendLocalTrustRequest) (*reputation.SendLocalTrustResponse, error)
|
AnnounceLocalTrust(context.Context, *reputation.AnnounceLocalTrustRequest) (*reputation.AnnounceLocalTrustResponse, error)
|
||||||
SendIntermediateResult(context.Context, *reputation.SendIntermediateResultRequest) (*reputation.SendIntermediateResultResponse, error)
|
AnnounceIntermediateResult(context.Context, *reputation.AnnounceIntermediateResultRequest) (*reputation.AnnounceIntermediateResultResponse, error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,
|
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
|
||||||
func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
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,
|
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
|
||||||
func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.(*reputation.SendIntermediateResultResponse), nil
|
return resp.(*reputation.AnnounceIntermediateResultResponse), nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue