Skip to content

Commit

Permalink
start deleting olddiff
Browse files Browse the repository at this point in the history
  • Loading branch information
zarkone committed Sep 10, 2024
1 parent 29fb813 commit 56a8bd3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
56 changes: 17 additions & 39 deletions nodespace/rpchandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion nodesync/nodesync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 56a8bd3

Please sign in to comment.