diff --git a/commonspace/headsync/headsync.go b/commonspace/headsync/headsync.go index 60168274..f72f66db 100644 --- a/commonspace/headsync/headsync.go +++ b/commonspace/headsync/headsync.go @@ -23,7 +23,7 @@ type TreeHeads struct { type HeadSync interface { Init(objectIds []string, deletionState deletionstate.DeletionState) - + UpdateHeads(id string, heads []string) HandleRangeRequest(ctx context.Context, req *spacesyncproto.HeadSyncRequest) (resp *spacesyncproto.HeadSyncResponse, err error) RemoveObjects(ids []string) @@ -126,6 +126,9 @@ func (d *headSync) fillDiff(objectIds []string) { }) } d.diff.Set(els...) + if err := d.storage.WriteSpaceHash(d.diff.Hash()); err != nil { + d.log.Error("can't write space hash", zap.Error(err)) + } } func concatStrings(strs []string) string { diff --git a/commonspace/headsync/headsync_test.go b/commonspace/headsync/headsync_test.go index bb20dfc3..2db23aff 100644 --- a/commonspace/headsync/headsync_test.go +++ b/commonspace/headsync/headsync_test.go @@ -46,6 +46,9 @@ func TestDiffService(t *testing.T) { Id: initId, Head: "h1h2", }) + hash := "123" + diffMock.EXPECT().Hash().Return(hash) + storageMock.EXPECT().WriteSpaceHash(hash) pSyncMock.EXPECT().Run() service.Init([]string{initId}, delState) }) diff --git a/commonspace/spacestorage/spacestorage.go b/commonspace/spacestorage/spacestorage.go index 08469f2f..348a408b 100644 --- a/commonspace/spacestorage/spacestorage.go +++ b/commonspace/spacestorage/spacestorage.go @@ -37,7 +37,7 @@ type SpaceStorage interface { TreeRoot(id string) (*treechangeproto.RawTreeChangeWithId, error) TreeStorage(id string) (treestorage.TreeStorage, error) CreateTreeStorage(payload treestorage.TreeStorageCreatePayload) (treestorage.TreeStorage, error) - WriteSpaceHash(head string) error + WriteSpaceHash(hash string) error ReadSpaceHash() (hash string, err error) Close() error