diff --git a/Makefile b/Makefile index d09e2ec..676dcc3 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ .PHONY: proto build test deps -SHELL=/bin/bash +SHELL=/usr/bin/env bash export GOPRIVATE=github.com/anyproto export PATH:=deps:$(PATH) export CGO_ENABLED:=1 diff --git a/nodespace/rpchandler.go b/nodespace/rpchandler.go index 6440bb5..2c896bb 100644 --- a/nodespace/rpchandler.go +++ b/nodespace/rpchandler.go @@ -270,46 +270,24 @@ func (r *rpcHandler) HeadSync(ctx context.Context, req *spacesyncproto.HeadSyncR func (r *rpcHandler) tryNodeHeadSync(req *spacesyncproto.HeadSyncRequest) (resp *spacesyncproto.HeadSyncResponse) { if len(req.Ranges) == 1 && (req.Ranges[0].From == 0 && req.Ranges[0].To == math.MaxUint64) { - switch req.DiffType { - case spacesyncproto.DiffType_Precalculated: - hash, err := r.s.nodeHead.GetHead(req.SpaceId) - if err != nil { - return - } - hashB, err := hex.DecodeString(hash) - if err != nil { - return - } - log.Debug("got head sync with nodehead", zap.String("spaceId", req.SpaceId)) - return &spacesyncproto.HeadSyncResponse{ - DiffType: spacesyncproto.DiffType_Precalculated, - Results: []*spacesyncproto.HeadSyncResult{ - { - Hash: hashB, - // this makes diff not compareResults and create new batch directly (see (d *diff) Diff) - Count: 1, - }, - }, - } - case spacesyncproto.DiffType_Initial: - hash, err := r.s.nodeHead.GetOldHead(req.SpaceId) - if err != nil { - return - } - hashB, err := hex.DecodeString(hash) - if err != nil { - return - } - log.Debug("got head sync with old nodehead", zap.String("spaceId", req.SpaceId)) - return &spacesyncproto.HeadSyncResponse{ - Results: []*spacesyncproto.HeadSyncResult{ - { - Hash: hashB, - // this makes diff not compareResults and create new batch directly (see (d *diff) Diff) - Count: 1, - }, + hash, err := r.s.nodeHead.GetHead(req.SpaceId) + if err != nil { + return + } + hashB, err := hex.DecodeString(hash) + if err != nil { + return + } + log.Debug("got head sync with nodehead", zap.String("spaceId", req.SpaceId)) + return &spacesyncproto.HeadSyncResponse{ + DiffType: spacesyncproto.DiffType_Precalculated, + Results: []*spacesyncproto.HeadSyncResult{ + { + Hash: hashB, + // this makes diff not compareResults and create new batch directly (see (d *diff) Diff) + Count: 1, }, - } + }, } } return nil diff --git a/nodesync/nodesync_test.go b/nodesync/nodesync_test.go index fac3abd..d0d70cd 100644 --- a/nodesync/nodesync_test.go +++ b/nodesync/nodesync_test.go @@ -87,7 +87,7 @@ func TestNodeSync_Sync(t *testing.T) { for i := 0; i < nodeconf.PartitionCount; i++ { if i == 0 { - // calling twice because we now do a twostep diff + // callng twice because we now do a twostep diff // the same as actually was done with real nodes before fx1.nodeHead.EXPECT().LDiff(i).Return(ld1) fx2.nodeHead.EXPECT().LDiff(i).Times(2).Return(ld2)