aboutsummaryrefslogtreecommitdiffstats
path: root/miner
diff options
context:
space:
mode:
Diffstat (limited to 'miner')
-rw-r--r--miner/miner.go4
-rw-r--r--miner/stress_clique.go2
-rw-r--r--miner/stress_ethash.go2
-rw-r--r--miner/worker.go9
-rw-r--r--miner/worker_test.go2
5 files changed, 14 insertions, 5 deletions
diff --git a/miner/miner.go b/miner/miner.go
index c5a0c9d62..7f194db26 100644
--- a/miner/miner.go
+++ b/miner/miner.go
@@ -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()
diff --git a/miner/stress_clique.go b/miner/stress_clique.go
index 8545b9413..8961091d5 100644
--- a/miner/stress_clique.go
+++ b/miner/stress_clique.go
@@ -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,
})
diff --git a/miner/stress_ethash.go b/miner/stress_ethash.go
index 4ed8aeee4..5ed11d73a 100644
--- a/miner/stress_ethash.go
+++ b/miner/stress_ethash.go
@@ -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,
})
diff --git a/miner/worker.go b/miner/worker.go
index 99f1f8dcf..629ce5bd2 100644
--- a/miner/worker.go
+++ b/miner/worker.go
@@ -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),
@@ -810,7 +815,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),
}
diff --git a/miner/worker_test.go b/miner/worker_test.go
index 40a57d137..6de1177cd 100644
--- a/miner/worker_test.go
+++ b/miner/worker_test.go
@@ -133,7 +133,7 @@ func (b *testWorkerBackend) PostChainEvents(events []interface{}) {
func newTestWorker(t *testing.T, chainConfig *params.ChainConfig, engine consensus.Engine, blocks int) (*worker, *testWorkerBackend) {
backend := newTestWorkerBackend(t, chainConfig, engine, blocks)
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
}