From 919fd902c547ec6b25a8527f1b3d8db7d40af8df Mon Sep 17 00:00:00 2001 From: Luke Williams Date: Tue, 28 Jun 2016 15:41:22 +1000 Subject: [PATCH] Add poll interval flag --- cmd/geth/main.go | 1 + cmd/utils/flags.go | 7 +++++++ eth/backend.go | 6 ++++++ miner/miner.go | 2 +- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 65338be8a3..94f0b5a5f2 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -234,6 +234,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso utils.GpobaseCorrectionFactorFlag, utils.ExtraDataFlag, utils.FixedDifficultyFlag, + utils.PollIntervalFlag, utils.MinerPassphraseFlag, } app.Flags = append(app.Flags, debug.Flags...) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 4b14b113ef..43e0fc5054 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -397,6 +397,11 @@ var ( Usage: "Specify a fixed difficulty.", Value: -1, } + PollIntervalFlag = cli.IntFlag{ + Name: "interval", + Usage: "Miner polling interval in milliseconds.", + Value: 200, + } MinerPassphraseFlag = cli.StringFlag{ Name: "minerpass", Usage: "Passphrase used to unlock key for signing blocks.", @@ -723,6 +728,8 @@ func MakeSystemNode(name, version string, relconf release.Config, extra []byte, SolcPath: ctx.GlobalString(SolcPathFlag.Name), AutoDAG: ctx.GlobalBool(AutoDAGFlag.Name) || ctx.GlobalBool(MiningEnabledFlag.Name), MinerPassphrase: ctx.GlobalString(MinerPassphraseFlag.Name), + FixedDifficulty: ctx.GlobalInt(FixedDifficultyFlag.Name), + PollInterval: ctx.GlobalInt(PollIntervalFlag.Name), } // Configure the Whisper service shhEnable := ctx.GlobalBool(WhisperEnabledFlag.Name) diff --git a/eth/backend.go b/eth/backend.go index 6a8c6fd24b..c312a1cd79 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -102,6 +102,7 @@ type Config struct { TestGenesisState ethdb.Database // Genesis state to seed the database with (testing only!) FixedDifficulty int + PollInterval int MinerPassphrase string } @@ -147,6 +148,7 @@ type Ethereum struct { netRPCService *PublicNetAPI fixedDifficulty int + pollInterval int minerPassphrase string } @@ -224,6 +226,8 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { GpobaseStepUp: config.GpobaseStepUp, GpobaseCorrectionFactor: config.GpobaseCorrectionFactor, httpclient: httpclient.New(config.DocRoot), + fixedDifficulty: config.FixedDifficulty, + pollInterval: config.PollInterval, minerPassphrase: config.MinerPassphrase, } switch { @@ -389,6 +393,8 @@ func (s *Ethereum) StopMining() { s.miner.Stop() } func (s *Ethereum) IsMining() bool { return s.miner.Mining() } func (s *Ethereum) Miner() *miner.Miner { return s.miner } func (s *Ethereum) MinerPassphrase() string { return s.minerPassphrase } +func (s *Ethereum) FixedDifficulty() int { return s.fixedDifficulty } +func (s *Ethereum) PollInterval() int { return s.pollInterval } func (s *Ethereum) AccountManager() *accounts.Manager { return s.accountManager } func (s *Ethereum) BlockChain() *core.BlockChain { return s.blockchain } diff --git a/miner/miner.go b/miner/miner.go index 58f3623e0f..de03f6f31c 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -140,7 +140,7 @@ func (self *Miner) runLoop() { self.Start(self.coinbase, self.threads) } } - time.Sleep(3000 * time.Millisecond) + time.Sleep(self.eth.PollInterval() * time.Millisecond) } }