aboutsummaryrefslogtreecommitdiff
path: root/miner
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2019-09-25 18:42:09 -0400
committerDeterminant <[email protected]>2019-09-25 18:42:09 -0400
commit35d55fc2bf9e8892a1174fc38b0dbba4af719044 (patch)
tree7e4db42c43884a542872c1ac2e5d014d9a71034f /miner
parent1a3b464bafdb2097e3305bf4f44746cf2f5a98c8 (diff)
allow disabling uncles
Diffstat (limited to 'miner')
-rw-r--r--miner/miner.go1
-rw-r--r--miner/worker.go11
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