Skip to content

Commit

Permalink
Revert "ethstats: fix bug in block reporting (ethereum#28398)"
Browse files Browse the repository at this point in the history
This reverts commit a4ebc4d.
  • Loading branch information
devopsbo3 authored Nov 10, 2023
1 parent 978ba45 commit 0c3a80d
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions ethstats/ethstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,12 @@ type backend interface {
// reporting to ethstats
type fullNodeBackend interface {
backend
Miner() *miner.Miner
BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error)
CurrentBlock() *types.Header
CurrentBlock() *types.Block
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
}

// Service implements an Ethereum netstats reporting daemon that pushes local
// chain statistics up to a monitoring server.
type Service struct {
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0c3a80d

Please sign in to comment.