From 545da442fcd8c5a210382b6b5c6bcee0e3ccb037 Mon Sep 17 00:00:00 2001 From: boreq Date: Mon, 30 Oct 2023 12:20:56 +0900 Subject: [PATCH] Fix relay lookup --- service/adapters/purple_pages.go | 4 +++- service/adapters/relay_source.go | 1 - service/app/downloader.go | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/service/adapters/purple_pages.go b/service/adapters/purple_pages.go index 23de09d..a7ab8f1 100644 --- a/service/adapters/purple_pages.go +++ b/service/adapters/purple_pages.go @@ -77,7 +77,9 @@ func (p *PurplePages) GetRelays(ctx context.Context, publicKey domain.PublicKey) var compoundError error errorsCounter := 0 - for result := range ch { + for i := 0; i < 2; i++ { + result := <-ch + if result.Err != nil { if errors.Is(err, ErrPurplePagesTimeout) { return nil, errors.Wrap(err, "one of the lookups timed out") diff --git a/service/adapters/relay_source.go b/service/adapters/relay_source.go index 7c366cf..0685913 100644 --- a/service/adapters/relay_source.go +++ b/service/adapters/relay_source.go @@ -2,7 +2,6 @@ package adapters import ( "context" - "github.com/boreq/errors" "github.com/planetary-social/nos-crossposting-service/internal" "github.com/planetary-social/nos-crossposting-service/internal/logging" diff --git a/service/app/downloader.go b/service/app/downloader.go index d290f6f..304cdf4 100644 --- a/service/app/downloader.go +++ b/service/app/downloader.go @@ -240,6 +240,7 @@ func (d *PublicKeyDownloader) refreshRelays(longCtx context.Context) error { defer fnCtxCancel() relayAddresses, err := d.relaySource.GetRelays(fnCtx, d.publicKey) + d.logger.Debug().WithField("n", len(relayAddresses)).WithField("err", err).Message("got relays") if err != nil { return errors.Wrap(err, "error getting relayAddresses") }