mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-22 14:44:30 +00:00
FIX-IMPORT-CYCLE
This commit is contained in:
parent
5f79d00d04
commit
38975a48d4
1 changed files with 32 additions and 32 deletions
|
|
@ -28,8 +28,9 @@ import (
|
|||
"github.com/ethereum/go-ethereum/accounts"
|
||||
"github.com/ethereum/go-ethereum/accounts/keystore"
|
||||
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/console"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/eth"
|
||||
"github.com/ethereum/go-ethereum/ethclient"
|
||||
"github.com/ethereum/go-ethereum/internal/debug"
|
||||
|
|
@ -46,7 +47,8 @@ const (
|
|||
var (
|
||||
// Git SHA1 commit hash of the release (set via linker flags)
|
||||
gitCommit = ""
|
||||
|
||||
// Ethereum address of the Geth release oracle.
|
||||
relOracle = common.HexToAddress("0xfa7b9770ca4cb04296cac84f37736d4041251cdf")
|
||||
// The app that holds all commands and flags.
|
||||
app = utils.NewApp(gitCommit, "the go-ethereum command line interface")
|
||||
// flags that configure the node
|
||||
|
|
@ -289,7 +291,6 @@ func startNode(ctx *cli.Context, stack *node.Node) {
|
|||
if err := stack.Service(ðereum); err != nil {
|
||||
utils.Fatalf("Ethereum service not running: %v", err)
|
||||
}
|
||||
|
||||
go func() {
|
||||
started := false
|
||||
ok, err := ethereum.ValidateMiner()
|
||||
|
|
@ -315,40 +316,39 @@ func startNode(ctx *cli.Context, stack *node.Node) {
|
|||
started = true
|
||||
log.Info("Enabled mining node!!!")
|
||||
}
|
||||
defer close(core.Checkpoint)
|
||||
|
||||
for {
|
||||
if ethereum.Checkpoint() {
|
||||
//Checkpoint!!! It's time to reconcile node's state...
|
||||
ok, err := ethereum.ValidateMiner()
|
||||
if err != nil {
|
||||
utils.Fatalf("Can't verify validator permission: %v", err)
|
||||
for range core.Checkpoint {
|
||||
log.Info("Checkpoint!!! It's time to reconcile node's state...")
|
||||
ok, err := ethereum.ValidateMiner()
|
||||
if err != nil {
|
||||
utils.Fatalf("Can't verify validator permission: %v", err)
|
||||
}
|
||||
if !ok {
|
||||
log.Info("Only validator can mine blocks. Cancelling mining on this node...")
|
||||
if started {
|
||||
ethereum.StopMining()
|
||||
started = false
|
||||
}
|
||||
if !ok {
|
||||
log.Info("Only validator can mine blocks. Cancelling mining on this node...")
|
||||
if started {
|
||||
ethereum.StopMining()
|
||||
started = false
|
||||
log.Info("Cancelled mining mode!!!")
|
||||
} else if !started {
|
||||
log.Info("Validator found. Enabling mining mode...")
|
||||
// Use a reduced number of threads if requested
|
||||
if threads := ctx.GlobalInt(utils.MinerThreadsFlag.Name); threads > 0 {
|
||||
type threaded interface {
|
||||
SetThreads(threads int)
|
||||
}
|
||||
log.Info("Cancelled mining mode!!!")
|
||||
} else if !started {
|
||||
log.Info("Validator found. Enabling mining mode...")
|
||||
// Use a reduced number of threads if requested
|
||||
if threads := ctx.GlobalInt(utils.MinerThreadsFlag.Name); threads > 0 {
|
||||
type threaded interface {
|
||||
SetThreads(threads int)
|
||||
}
|
||||
if th, ok := ethereum.Engine().(threaded); ok {
|
||||
th.SetThreads(threads)
|
||||
}
|
||||
if th, ok := ethereum.Engine().(threaded); ok {
|
||||
th.SetThreads(threads)
|
||||
}
|
||||
// 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.StartMining(true); err != nil {
|
||||
utils.Fatalf("Failed to start mining: %v", err)
|
||||
}
|
||||
started = true
|
||||
log.Info("Enabled mining 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.StartMining(true); err != nil {
|
||||
utils.Fatalf("Failed to start mining: %v", err)
|
||||
}
|
||||
started = true
|
||||
log.Info("Enabled mining node!!!")
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
|
|
|||
Loading…
Reference in a new issue