les: duplicate downloader and fetcher to allow progressive refactoring

This commit is contained in:
Péter Szilágyi
2021-09-10 10:55:48 +03:00
parent 90987db733
commit 9e17648d8c
27 changed files with 8746 additions and 22 deletions

View File

@ -30,12 +30,12 @@ import (
"sync"
"time"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/mclock"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth/downloader"
ethproto "github.com/ethereum/go-ethereum/eth/protocols/eth"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/les"
@ -67,7 +67,7 @@ type backend interface {
HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error)
GetTd(ctx context.Context, hash common.Hash) *big.Int
Stats() (pending int, queued int)
Downloader() *downloader.Downloader
SyncProgress() ethereum.SyncProgress
}
// fullNodeBackend encompasses the functionality necessary for a full node
@ -777,7 +777,7 @@ func (s *Service) reportStats(conn *connWrapper) error {
mining = fullBackend.Miner().Mining()
hashrate = int(fullBackend.Miner().Hashrate())
sync := fullBackend.Downloader().Progress()
sync := fullBackend.SyncProgress()
syncing = fullBackend.CurrentHeader().Number.Uint64() >= sync.HighestBlock
price, _ := fullBackend.SuggestGasTipCap(context.Background())
@ -786,7 +786,7 @@ func (s *Service) reportStats(conn *connWrapper) error {
gasprice += int(basefee.Uint64())
}
} else {
sync := s.backend.Downloader().Progress()
sync := s.backend.SyncProgress()
syncing = s.backend.CurrentHeader().Number.Uint64() >= sync.HighestBlock
}
// Assemble the node stats and send it to the server