From abb86dbb8eed352605f0a39bd34ba781e8513f13 Mon Sep 17 00:00:00 2001 From: Giulio Date: Thu, 2 May 2024 22:12:11 +0200 Subject: [PATCH 1/2] save --- p2p/sentry/sentry_multi_client/sentry_multi_client.go | 4 +++- p2p/sentry/status_data_provider.go | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/p2p/sentry/sentry_multi_client/sentry_multi_client.go b/p2p/sentry/sentry_multi_client/sentry_multi_client.go index a794911a353..4246e893936 100644 --- a/p2p/sentry/sentry_multi_client/sentry_multi_client.go +++ b/p2p/sentry/sentry_multi_client/sentry_multi_client.go @@ -156,7 +156,9 @@ func SentryReconnectAndPumpStreamLoop[TMessage interface{}]( statusData, err := statusDataFactory(ctx) if err != nil { - logger.Error("SentryReconnectAndPumpStreamLoop: statusDataFactory error", "stream", streamName, "err", err) + if errors.Is(err, sentry.ErrNoHead) { + logger.Error("SentryReconnectAndPumpStreamLoop: statusDataFactory error", "stream", streamName, "err", err) + } time.Sleep(time.Second) continue } diff --git a/p2p/sentry/status_data_provider.go b/p2p/sentry/status_data_provider.go index f278bccec6a..5e0870353b8 100644 --- a/p2p/sentry/status_data_provider.go +++ b/p2p/sentry/status_data_provider.go @@ -18,6 +18,8 @@ import ( "github.com/ledgerwatch/erigon/core/types" ) +var ErrNoHead = errors.New("ReadChainHead: ReadCurrentHeader error") + type ChainHead struct { HeadHeight uint64 HeadTime uint64 @@ -77,7 +79,7 @@ func (s *StatusDataProvider) GetStatusData(ctx context.Context) (*proto_sentry.S func ReadChainHeadWithTx(tx kv.Tx) (ChainHead, error) { header := rawdb.ReadCurrentHeaderHavingBody(tx) if header == nil { - return ChainHead{}, errors.New("ReadChainHead: ReadCurrentHeader error") + return ChainHead{}, ErrNoHead } height := header.Number.Uint64() From 6850ec826981c255429f78f480340369f3385ab7 Mon Sep 17 00:00:00 2001 From: Giulio Date: Thu, 2 May 2024 22:30:29 +0200 Subject: [PATCH 2/2] save --- p2p/sentry/sentry_multi_client/sentry_multi_client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/p2p/sentry/sentry_multi_client/sentry_multi_client.go b/p2p/sentry/sentry_multi_client/sentry_multi_client.go index 4246e893936..d00ee47cedf 100644 --- a/p2p/sentry/sentry_multi_client/sentry_multi_client.go +++ b/p2p/sentry/sentry_multi_client/sentry_multi_client.go @@ -156,7 +156,7 @@ func SentryReconnectAndPumpStreamLoop[TMessage interface{}]( statusData, err := statusDataFactory(ctx) if err != nil { - if errors.Is(err, sentry.ErrNoHead) { + if !errors.Is(err, sentry.ErrNoHead) { logger.Error("SentryReconnectAndPumpStreamLoop: statusDataFactory error", "stream", streamName, "err", err) } time.Sleep(time.Second)