mirror of
https://github.com/tim-beatham/smegmesh.git
synced 2025-08-18 00:49:47 +02:00
27-remove-client-grpc-endpoint
Removed a client's grpc endpoint value. Client's aren't publicly available so there is no need for a client's gRPC endpoint. Also changed a node ID's to their public key. A node id's public address is an issue for mobility of clients as their endpoint is subject to change
This commit is contained in:
@@ -45,14 +45,19 @@ func (s *SyncerImpl) Sync(meshId string) error {
|
||||
}
|
||||
|
||||
nodeNames := s.manager.GetMesh(meshId).GetPeers()
|
||||
|
||||
self, err := s.manager.GetSelf(meshId)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
neighbours := s.cluster.GetNeighbours(nodeNames, self.GetHostEndpoint())
|
||||
selfPublickey, err := self.GetPublicKey()
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
neighbours := s.cluster.GetNeighbours(nodeNames, selfPublickey.String())
|
||||
randomSubset := lib.RandomSubsetOfLength(neighbours, s.conf.BranchRate)
|
||||
|
||||
for _, node := range randomSubset {
|
||||
@@ -63,7 +68,7 @@ func (s *SyncerImpl) Sync(meshId string) error {
|
||||
|
||||
if len(nodeNames) > s.conf.ClusterSize && rand.Float64() < s.conf.InterClusterChance {
|
||||
logging.Log.WriteInfof("Sending to random cluster")
|
||||
interCluster := s.cluster.GetInterCluster(nodeNames, self.GetHostEndpoint())
|
||||
interCluster := s.cluster.GetInterCluster(nodeNames, selfPublickey.String())
|
||||
randomSubset = append(randomSubset, interCluster)
|
||||
}
|
||||
|
||||
@@ -74,7 +79,14 @@ func (s *SyncerImpl) Sync(meshId string) error {
|
||||
|
||||
go func(i int) error {
|
||||
defer waitGroup.Done()
|
||||
err := s.requester.SyncMesh(meshId, randomSubset[i])
|
||||
|
||||
correspondingPeer := s.manager.GetNode(meshId, randomSubset[i])
|
||||
|
||||
if correspondingPeer == nil {
|
||||
logging.Log.WriteErrorf("node %s does not exist", randomSubset[i])
|
||||
}
|
||||
|
||||
err := s.requester.SyncMesh(meshId, correspondingPeer.GetHostEndpoint())
|
||||
return err
|
||||
}(index)
|
||||
}
|
||||
|
Reference in New Issue
Block a user