From bc857efc6c3dff2142dde265f146bbe5b97a4e9a Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Sun, 18 Dec 2022 13:43:05 +0100 Subject: [PATCH] Add some comments and checks --- common/commonspace/service.go | 2 ++ common/commonspace/synctree/synctree.go | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/common/commonspace/service.go b/common/commonspace/service.go index 30d2eff2..ae0e704b 100644 --- a/common/commonspace/service.go +++ b/common/commonspace/service.go @@ -112,6 +112,8 @@ func (s *service) NewSpace(ctx context.Context, id string) (Space, error) { var statusService statusservice.StatusService // this will work only for clients, not the best solution, but... + // TODO: maybe change this to dependency injection where we would inject the method `ProvideStatusService` + // and for nodes there would be NoOpStatusService if !lastConfiguration.IsResponsible(st.Id()) { statusService = statusservice.NewStatusService(st.Id(), lastConfiguration) } diff --git a/common/commonspace/synctree/synctree.go b/common/commonspace/synctree/synctree.go index 2541f318..b12751f7 100644 --- a/common/commonspace/synctree/synctree.go +++ b/common/commonspace/synctree/synctree.go @@ -101,7 +101,10 @@ func DeriveSyncTree(ctx context.Context, deps CreateDeps) (id string, err error) deps.Configuration) headUpdate := syncClient.CreateHeadUpdate(objTree, nil) - deps.StatusService.HeadsChange(objTree.ID(), objTree.Heads()) + if deps.StatusService != nil { + // TODO: maybe change to no-op status service + deps.StatusService.HeadsChange(objTree.ID(), objTree.Heads()) + } syncClient.BroadcastAsync(headUpdate) id = objTree.ID() return @@ -119,7 +122,10 @@ func CreateSyncTree(ctx context.Context, deps CreateDeps) (id string, err error) deps.Configuration) headUpdate := syncClient.CreateHeadUpdate(objTree, nil) - deps.StatusService.HeadsChange(objTree.ID(), objTree.Heads()) + + if deps.StatusService != nil { + deps.StatusService.HeadsChange(objTree.ID(), objTree.Heads()) + } syncClient.BroadcastAsync(headUpdate) id = objTree.ID() return