mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
cmd, miner: add noempty-precommit flag
This commit is contained in:
parent
671f22be38
commit
44ac243dc2
5 changed files with 26 additions and 10 deletions
|
|
@ -129,6 +129,7 @@ var (
|
||||||
utils.MinerLegacyExtraDataFlag,
|
utils.MinerLegacyExtraDataFlag,
|
||||||
utils.MinerRecommitIntervalFlag,
|
utils.MinerRecommitIntervalFlag,
|
||||||
utils.MinerNoVerfiyFlag,
|
utils.MinerNoVerfiyFlag,
|
||||||
|
utils.MinerNoEmptyPrecommitFlag,
|
||||||
utils.NATFlag,
|
utils.NATFlag,
|
||||||
utils.NoDiscoverFlag,
|
utils.NoDiscoverFlag,
|
||||||
utils.DiscoveryV5Flag,
|
utils.DiscoveryV5Flag,
|
||||||
|
|
|
||||||
|
|
@ -210,6 +210,7 @@ var AppHelpFlagGroups = []flagGroup{
|
||||||
utils.MinerExtraDataFlag,
|
utils.MinerExtraDataFlag,
|
||||||
utils.MinerRecommitIntervalFlag,
|
utils.MinerRecommitIntervalFlag,
|
||||||
utils.MinerNoVerfiyFlag,
|
utils.MinerNoVerfiyFlag,
|
||||||
|
utils.MinerNoEmptyPrecommitFlag,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -483,6 +483,10 @@ var (
|
||||||
Name: "miner.noverify",
|
Name: "miner.noverify",
|
||||||
Usage: "Disable remote sealing verification",
|
Usage: "Disable remote sealing verification",
|
||||||
}
|
}
|
||||||
|
MinerNoEmptyPrecommitFlag = cli.BoolFlag{
|
||||||
|
Name: "miner.noempty-precommit",
|
||||||
|
Usage: "Disable empty mining solution precommit",
|
||||||
|
}
|
||||||
// Account settings
|
// Account settings
|
||||||
UnlockedAccountFlag = cli.StringFlag{
|
UnlockedAccountFlag = cli.StringFlag{
|
||||||
Name: "unlock",
|
Name: "unlock",
|
||||||
|
|
@ -1359,6 +1363,9 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) {
|
||||||
if ctx.GlobalIsSet(MinerNoVerfiyFlag.Name) {
|
if ctx.GlobalIsSet(MinerNoVerfiyFlag.Name) {
|
||||||
cfg.Noverify = ctx.Bool(MinerNoVerfiyFlag.Name)
|
cfg.Noverify = ctx.Bool(MinerNoVerfiyFlag.Name)
|
||||||
}
|
}
|
||||||
|
if ctx.GlobalIsSet(MinerNoEmptyPrecommitFlag.Name) {
|
||||||
|
cfg.NoEmptyPrecommit = ctx.Bool(MinerNoEmptyPrecommitFlag.Name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setWhitelist(ctx *cli.Context, cfg *eth.Config) {
|
func setWhitelist(ctx *cli.Context, cfg *eth.Config) {
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ type Config struct {
|
||||||
GasPrice *big.Int // Minimum gas price for mining a transaction
|
GasPrice *big.Int // Minimum gas price for mining a transaction
|
||||||
Recommit time.Duration // The time interval for miner to re-create mining work.
|
Recommit time.Duration // The time interval for miner to re-create mining work.
|
||||||
Noverify bool // Disable remote mining solution verification(only useful in ethash).
|
Noverify bool // Disable remote mining solution verification(only useful in ethash).
|
||||||
|
NoEmptyPrecommit bool // Disable pre-commit empty mining solution
|
||||||
}
|
}
|
||||||
|
|
||||||
// Miner creates blocks and searches for proof-of-work values.
|
// Miner creates blocks and searches for proof-of-work values.
|
||||||
|
|
|
||||||
|
|
@ -305,6 +305,10 @@ func (w *worker) newWorkLoop(recommit time.Duration) {
|
||||||
if interrupt != nil {
|
if interrupt != nil {
|
||||||
atomic.StoreInt32(interrupt, s)
|
atomic.StoreInt32(interrupt, s)
|
||||||
}
|
}
|
||||||
|
// Disable empty mining solution precommit if required.
|
||||||
|
if !noempty && w.config.NoEmptyPrecommit {
|
||||||
|
noempty = true
|
||||||
|
}
|
||||||
interrupt = new(int32)
|
interrupt = new(int32)
|
||||||
w.newWorkCh <- &newWorkReq{interrupt: interrupt, noempty: noempty, timestamp: timestamp}
|
w.newWorkCh <- &newWorkReq{interrupt: interrupt, noempty: noempty, timestamp: timestamp}
|
||||||
timer.Reset(recommit)
|
timer.Reset(recommit)
|
||||||
|
|
@ -922,8 +926,10 @@ func (w *worker) commitNewWork(interrupt *int32, noempty bool, timestamp int64)
|
||||||
log.Error("Failed to fetch pending transactions", "err", err)
|
log.Error("Failed to fetch pending transactions", "err", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Short circuit if there is no available pending transactions
|
// Short circuit if there is no available pending transactions.
|
||||||
if len(pending) == 0 {
|
// But if we disable empty precommit already, ignore it. Since
|
||||||
|
// empty block is necessary to keep the liveness of the network.
|
||||||
|
if len(pending) == 0 && !w.config.NoEmptyPrecommit {
|
||||||
w.updateSnapshot()
|
w.updateSnapshot()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue