diff --git a/synced-pool.go b/synced-pool.go index 8412dc4..d06f281 100644 --- a/synced-pool.go +++ b/synced-pool.go @@ -363,17 +363,23 @@ func (p *SyncedPool) removeLocalGrain(id CartId) { func (p *SyncedPool) AddRemote(host string) { _, hasHost := p.remotes[host] - if host == "" || hasHost { + if host == "" || hasHost || host == p.Hostname { return } - // if host == "" || hasHost || host == p.Hostname { - // return - // } + client := NewConnection(fmt.Sprintf("%s:1338", host)) - r, err := client.Call(Ping, nil) - if err != nil { - log.Printf("Error connecting to remote %s: %s\n", host, err) - return + var r *FrameWithPayload + var err error + pings := 3 + for pings >= 0 { + r, err = client.Call(Ping, nil) + if err != nil { + log.Printf("Ping failed when adding %s, trying %d more times\n", host, pings) + pings-- + time.Sleep(time.Millisecond * 300) + continue + } + break } log.Printf("Connected to remote %s: %v\n", host, r)