cmd, core, eth, miner, params: configurable gas floor and ceil
This commit is contained in:
@@ -52,13 +52,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) *Miner {
|
||||
func New(eth Backend, config *params.ChainConfig, mux *event.TypeMux, engine consensus.Engine, recommit time.Duration, gasFloor, gasCeil uint64) *Miner {
|
||||
miner := &Miner{
|
||||
eth: eth,
|
||||
mux: mux,
|
||||
engine: engine,
|
||||
exitCh: make(chan struct{}),
|
||||
worker: newWorker(config, engine, eth, mux, recommit),
|
||||
worker: newWorker(config, engine, eth, mux, recommit, gasFloor, gasCeil),
|
||||
canStart: 1,
|
||||
}
|
||||
go miner.update()
|
||||
|
@@ -206,6 +206,8 @@ func makeSealer(genesis *core.Genesis, nodes []string) (*node.Node, error) {
|
||||
DatabaseHandles: 256,
|
||||
TxPool: core.DefaultTxPoolConfig,
|
||||
GPO: eth.DefaultConfig.GPO,
|
||||
MinerGasFloor: genesis.GasLimit * 9 / 10,
|
||||
MinerGasCeil: genesis.GasLimit * 11 / 10,
|
||||
MinerGasPrice: big.NewInt(1),
|
||||
MinerRecommit: time.Second,
|
||||
})
|
||||
|
@@ -186,6 +186,8 @@ func makeMiner(genesis *core.Genesis, nodes []string) (*node.Node, error) {
|
||||
TxPool: core.DefaultTxPoolConfig,
|
||||
GPO: eth.DefaultConfig.GPO,
|
||||
Ethash: eth.DefaultConfig.Ethash,
|
||||
MinerGasFloor: genesis.GasLimit * 9 / 10,
|
||||
MinerGasCeil: genesis.GasLimit * 11 / 10,
|
||||
MinerGasPrice: big.NewInt(1),
|
||||
MinerRecommit: time.Second,
|
||||
})
|
||||
|
@@ -127,6 +127,9 @@ type worker struct {
|
||||
eth Backend
|
||||
chain *core.BlockChain
|
||||
|
||||
gasFloor uint64
|
||||
gasCeil uint64
|
||||
|
||||
// Subscriptions
|
||||
mux *event.TypeMux
|
||||
txsCh chan core.NewTxsEvent
|
||||
@@ -171,13 +174,15 @@ type worker struct {
|
||||
resubmitHook func(time.Duration, time.Duration) // Method to call upon updating resubmitting interval.
|
||||
}
|
||||
|
||||
func newWorker(config *params.ChainConfig, engine consensus.Engine, eth Backend, mux *event.TypeMux, recommit time.Duration) *worker {
|
||||
func newWorker(config *params.ChainConfig, engine consensus.Engine, eth Backend, mux *event.TypeMux, recommit time.Duration, gasFloor, gasCeil uint64) *worker {
|
||||
worker := &worker{
|
||||
config: config,
|
||||
engine: engine,
|
||||
eth: eth,
|
||||
mux: mux,
|
||||
chain: eth.BlockChain(),
|
||||
gasFloor: gasFloor,
|
||||
gasCeil: gasCeil,
|
||||
possibleUncles: make(map[common.Hash]*types.Block),
|
||||
unconfirmed: newUnconfirmedBlocks(eth.BlockChain(), miningLogAtDepth),
|
||||
pendingTasks: make(map[common.Hash]*task),
|
||||
@@ -807,7 +812,7 @@ func (w *worker) commitNewWork(interrupt *int32, noempty bool) {
|
||||
header := &types.Header{
|
||||
ParentHash: parent.Hash(),
|
||||
Number: num.Add(num, common.Big1),
|
||||
GasLimit: core.CalcGasLimit(parent),
|
||||
GasLimit: core.CalcGasLimit(parent, w.gasFloor, w.gasCeil),
|
||||
Extra: w.extra,
|
||||
Time: big.NewInt(tstamp),
|
||||
}
|
||||
|
@@ -119,7 +119,7 @@ func (b *testWorkerBackend) PostChainEvents(events []interface{}) {
|
||||
func newTestWorker(t *testing.T, chainConfig *params.ChainConfig, engine consensus.Engine) (*worker, *testWorkerBackend) {
|
||||
backend := newTestWorkerBackend(t, chainConfig, engine)
|
||||
backend.txPool.AddLocals(pendingTxs)
|
||||
w := newWorker(chainConfig, engine, backend, new(event.TypeMux), time.Second)
|
||||
w := newWorker(chainConfig, engine, backend, new(event.TypeMux), time.Second, params.GenesisGasLimit, params.GenesisGasLimit)
|
||||
w.setEtherbase(testBankAddress)
|
||||
return w, backend
|
||||
}
|
||||
|
Reference in New Issue
Block a user