mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +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.GpoPercentileFlag,
|
||||||
//utils.ExtraDataFlag,
|
//utils.ExtraDataFlag,
|
||||||
configFileFlag,
|
configFileFlag,
|
||||||
utils.CommitTxWhenNotMiningFlag,
|
utils.AnnounceTxsFlag,
|
||||||
}
|
}
|
||||||
|
|
||||||
rpcFlags = []cli.Flag{
|
rpcFlags = []cli.Flag{
|
||||||
|
|
|
||||||
|
|
@ -113,10 +113,9 @@ func NewApp(gitCommit, usage string) *cli.App {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// General settings
|
// General settings
|
||||||
CommitTxWhenNotMiningFlag = DirectoryFlag{
|
AnnounceTxsFlag = cli.BoolFlag{
|
||||||
Name: "committxwhennotmining",
|
Name: "announce-txs",
|
||||||
Usage: "Always commit transactions",
|
Usage: "Always commit transactions",
|
||||||
Value: DirectoryString{node.DefaultDataDir()},
|
|
||||||
}
|
}
|
||||||
DataDirFlag = DirectoryFlag{
|
DataDirFlag = DirectoryFlag{
|
||||||
Name: "datadir",
|
Name: "datadir",
|
||||||
|
|
@ -902,8 +901,8 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
|
||||||
if ctx.GlobalIsSet(NoUSBFlag.Name) {
|
if ctx.GlobalIsSet(NoUSBFlag.Name) {
|
||||||
cfg.NoUSB = ctx.GlobalBool(NoUSBFlag.Name)
|
cfg.NoUSB = ctx.GlobalBool(NoUSBFlag.Name)
|
||||||
}
|
}
|
||||||
if ctx.GlobalIsSet(CommitTxWhenNotMiningFlag.Name) {
|
if ctx.GlobalIsSet(AnnounceTxsFlag.Name) {
|
||||||
cfg.CommitTxWhenNotMining = ctx.GlobalBool(CommitTxWhenNotMiningFlag.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 {
|
if err != nil {
|
||||||
return err
|
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)
|
masternodes := c.GetMasternodes(chain, header)
|
||||||
mstring := []string{}
|
mstring := []string{}
|
||||||
for _, m := range masternodes {
|
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 {
|
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
|
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.miner.SetExtra(makeExtraData(config.ExtraData))
|
||||||
|
|
||||||
eth.ApiBackend = &EthApiBackend{eth, nil}
|
eth.ApiBackend = &EthApiBackend{eth, nil}
|
||||||
|
|
|
||||||
|
|
@ -57,12 +57,12 @@ type Miner struct {
|
||||||
shouldStart int32 // should start indicates whether we should start after sync
|
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{
|
miner := &Miner{
|
||||||
eth: eth,
|
eth: eth,
|
||||||
mux: mux,
|
mux: mux,
|
||||||
engine: engine,
|
engine: engine,
|
||||||
worker: newWorker(config, engine, common.Address{}, eth, mux, commitTxWhenNotMining),
|
worker: newWorker(config, engine, common.Address{}, eth, mux, announceTxs),
|
||||||
canStart: 1,
|
canStart: 1,
|
||||||
}
|
}
|
||||||
miner.Register(NewCpuAgent(eth.BlockChain(), engine))
|
miner.Register(NewCpuAgent(eth.BlockChain(), engine))
|
||||||
|
|
|
||||||
|
|
@ -132,30 +132,30 @@ type worker struct {
|
||||||
// atomic status counters
|
// atomic status counters
|
||||||
mining int32
|
mining int32
|
||||||
atWork int32
|
atWork int32
|
||||||
commitTxWhenNotMining bool
|
announceTxs bool
|
||||||
lastParentBlockCommit string
|
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{
|
worker := &worker{
|
||||||
config: config,
|
config: config,
|
||||||
engine: engine,
|
engine: engine,
|
||||||
eth: eth,
|
eth: eth,
|
||||||
mux: mux,
|
mux: mux,
|
||||||
txCh: make(chan core.TxPreEvent, txChanSize),
|
txCh: make(chan core.TxPreEvent, txChanSize),
|
||||||
chainHeadCh: make(chan core.ChainHeadEvent, chainHeadChanSize),
|
chainHeadCh: make(chan core.ChainHeadEvent, chainHeadChanSize),
|
||||||
chainSideCh: make(chan core.ChainSideEvent, chainSideChanSize),
|
chainSideCh: make(chan core.ChainSideEvent, chainSideChanSize),
|
||||||
chainDb: eth.ChainDb(),
|
chainDb: eth.ChainDb(),
|
||||||
recv: make(chan *Result, resultQueueSize),
|
recv: make(chan *Result, resultQueueSize),
|
||||||
chain: eth.BlockChain(),
|
chain: eth.BlockChain(),
|
||||||
proc: eth.BlockChain().Validator(),
|
proc: eth.BlockChain().Validator(),
|
||||||
possibleUncles: make(map[common.Hash]*types.Block),
|
possibleUncles: make(map[common.Hash]*types.Block),
|
||||||
coinbase: coinbase,
|
coinbase: coinbase,
|
||||||
agents: make(map[Agent]struct{}),
|
agents: make(map[Agent]struct{}),
|
||||||
unconfirmed: newUnconfirmedBlocks(eth.BlockChain(), miningLogAtDepth),
|
unconfirmed: newUnconfirmedBlocks(eth.BlockChain(), miningLogAtDepth),
|
||||||
commitTxWhenNotMining: commitTxWhenNotMining,
|
announceTxs: announceTxs,
|
||||||
}
|
}
|
||||||
if worker.commitTxWhenNotMining {
|
if worker.announceTxs {
|
||||||
// Subscribe TxPreEvent for tx pool
|
// Subscribe TxPreEvent for tx pool
|
||||||
worker.txSub = eth.TxPool().SubscribeTxPreEvent(worker.txCh)
|
worker.txSub = eth.TxPool().SubscribeTxPreEvent(worker.txCh)
|
||||||
}
|
}
|
||||||
|
|
@ -253,7 +253,7 @@ func (self *worker) unregister(agent Agent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *worker) update() {
|
func (self *worker) update() {
|
||||||
if self.commitTxWhenNotMining {
|
if self.announceTxs {
|
||||||
defer self.txSub.Unsubscribe()
|
defer self.txSub.Unsubscribe()
|
||||||
}
|
}
|
||||||
defer self.chainHeadSub.Unsubscribe()
|
defer self.chainHeadSub.Unsubscribe()
|
||||||
|
|
@ -486,7 +486,7 @@ func (self *worker) commitNewWork() {
|
||||||
if parent.Hash().Hex() == self.lastParentBlockCommit {
|
if parent.Hash().Hex() == self.lastParentBlockCommit {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !self.commitTxWhenNotMining && atomic.LoadInt32(&self.mining) == 0 {
|
if !self.announceTxs && atomic.LoadInt32(&self.mining) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ type Config struct {
|
||||||
// Logger is a custom logger to use with the p2p.Server.
|
// Logger is a custom logger to use with the p2p.Server.
|
||||||
Logger log.Logger `toml:",omitempty"`
|
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
|
// IPCEndpoint resolves an IPC endpoint based on a configured value, taking into
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue