Add poll interval flag

This commit is contained in:
Luke Williams 2016-06-28 15:41:22 +10:00
parent c6782a4284
commit 919fd902c5
4 changed files with 15 additions and 1 deletions

View file

@ -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...)

View file

@ -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)

View file

@ -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 }

View file

@ -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)
}
}