mirror of
https://github.com/tim-beatham/smegmesh.git
synced 2024-12-13 10:01:22 +01:00
main
- Done
This commit is contained in:
parent
664e54b710
commit
b6fe352553
@ -97,37 +97,24 @@ func (s *SyncerImpl) Sync(correspondingMesh mesh.MeshProvider) (bool, error) {
|
|||||||
|
|
||||||
var succeeded bool = false
|
var succeeded bool = false
|
||||||
|
|
||||||
var wait sync.WaitGroup
|
for _, node := range gossipNodes {
|
||||||
|
correspondingPeer, err := correspondingMesh.GetNode(node)
|
||||||
|
|
||||||
for index := range gossipNodes {
|
if correspondingPeer == nil || err != nil {
|
||||||
wait.Add(1)
|
logging.Log.WriteErrorf("node %s does not exist", node)
|
||||||
|
continue
|
||||||
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())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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++
|
s.syncCount++
|
||||||
logging.Log.WriteInfof("sync time: %v", time.Since(before))
|
logging.Log.WriteInfof("sync time: %v", time.Since(before))
|
||||||
|
Loading…
Reference in New Issue
Block a user