staking not mining

This commit is contained in:
AnilChinchawale 2018-10-21 16:42:10 +05:30
parent 264a6dc9db
commit 77ac77cdb1
5 changed files with 25 additions and 25 deletions

View file

@ -99,8 +99,8 @@ var (
utils.MaxPendingPeersFlag,
utils.EtherbaseFlag,
utils.GasPriceFlag,
utils.MinerThreadsFlag,
utils.MiningEnabledFlag,
utils.StakerThreadsFlag,
utils.StakingEnabledFlag,
utils.TargetGasLimitFlag,
utils.NATFlag,
utils.NoDiscoverFlag,
@ -283,10 +283,10 @@ func startNode(ctx *cli.Context, stack *node.Node) {
}
}()
// Start auxiliary services if enabled
if ctx.GlobalBool(utils.MiningEnabledFlag.Name) || ctx.GlobalBool(utils.DeveloperFlag.Name) {
if ctx.GlobalBool(utils.StakingEnabledFlag.Name) || ctx.GlobalBool(utils.DeveloperFlag.Name) {
// Mining only makes sense if a full Ethereum node is running
if ctx.GlobalBool(utils.LightModeFlag.Name) || ctx.GlobalString(utils.SyncModeFlag.Name) == "light" {
utils.Fatalf("Light clients do not support mining")
utils.Fatalf("Light clients do not support staking")
}
var ethereum *eth.Ethereum
if err := stack.Service(&ethereum); err != nil {
@ -299,9 +299,9 @@ func startNode(ctx *cli.Context, stack *node.Node) {
utils.Fatalf("Can't verify validator permission: %v", err)
}
if ok {
log.Info("Validator found. Enabling mining mode...")
log.Info("Validator found. Enabling staking mode...")
// Use a reduced number of threads if requested
if threads := ctx.GlobalInt(utils.MinerThreadsFlag.Name); threads > 0 {
if threads := ctx.GlobalInt(utils.StakerThreadsFlag.Name); threads > 0 {
type threaded interface {
SetThreads(threads int)
}
@ -315,7 +315,7 @@ func startNode(ctx *cli.Context, stack *node.Node) {
utils.Fatalf("Failed to start staking: %v", err)
}
started = true
log.Info("Enabled mining node!!!")
log.Info("Enabled staking node!!!")
}
defer close(core.CheckpointCh)
defer close(core.M1Ch)
@ -329,15 +329,15 @@ func startNode(ctx *cli.Context, stack *node.Node) {
}
if !ok {
if started {
log.Info("Only masternode can propose and verify blocks. Cancelling mining on this node...")
ethereum.StopMining()
log.Info("Only masternode can propose and verify blocks. Cancelling staking on this node...")
ethereum.StopStaking()
started = false
log.Info("Cancelled mining mode!!!")
}
} else if !started {
log.Info("Masternode found. Enabling mining mode...")
log.Info("Masternode found. Enabling staking mode...")
// Use a reduced number of threads if requested
if threads := ctx.GlobalInt(utils.MinerThreadsFlag.Name); threads > 0 {
if threads := ctx.GlobalInt(utils.StakerThreadsFlag.Name); threads > 0 {
type threaded interface {
SetThreads(threads int)
}
@ -348,10 +348,10 @@ func startNode(ctx *cli.Context, stack *node.Node) {
// Set the gas price to the limits from the CLI and start mining
ethereum.TxPool().SetGasPrice(utils.GlobalBig(ctx, utils.GasPriceFlag.Name))
if err := ethereum.StartStaking(true); err != nil {
utils.Fatalf("Failed to start mining: %v", err)
utils.Fatalf("Failed to start staking: %v", err)
}
started = true
log.Info("Enabled mining node!!!")
log.Info("Enabled staking node!!!")
}
case <-core.M1Ch:
log.Info("It's time to update new set of masternodes for the next epoch...")

View file

@ -182,8 +182,8 @@ var AppHelpFlagGroups = []flagGroup{
{
Name: "MINER",
Flags: []cli.Flag{
utils.MiningEnabledFlag,
utils.MinerThreadsFlag,
utils.StakingEnabledFlag,
utils.StakerThreadsFlag,
utils.EtherbaseFlag,
utils.TargetGasLimitFlag,
utils.GasPriceFlag,

View file

@ -311,13 +311,13 @@ var (
Value: int(state.MaxTrieCacheGen),
}
// Miner settings
MiningEnabledFlag = cli.BoolFlag{
StakingEnabledFlag = cli.BoolFlag{
Name: "mine",
Usage: "Enable mining",
Usage: "Enable staking",
}
MinerThreadsFlag = cli.IntFlag{
StakerThreadsFlag = cli.IntFlag{
Name: "minerthreads",
Usage: "Number of CPU threads to use for mining",
Usage: "Number of CPU threads to use for staking",
Value: runtime.NumCPU(),
}
TargetGasLimitFlag = cli.Uint64Flag{

View file

@ -81,7 +81,7 @@ func NewPublicMinerAPI(e *Ethereum) *PublicMinerAPI {
// Mining returns an indication if this node is currently mining.
func (api *PublicMinerAPI) Mining() bool {
return api.e.IsMining()
return api.e.IsStaking()
}
// SubmitWork can be used by external miner to submit their POW solution. It returns an indication if the work was
@ -95,7 +95,7 @@ func (api *PublicMinerAPI) SubmitWork(nonce types.BlockNonce, solution, digest c
// result[1], 32 bytes hex encoded seed hash used for DAG
// result[2], 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty
func (api *PublicMinerAPI) GetWork() ([3]string, error) {
if !api.e.IsMining() {
if !api.e.IsStaking() {
if err := api.e.StartStaking(false); err != nil {
return [3]string{}, err
}
@ -145,7 +145,7 @@ func (api *PrivateMinerAPI) Start(threads *int) error {
th.SetThreads(*threads)
}
// Start the miner and return
if !api.e.IsMining() {
if !api.e.IsStaking() {
// Propagate the initial price point to the transaction pool
api.e.lock.RLock()
price := api.e.gasPrice
@ -165,7 +165,7 @@ func (api *PrivateMinerAPI) Stop() bool {
if th, ok := api.e.engine.(threaded); ok {
th.SetThreads(-1)
}
api.e.StopMining()
api.e.StopStaking()
return true
}

View file

@ -471,8 +471,8 @@ func (s *Ethereum) StartStaking(local bool) error {
return nil
}
func (s *Ethereum) StopMining() { s.miner.Stop() }
func (s *Ethereum) IsMining() bool { return s.miner.Mining() }
func (s *Ethereum) StopStaking() { s.miner.Stop() }
func (s *Ethereum) IsStaking() bool { return s.miner.Mining() }
func (s *Ethereum) Miner() *miner.Miner { return s.miner }
func (s *Ethereum) AccountManager() *accounts.Manager { return s.accountManager }