RelayConnect() ensures there will be a connection, and handle connection errors better.

This commit is contained in:
fiatjaf
2022-11-15 07:53:50 -03:00
parent 2b8807d699
commit dd0571229b
2 changed files with 18 additions and 8 deletions
+5 -1
View File
@@ -65,7 +65,11 @@ func (r *RelayPool) Add(url string, policy RelayPoolPolicy) error {
policy = SimplePolicy{Read: true, Write: true}
}
relay := NewRelay(url)
relay, err := RelayConnect(url)
if err != nil {
return err
}
r.Policies.Store(relay.URL, policy)
r.Relays.Store(relay.URL, relay)