1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-08 05:57:03 +09:00

GO-3921: add new network compatibility status

Signed-off-by: AnastasiaShemyakinskaya <shem98a@mail.ru>
This commit is contained in:
AnastasiaShemyakinskaya 2024-08-22 14:51:23 +02:00
parent fbe57f83d1
commit 4d565195a3
No known key found for this signature in database
GPG key ID: CCD60ED83B103281
7 changed files with 57 additions and 2 deletions

View file

@ -4,6 +4,7 @@ package coordinatorclient
import (
"context"
"errors"
"github.com/anyproto/any-sync/net/secureservice"
"storj.io/drpc"
@ -40,6 +41,7 @@ type CoordinatorClient interface {
SpaceMakeShareable(ctx context.Context, spaceId string) (err error)
SpaceMakeUnshareable(ctx context.Context, spaceId, aclId string) (err error)
NetworkConfiguration(ctx context.Context, currentId string) (*coordinatorproto.NetworkConfigurationResponse, error)
IsNetworkNeedsUpdate(ctx context.Context) (bool, error)
DeletionLog(ctx context.Context, lastRecordId string, limit int) (records []*coordinatorproto.DeletionLogRecord, err error)
IdentityRepoPut(ctx context.Context, identity string, data []*identityrepoproto.Data) (err error)
@ -350,6 +352,18 @@ func (c *coordinatorClient) AclEventLog(ctx context.Context, accountId, lastReco
return
}
func (c *coordinatorClient) IsNetworkNeedsUpdate(ctx context.Context) (bool, error) {
p, err := c.getPeer(ctx)
if err != nil {
return false, err
}
version, err := peer.CtxProtoVersion(p.Context())
if err != nil {
return false, err
}
return version != secureservice.ProtoVersion, nil
}
func (c *coordinatorClient) doClient(ctx context.Context, f func(cl coordinatorproto.DRPCCoordinatorClient) error) error {
p, err := c.getPeer(ctx)
if err != nil {

View file

@ -5,7 +5,6 @@
//
// mockgen -destination mock_coordinatorclient/mock_coordinatorclient.go github.com/anyproto/any-sync/coordinator/coordinatorclient CoordinatorClient
//
// Package mock_coordinatorclient is a generated GoMock package.
package mock_coordinatorclient
@ -190,6 +189,21 @@ func (mr *MockCoordinatorClientMockRecorder) Init(arg0 any) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockCoordinatorClient)(nil).Init), arg0)
}
// IsNetworkNeedsUpdate mocks base method.
func (m *MockCoordinatorClient) IsNetworkNeedsUpdate(arg0 context.Context) (bool, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IsNetworkNeedsUpdate", arg0)
ret0, _ := ret[0].(bool)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// IsNetworkNeedsUpdate indicates an expected call of IsNetworkNeedsUpdate.
func (mr *MockCoordinatorClientMockRecorder) IsNetworkNeedsUpdate(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsNetworkNeedsUpdate", reflect.TypeOf((*MockCoordinatorClient)(nil).IsNetworkNeedsUpdate), arg0)
}
// Name mocks base method.
func (m *MockCoordinatorClient) Name() string {
m.ctrl.T.Helper()

View file

@ -66,10 +66,18 @@ func (n *nodeConfSource) GetLast(ctx context.Context, currentId string) (c nodec
Types: types,
}
}
needsUpdate, err := n.cl.IsNetworkNeedsUpdate(ctx)
if err != nil {
return
}
if needsUpdate {
err = nodeconf.ErrNetworkNeedsUpdate
}
return nodeconf.Configuration{
Id: res.ConfigurationId,
NetworkId: res.NetworkId,
Nodes: nodes,
CreationTime: time.Unix(int64(res.CreationTimeUnix), 0),
}, nil
}, err
}