diff --git a/cmd/tomo/main.go b/cmd/tomo/main.go index 0d7d60991c..9a125d0485 100644 --- a/cmd/tomo/main.go +++ b/cmd/tomo/main.go @@ -120,7 +120,7 @@ var ( //utils.GpoPercentileFlag, //utils.ExtraDataFlag, configFileFlag, - utils.CommitTxWhenNotMiningFlag, + utils.AnnounceTxsFlag, } rpcFlags = []cli.Flag{ diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 082c6a7e54..f158819e42 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -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) } } diff --git a/consensus/posv/posv.go b/consensus/posv/posv.go index 341d20af00..7b8e36e941 100644 --- a/consensus/posv/posv.go +++ b/consensus/posv/posv.go @@ -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 { diff --git a/eth/backend.go b/eth/backend.go index 0cb6fe601b..ed11a8cae7 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -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} diff --git a/miner/miner.go b/miner/miner.go index 021099e6a3..4bfab42f65 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -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)) diff --git a/miner/worker.go b/miner/worker.go index 44c1cb51e9..2bdc132370 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -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 } diff --git a/node/config.go b/node/config.go index e828001406..cbc27317fa 100644 --- a/node/config.go +++ b/node/config.go @@ -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