mirror of
https://github.com/tim-beatham/smegmesh.git
synced 2025-06-24 14:01:37 +02:00
bugfix-pull-only
Bugfix with inter-cluster communication pull not working
This commit is contained in:
parent
ad22f04b0d
commit
b6199892f0
@ -55,12 +55,14 @@ func (i *ConnClusterImpl) GetNeighbours(global []string, selfId string) []string
|
|||||||
// you will communicate with a random node that is not in your cluster.
|
// you will communicate with a random node that is not in your cluster.
|
||||||
func (i *ConnClusterImpl) GetInterCluster(global []string, selfId string) string {
|
func (i *ConnClusterImpl) GetInterCluster(global []string, selfId string) string {
|
||||||
// Doesn't matter if not in it. Get index of where the node 'should' be
|
// Doesn't matter if not in it. Get index of where the node 'should' be
|
||||||
|
slices.Sort(global)
|
||||||
|
|
||||||
index, _ := binarySearch(global, selfId, 1)
|
index, _ := binarySearch(global, selfId, 1)
|
||||||
numClusters := math.Ceil(float64(len(global)) / float64(i.clusterSize))
|
numClusters := math.Ceil(float64(len(global)) / float64(i.clusterSize))
|
||||||
|
|
||||||
randomCluster := rand.Intn(int(numClusters)-1) + 1
|
randomCluster := rand.Intn(int(numClusters)-1) + 1
|
||||||
|
|
||||||
neighbourIndex := (index + randomCluster) % len(global)
|
neighbourIndex := (index + (randomCluster * i.clusterSize)) % len(global)
|
||||||
return global[neighbourIndex]
|
return global[neighbourIndex]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user