diff options
-rw-r--r-- | miner/miner.go | 1 | ||||
-rw-r--r-- | miner/worker.go | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/miner/miner.go b/miner/miner.go index 1f1baa8..60a5d39 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -50,6 +50,7 @@ type Config struct { Noverify bool // Disable remote mining solution verification(only useful in ethash). ManualMining bool ManualUncle bool + DisableUncle bool } type Miner struct { diff --git a/miner/worker.go b/miner/worker.go index 1aeb9bd..8dd2aff 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -184,6 +184,7 @@ type worker struct { resubmitHook func(time.Duration, time.Duration) // Method to call upon updating resubmitting interval. manualMining bool manualUncle bool + disableUncle bool minerCallbacks *MinerCallbacks } @@ -212,8 +213,12 @@ func newWorker(config *Config, chainConfig *params.ChainConfig, engine consensus resubmitAdjustCh: make(chan *intervalAdjust, resubmitAdjustChanSize), manualMining: config.ManualMining, manualUncle: config.ManualUncle, + disableUncle: config.DisableUncle, minerCallbacks: mcb, } + if worker.disableUncle { + worker.manualUncle = true + } // Subscribe NewTxsEvent for tx pool worker.txsSub = eth.TxPool().SubscribeNewTxsEvent(worker.txsCh) // Subscribe events for blockchain @@ -689,6 +694,9 @@ func (w *worker) makeCurrent(parent *types.Block, header *types.Header) error { // commitUncle adds the given block to uncle block set, returns error if failed to add. func (w *worker) commitUncle(env *environment, uncle *types.Header) error { + if w.disableUncle { + return nil + } hash := uncle.Hash() if env.uncles.Contains(hash) { return errors.New("uncle not unique") @@ -937,6 +945,9 @@ func (w *worker) commitNewWork(interrupt *int32, noempty bool, timestamp int64) delete(blocks, hash) } } + if w.disableUncle { + return + } for hash, uncle := range blocks { if len(uncles) == 2 { break |