mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
refactor name flag committxwhennotmining -> announce-txs
This commit is contained in:
parent
6af064ec32
commit
b2929f2b50
7 changed files with 31 additions and 32 deletions
|
|
@ -120,7 +120,7 @@ var (
|
|||
//utils.GpoPercentileFlag,
|
||||
//utils.ExtraDataFlag,
|
||||
configFileFlag,
|
||||
utils.CommitTxWhenNotMiningFlag,
|
||||
utils.AnnounceTxsFlag,
|
||||
}
|
||||
|
||||
rpcFlags = []cli.Flag{
|
||||
|
|
|
|||
|
|
@ -113,10 +113,9 @@ func NewApp(gitCommit, usage string) *cli.App {
|
|||
|
||||
var (
|
||||
// General settings
|
||||
CommitTxWhenNotMiningFlag = DirectoryFlag{
|
||||
Name: "committxwhennotmining",
|
||||
AnnounceTxsFlag = cli.BoolFlag{
|
||||
Name: "announce-txs",
|
||||
Usage: "Always commit transactions",
|
||||
Value: DirectoryString{node.DefaultDataDir()},
|
||||
}
|
||||
DataDirFlag = DirectoryFlag{
|
||||
Name: "datadir",
|
||||
|
|
@ -902,8 +901,8 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
|
|||
if ctx.GlobalIsSet(NoUSBFlag.Name) {
|
||||
cfg.NoUSB = ctx.GlobalBool(NoUSBFlag.Name)
|
||||
}
|
||||
if ctx.GlobalIsSet(CommitTxWhenNotMiningFlag.Name) {
|
||||
cfg.CommitTxWhenNotMining = ctx.GlobalBool(CommitTxWhenNotMiningFlag.Name)
|
||||
if ctx.GlobalIsSet(AnnounceTxsFlag.Name) {
|
||||
cfg.AnnounceTxs = ctx.GlobalBool(AnnounceTxsFlag.Name)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -630,7 +630,7 @@ func (c *Posv) verifySeal(chain consensus.ChainReader, header *types.Header, par
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Debug("verify seal block", "number", header.Number, "hash", header.Hash(), "difficulty", header.Difficulty)
|
||||
log.Debug("verify seal block", "number", header.Number, "hash", header.Hash(), "difficulty", header.Difficulty, "creator", creator)
|
||||
masternodes := c.GetMasternodes(chain, header)
|
||||
mstring := []string{}
|
||||
for _, m := range masternodes {
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
|||
if eth.protocolManager, err = NewProtocolManager(eth.chainConfig, config.SyncMode, config.NetworkId, eth.eventMux, eth.txPool, eth.engine, eth.blockchain, chainDb); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
eth.miner = miner.New(eth, eth.chainConfig, eth.EventMux(), eth.engine, ctx.GetConfig().CommitTxWhenNotMining)
|
||||
eth.miner = miner.New(eth, eth.chainConfig, eth.EventMux(), eth.engine, ctx.GetConfig().AnnounceTxs)
|
||||
eth.miner.SetExtra(makeExtraData(config.ExtraData))
|
||||
|
||||
eth.ApiBackend = &EthApiBackend{eth, nil}
|
||||
|
|
|
|||
|
|
@ -57,12 +57,12 @@ 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, commitTxWhenNotMining bool) *Miner {
|
||||
func New(eth Backend, config *params.ChainConfig, mux *event.TypeMux, engine consensus.Engine, announceTxs bool) *Miner {
|
||||
miner := &Miner{
|
||||
eth: eth,
|
||||
mux: mux,
|
||||
engine: engine,
|
||||
worker: newWorker(config, engine, common.Address{}, eth, mux, commitTxWhenNotMining),
|
||||
worker: newWorker(config, engine, common.Address{}, eth, mux, announceTxs),
|
||||
canStart: 1,
|
||||
}
|
||||
miner.Register(NewCpuAgent(eth.BlockChain(), engine))
|
||||
|
|
|
|||
|
|
@ -132,30 +132,30 @@ type worker struct {
|
|||
// atomic status counters
|
||||
mining int32
|
||||
atWork int32
|
||||
commitTxWhenNotMining bool
|
||||
announceTxs bool
|
||||
lastParentBlockCommit string
|
||||
}
|
||||
|
||||
func newWorker(config *params.ChainConfig, engine consensus.Engine, coinbase common.Address, eth Backend, mux *event.TypeMux, commitTxWhenNotMining bool) *worker {
|
||||
func newWorker(config *params.ChainConfig, engine consensus.Engine, coinbase common.Address, eth Backend, mux *event.TypeMux, announceTxs bool) *worker {
|
||||
worker := &worker{
|
||||
config: config,
|
||||
engine: engine,
|
||||
eth: eth,
|
||||
mux: mux,
|
||||
txCh: make(chan core.TxPreEvent, txChanSize),
|
||||
chainHeadCh: make(chan core.ChainHeadEvent, chainHeadChanSize),
|
||||
chainSideCh: make(chan core.ChainSideEvent, chainSideChanSize),
|
||||
chainDb: eth.ChainDb(),
|
||||
recv: make(chan *Result, resultQueueSize),
|
||||
chain: eth.BlockChain(),
|
||||
proc: eth.BlockChain().Validator(),
|
||||
possibleUncles: make(map[common.Hash]*types.Block),
|
||||
coinbase: coinbase,
|
||||
agents: make(map[Agent]struct{}),
|
||||
unconfirmed: newUnconfirmedBlocks(eth.BlockChain(), miningLogAtDepth),
|
||||
commitTxWhenNotMining: commitTxWhenNotMining,
|
||||
config: config,
|
||||
engine: engine,
|
||||
eth: eth,
|
||||
mux: mux,
|
||||
txCh: make(chan core.TxPreEvent, txChanSize),
|
||||
chainHeadCh: make(chan core.ChainHeadEvent, chainHeadChanSize),
|
||||
chainSideCh: make(chan core.ChainSideEvent, chainSideChanSize),
|
||||
chainDb: eth.ChainDb(),
|
||||
recv: make(chan *Result, resultQueueSize),
|
||||
chain: eth.BlockChain(),
|
||||
proc: eth.BlockChain().Validator(),
|
||||
possibleUncles: make(map[common.Hash]*types.Block),
|
||||
coinbase: coinbase,
|
||||
agents: make(map[Agent]struct{}),
|
||||
unconfirmed: newUnconfirmedBlocks(eth.BlockChain(), miningLogAtDepth),
|
||||
announceTxs: announceTxs,
|
||||
}
|
||||
if worker.commitTxWhenNotMining {
|
||||
if worker.announceTxs {
|
||||
// Subscribe TxPreEvent for tx pool
|
||||
worker.txSub = eth.TxPool().SubscribeTxPreEvent(worker.txCh)
|
||||
}
|
||||
|
|
@ -253,7 +253,7 @@ func (self *worker) unregister(agent Agent) {
|
|||
}
|
||||
|
||||
func (self *worker) update() {
|
||||
if self.commitTxWhenNotMining {
|
||||
if self.announceTxs {
|
||||
defer self.txSub.Unsubscribe()
|
||||
}
|
||||
defer self.chainHeadSub.Unsubscribe()
|
||||
|
|
@ -486,7 +486,7 @@ func (self *worker) commitNewWork() {
|
|||
if parent.Hash().Hex() == self.lastParentBlockCommit {
|
||||
return
|
||||
}
|
||||
if !self.commitTxWhenNotMining && atomic.LoadInt32(&self.mining) == 0 {
|
||||
if !self.announceTxs && atomic.LoadInt32(&self.mining) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ type Config struct {
|
|||
// Logger is a custom logger to use with the p2p.Server.
|
||||
Logger log.Logger `toml:",omitempty"`
|
||||
|
||||
CommitTxWhenNotMining bool `toml:",omitempty"`
|
||||
AnnounceTxs bool `toml:",omitempty"`
|
||||
}
|
||||
|
||||
// IPCEndpoint resolves an IPC endpoint based on a configured value, taking into
|
||||
|
|
|
|||
Loading…
Reference in a new issue