From b6fe352553118795a6279dd70503d644791de758 Mon Sep 17 00:00:00 2001 From: Tim Beatham Date: Thu, 18 Jan 2024 10:50:59 +0000 Subject: [PATCH] main - Done --- pkg/sync/syncer.go | 41 ++++++++++++++--------------------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/pkg/sync/syncer.go b/pkg/sync/syncer.go index d5a4424..227d06c 100644 --- a/pkg/sync/syncer.go +++ b/pkg/sync/syncer.go @@ -97,37 +97,24 @@ func (s *SyncerImpl) Sync(correspondingMesh mesh.MeshProvider) (bool, error) { var succeeded bool = false - var wait sync.WaitGroup + for _, node := range gossipNodes { + correspondingPeer, err := correspondingMesh.GetNode(node) - for index := range gossipNodes { - wait.Add(1) - - syncNode := func(i int) { - node := gossipNodes[i] - correspondingPeer, err := correspondingMesh.GetNode(node) - - defer wait.Done() - - if correspondingPeer == nil || err != nil { - logging.Log.WriteErrorf("node %s does not exist", node) - return - } - - err = s.requester.SyncMesh(correspondingMesh, correspondingPeer) - - if err == nil || err == io.EOF { - succeeded = true - } - - if err != nil { - logging.Log.WriteErrorf(err.Error()) - } + if correspondingPeer == nil || err != nil { + logging.Log.WriteErrorf("node %s does not exist", node) + continue } - go syncNode(index) - } + err = s.requester.SyncMesh(correspondingMesh, correspondingPeer) - wait.Wait() + if err == nil || err == io.EOF { + succeeded = true + } + + if err != nil { + logging.Log.WriteErrorf(err.Error()) + } + } s.syncCount++ logging.Log.WriteInfof("sync time: %v", time.Since(before))