From 8314e9d740a5ec054e3c76dbdb771eb59679d8b5 Mon Sep 17 00:00:00 2001 From: devopsbo3 <69951731+devopsbo3@users.noreply.github.com> Date: Fri, 10 Nov 2023 12:27:53 -0600 Subject: [PATCH] Revert "ethstats: fix bug in block reporting (#28398)" This reverts commit a4ebc4d38bc08daa9a33dced56855931a8cf41b1. --- ethstats/ethstats.go | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/ethstats/ethstats.go b/ethstats/ethstats.go index 84a6722806..e059844a17 100644 --- a/ethstats/ethstats.go +++ b/ethstats/ethstats.go @@ -76,16 +76,10 @@ type backend interface { // reporting to ethstats type fullNodeBackend interface { backend - BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error) - CurrentBlock() *types.Header - SuggestGasTipCap(ctx context.Context) (*big.Int, error) -} - -// miningNodeBackend encompasses the functionality necessary for a mining node -// reporting to ethstats -type miningNodeBackend interface { - fullNodeBackend Miner() *miner.Miner + BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error) + CurrentBlock() *types.Block + SuggestGasTipCap(ctx context.Context) (*big.Int, error) } // Service implements an Ethereum netstats reporting daemon that pushes local @@ -640,8 +634,7 @@ func (s *Service) assembleBlockStats(block *types.Block) *blockStats { fullBackend, ok := s.backend.(fullNodeBackend) if ok { if block == nil { - head := fullBackend.CurrentBlock() - block, _ = fullBackend.BlockByNumber(context.Background(), rpc.BlockNumber(head.Number.Uint64())) + block = fullBackend.CurrentBlock() } header = block.Header() td = fullBackend.GetTd(context.Background(), header.Hash()) @@ -786,11 +779,10 @@ func (s *Service) reportStats(conn *connWrapper) error { gasprice int ) // check if backend is a full node - if fullBackend, ok := s.backend.(fullNodeBackend); ok { - if miningBackend, ok := s.backend.(miningNodeBackend); ok { - mining = miningBackend.Miner().Mining() - hashrate = int(miningBackend.Miner().Hashrate()) - } + fullBackend, ok := s.backend.(fullNodeBackend) + if ok { + mining = fullBackend.Miner().Mining() + hashrate = int(fullBackend.Miner().Hashrate()) sync := fullBackend.SyncProgress() syncing = fullBackend.CurrentHeader().Number.Uint64() >= sync.HighestBlock