mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
feat(worker): allow empty blocks (#1153)
This commit is contained in:
parent
e1e578d99d
commit
019e52cb0c
6 changed files with 14 additions and 1 deletions
|
|
@ -133,6 +133,7 @@ var (
|
|||
utils.MinerNoVerifyFlag,
|
||||
utils.MinerStoreSkippedTxTracesFlag,
|
||||
utils.MinerMaxAccountsNumFlag,
|
||||
utils.MinerAllowEmptyFlag,
|
||||
utils.NATFlag,
|
||||
utils.NoDiscoverFlag,
|
||||
utils.DiscoveryV5Flag,
|
||||
|
|
|
|||
|
|
@ -197,6 +197,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
|
|||
utils.MinerNoVerifyFlag,
|
||||
utils.MinerStoreSkippedTxTracesFlag,
|
||||
utils.MinerMaxAccountsNumFlag,
|
||||
utils.MinerAllowEmptyFlag,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -515,6 +515,10 @@ var (
|
|||
Usage: "Maximum number of accounts that miner will fetch the pending transactions of when building a new block",
|
||||
Value: math.MaxInt,
|
||||
}
|
||||
MinerAllowEmptyFlag = cli.BoolFlag{
|
||||
Name: "miner.allowempty",
|
||||
Usage: "Allow sealing empty blocks",
|
||||
}
|
||||
// Account settings
|
||||
UnlockedAccountFlag = cli.StringFlag{
|
||||
Name: "unlock",
|
||||
|
|
@ -1620,6 +1624,9 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) {
|
|||
if ctx.GlobalIsSet(MinerMaxAccountsNumFlag.Name) {
|
||||
cfg.MaxAccountsNum = ctx.GlobalInt(MinerMaxAccountsNumFlag.Name)
|
||||
}
|
||||
if ctx.GlobalIsSet(MinerAllowEmptyFlag.Name) {
|
||||
cfg.AllowEmpty = ctx.GlobalBool(MinerAllowEmptyFlag.Name)
|
||||
}
|
||||
if ctx.GlobalIsSet(LegacyMinerGasTargetFlag.Name) {
|
||||
log.Warn("The generic --miner.gastarget flag is deprecated and will be removed in the future!")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ type Config struct {
|
|||
StoreSkippedTxTraces bool // Whether store the wrapped traces when storing a skipped tx
|
||||
MaxAccountsNum int // Maximum number of accounts that miner will fetch the pending transactions of when building a new block
|
||||
CCCMaxWorkers int // Maximum number of workers to use for async CCC tasks
|
||||
AllowEmpty bool // If true, then we allow sealing empty blocks
|
||||
|
||||
SigningDisabled bool // Whether to disable signing blocks with consensus enginek
|
||||
}
|
||||
|
|
|
|||
|
|
@ -400,6 +400,9 @@ func (w *worker) mainLoop() {
|
|||
w.current.deadlineReached = true
|
||||
if len(w.current.txs) > 0 {
|
||||
_, err = w.commit()
|
||||
} else if w.config.AllowEmpty {
|
||||
log.Warn("Committing empty block", "number", w.current.header.Number)
|
||||
_, err = w.commit()
|
||||
}
|
||||
case ev := <-w.txsCh:
|
||||
idleTimer.UpdateSince(idleStart)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import (
|
|||
const (
|
||||
VersionMajor = 5 // Major version component of the current release
|
||||
VersionMinor = 8 // Minor version component of the current release
|
||||
VersionPatch = 28 // Patch version component of the current release
|
||||
VersionPatch = 29 // Patch version component of the current release
|
||||
VersionMeta = "mainnet" // Version metadata to append to the version string
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue