miner: polish miner configuration (#19480)
* cmd, eth, miner: disable advance sealing if user require * cmd, console, miner, les, eth: wrap the miner config * eth: remove todo * cmd, miner: revert noadvance flag The reason for this is: if the transaction execution is even longer than block time, then this kind of transactions is DoS attack.
This commit is contained in:
committed by
Péter Szilágyi
parent
d9403690ec
commit
6269e5574c
@ -19,10 +19,12 @@ package miner
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/consensus"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
@ -39,6 +41,18 @@ type Backend interface {
|
||||
TxPool() *core.TxPool
|
||||
}
|
||||
|
||||
// Config is the configuration parameters of mining.
|
||||
type Config struct {
|
||||
Etherbase common.Address `toml:",omitempty"` // Public address for block mining rewards (default = first account)
|
||||
Notify []string `toml:",omitempty"` // HTTP URL list to be notified of new work packages(only useful in ethash).
|
||||
ExtraData hexutil.Bytes `toml:",omitempty"` // Block extra data set by the miner
|
||||
GasFloor uint64 // Target gas floor for mined blocks.
|
||||
GasCeil uint64 // Target gas ceiling for mined blocks.
|
||||
GasPrice *big.Int // Minimum gas price for mining a transaction
|
||||
Recommit time.Duration // The time interval for miner to re-create mining work.
|
||||
Noverify bool // Disable remote mining solution verification(only useful in ethash).
|
||||
}
|
||||
|
||||
// Miner creates blocks and searches for proof-of-work values.
|
||||
type Miner struct {
|
||||
mux *event.TypeMux
|
||||
@ -52,13 +66,13 @@ type Miner struct {
|
||||
shouldStart int32 // should start indicates whether we should start after sync
|
||||
}
|
||||
|
||||
func New(eth Backend, config *params.ChainConfig, mux *event.TypeMux, engine consensus.Engine, recommit time.Duration, gasFloor, gasCeil uint64, isLocalBlock func(block *types.Block) bool) *Miner {
|
||||
func New(eth Backend, config *Config, chainConfig *params.ChainConfig, mux *event.TypeMux, engine consensus.Engine, isLocalBlock func(block *types.Block) bool) *Miner {
|
||||
miner := &Miner{
|
||||
eth: eth,
|
||||
mux: mux,
|
||||
engine: engine,
|
||||
exitCh: make(chan struct{}),
|
||||
worker: newWorker(config, engine, eth, mux, recommit, gasFloor, gasCeil, isLocalBlock),
|
||||
worker: newWorker(config, chainConfig, engine, eth, mux, isLocalBlock),
|
||||
canStart: 1,
|
||||
}
|
||||
go miner.update()
|
||||
|
Reference in New Issue
Block a user