Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuke old miner and mux #1666

Merged
merged 4 commits into from
Apr 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -815,8 +815,7 @@ type filterBackend struct {
b *SimulatedBackend
}

func (fb *filterBackend) ChainDb() ethdb.Database { return fb.db }
func (fb *filterBackend) EventMux() *event.TypeMux { panic("not supported") }
func (fb *filterBackend) ChainDb() ethdb.Database { return fb.db }

func (fb *filterBackend) HeaderByNumber(ctx context.Context, block rpc.BlockNumber) (*types.Header, error) {
if block == rpc.LatestBlockNumber {
Expand Down
3 changes: 0 additions & 3 deletions core/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ import (
// NewTxsEvent is posted when a batch of transactions enter the transaction pool.
type NewTxsEvent struct{ Txs []*types.Transaction }

// NewMinedBlockEvent is posted when a block has been imported.
type NewMinedBlockEvent struct{ Block *types.Block }

// RemovedLogsEvent is posted when a reorg happens
type RemovedLogsEvent struct{ Logs []*types.Log }

Expand Down
37 changes: 0 additions & 37 deletions eth/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"github.com/ledgerwatch/turbo-geth/eth/gasprice"
"github.com/ledgerwatch/turbo-geth/ethdb"
"github.com/ledgerwatch/turbo-geth/event"
"github.com/ledgerwatch/turbo-geth/miner"
"github.com/ledgerwatch/turbo-geth/params"
"github.com/ledgerwatch/turbo-geth/rpc"
)
Expand Down Expand Up @@ -62,25 +61,13 @@ func (b *EthAPIBackend) SetHead(number uint64) {
}

func (b *EthAPIBackend) resolveBlockNumber(blockNr rpc.BlockNumber) uint64 {
// Pending block is only known by the miner
if blockNr == rpc.PendingBlockNumber {
block := b.eth.miner.PendingBlock()
return block.NumberU64()
}

if blockNr == rpc.LatestBlockNumber {
return b.eth.blockchain.CurrentBlock().NumberU64()
}
return uint64(blockNr)
}

func (b *EthAPIBackend) HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Header, error) {
// Pending block is only known by the miner
if blockNr == rpc.PendingBlockNumber {
block := b.eth.miner.PendingBlock()
return block.Header(), nil
}
// Otherwise resolve and return the block
bn := b.resolveBlockNumber(blockNr)
return b.eth.blockchain.GetHeaderByNumber(bn), nil
}
Expand All @@ -107,12 +94,6 @@ func (b *EthAPIBackend) HeaderByHash(ctx context.Context, hash common.Hash) (*ty
}

func (b *EthAPIBackend) BlockByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Block, error) {
// Pending block is only known by the miner
if blockNr == rpc.PendingBlockNumber {
block := b.eth.miner.PendingBlock()
return block, nil
}
// Otherwise resolve and return the block
bn := b.resolveBlockNumber(blockNr)
return b.eth.blockchain.GetBlockByNumber(bn), nil
}
Expand Down Expand Up @@ -143,12 +124,6 @@ func (b *EthAPIBackend) BlockByNumberOrHash(ctx context.Context, blockNrOrHash r
}

func (b *EthAPIBackend) StateAndHeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*state.IntraBlockState, *types.Header, error) {
// Pending state is only known by the miner
if blockNr == rpc.PendingBlockNumber {
block, state, _ := b.eth.miner.Pending()
return state, block.Header(), nil
}
// Otherwise resolve the block number and return its state
bn := b.resolveBlockNumber(blockNr)
header, err := b.HeaderByNumber(ctx, blockNr)
if err != nil {
Expand Down Expand Up @@ -265,10 +240,6 @@ func (b *EthAPIBackend) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEven
return b.eth.BlockChain().SubscribeRemovedLogsEvent(ch)
}

func (b *EthAPIBackend) SubscribePendingLogsEvent(ch chan<- []*types.Log) event.Subscription {
return b.eth.miner.SubscribePendingLogs(ch)
}

func (b *EthAPIBackend) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription {
return b.eth.BlockChain().SubscribeChainEvent(ch)
}
Expand Down Expand Up @@ -342,10 +313,6 @@ func (b *EthAPIBackend) ChainDb() ethdb.Database {
return b.eth.ChainDb()
}

func (b *EthAPIBackend) EventMux() *event.TypeMux {
return b.eth.EventMux()
}

func (b *EthAPIBackend) ExtRPCEnabled() bool {
return b.extRPCEnabled
}
Expand Down Expand Up @@ -380,10 +347,6 @@ func (b *EthAPIBackend) CurrentHeader() *types.Header {
return b.eth.blockchain.CurrentHeader()
}

func (b *EthAPIBackend) Miner() *miner.Miner {
return b.eth.Miner()
}

func (b *EthAPIBackend) StartMining(threads int) error {
return b.eth.StartMining(threads)
}
Expand Down
16 changes: 2 additions & 14 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,8 @@ import (
"github.com/ledgerwatch/turbo-geth/eth/stagedsync/stages"
"github.com/ledgerwatch/turbo-geth/ethdb"
"github.com/ledgerwatch/turbo-geth/ethdb/remote/remotedbserver"
"github.com/ledgerwatch/turbo-geth/event"
"github.com/ledgerwatch/turbo-geth/internal/ethapi"
"github.com/ledgerwatch/turbo-geth/log"
"github.com/ledgerwatch/turbo-geth/miner"
"github.com/ledgerwatch/turbo-geth/node"
"github.com/ledgerwatch/turbo-geth/p2p"
"github.com/ledgerwatch/turbo-geth/p2p/enode"
Expand Down Expand Up @@ -91,14 +89,12 @@ type Ethereum struct {
chainKV ethdb.RwKV // Same as chainDb, but different interface
privateAPI *grpc.Server

eventMux *event.TypeMux
engine consensus.Engine
engine consensus.Engine

bloomRequests chan chan *bloombits.Retrieval // Channel receiving bloom data retrieval requests

APIBackend *EthAPIBackend

miner *miner.Miner
gasPrice *uint256.Int
etherbase common.Address
signer *ecdsa.PrivateKey
Expand Down Expand Up @@ -288,7 +284,6 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
config: config,
chainDb: chainDb,
chainKV: chainDb.(ethdb.HasRwKV).RwKV(),
eventMux: stack.EventMux(),
engine: ethconfig.CreateConsensusEngine(chainConfig, &config.Ethash, config.Miner.Notify, config.Miner.Noverify, chainDb),
networkID: config.NetworkID,
etherbase: config.Miner.Etherbase,
Expand Down Expand Up @@ -436,7 +431,6 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
Chain: eth.blockchain,
TxPool: eth.txPool,
Network: config.NetworkID,
EventMux: eth.eventMux,
Checkpoint: checkpoint,

Whitelist: config.Whitelist,
Expand Down Expand Up @@ -638,8 +632,6 @@ func (s *Ethereum) SetEtherbase(etherbase common.Address) {
s.lock.Lock()
s.etherbase = etherbase
s.lock.Unlock()

s.miner.SetEtherbase(etherbase)
}

// StartMining starts the miner with the given number of CPU threads. If mining
Expand Down Expand Up @@ -684,7 +676,6 @@ func (s *Ethereum) StartMining(threads int) error {
// If mining is started, we can disable the transaction rejection mechanism
// introduced to speed sync times.
atomic.StoreUint32(&s.handler.acceptTxs, 1)
//go s.miner.Start(eb)
}
return nil
}
Expand All @@ -701,12 +692,10 @@ func (s *Ethereum) StopMining() {
}
}

func (s *Ethereum) IsMining() bool { return s.config.Miner.Enabled }
func (s *Ethereum) Miner() *miner.Miner { return s.miner }
func (s *Ethereum) IsMining() bool { return s.config.Miner.Enabled }

func (s *Ethereum) BlockChain() *core.BlockChain { return s.blockchain }
func (s *Ethereum) TxPool() *core.TxPool { return s.txPool }
func (s *Ethereum) EventMux() *event.TypeMux { return s.eventMux }
func (s *Ethereum) Engine() consensus.Engine { return s.engine }
func (s *Ethereum) ChainDb() ethdb.Database { return s.chainDb }
func (s *Ethereum) ChainKV() ethdb.RwKV { return s.chainKV }
Expand Down Expand Up @@ -760,7 +749,6 @@ func (s *Ethereum) Stop() error {
//s.miner.Stop()
s.blockchain.Stop()
s.engine.Close()
s.eventMux.Stop()
if s.txPool != nil {
s.txPool.Stop()
}
Expand Down
166 changes: 0 additions & 166 deletions eth/downloader/api.go

This file was deleted.

Loading