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