mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
Revert "ethstats: fix bug in block reporting (#28398)"
This reverts commit a4ebc4d38b.
This commit is contained in:
parent
5e566e84d4
commit
8314e9d740
1 changed files with 8 additions and 16 deletions
|
|
@ -76,16 +76,10 @@ type backend interface {
|
||||||
// reporting to ethstats
|
// reporting to ethstats
|
||||||
type fullNodeBackend interface {
|
type fullNodeBackend interface {
|
||||||
backend
|
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
|
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
|
// 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)
|
fullBackend, ok := s.backend.(fullNodeBackend)
|
||||||
if ok {
|
if ok {
|
||||||
if block == nil {
|
if block == nil {
|
||||||
head := fullBackend.CurrentBlock()
|
block = fullBackend.CurrentBlock()
|
||||||
block, _ = fullBackend.BlockByNumber(context.Background(), rpc.BlockNumber(head.Number.Uint64()))
|
|
||||||
}
|
}
|
||||||
header = block.Header()
|
header = block.Header()
|
||||||
td = fullBackend.GetTd(context.Background(), header.Hash())
|
td = fullBackend.GetTd(context.Background(), header.Hash())
|
||||||
|
|
@ -786,11 +779,10 @@ func (s *Service) reportStats(conn *connWrapper) error {
|
||||||
gasprice int
|
gasprice int
|
||||||
)
|
)
|
||||||
// check if backend is a full node
|
// check if backend is a full node
|
||||||
if fullBackend, ok := s.backend.(fullNodeBackend); ok {
|
fullBackend, ok := s.backend.(fullNodeBackend)
|
||||||
if miningBackend, ok := s.backend.(miningNodeBackend); ok {
|
if ok {
|
||||||
mining = miningBackend.Miner().Mining()
|
mining = fullBackend.Miner().Mining()
|
||||||
hashrate = int(miningBackend.Miner().Hashrate())
|
hashrate = int(fullBackend.Miner().Hashrate())
|
||||||
}
|
|
||||||
|
|
||||||
sync := fullBackend.SyncProgress()
|
sync := fullBackend.SyncProgress()
|
||||||
syncing = fullBackend.CurrentHeader().Number.Uint64() >= sync.HighestBlock
|
syncing = fullBackend.CurrentHeader().Number.Uint64() >= sync.HighestBlock
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue