mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
fix import cycle
This commit is contained in:
parent
a546ae74bd
commit
0ae49c74fa
4 changed files with 33 additions and 40 deletions
|
|
@ -29,8 +29,8 @@ import (
|
|||
"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/consensus/clique"
|
||||
"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"
|
||||
|
|
@ -316,42 +316,39 @@ func startNode(ctx *cli.Context, stack *node.Node) {
|
|||
started = true
|
||||
log.Info("Enabled mining node!!!")
|
||||
}
|
||||
defer close(clique.Checkpoint)
|
||||
defer close(core.Checkpoint)
|
||||
|
||||
for {
|
||||
select {
|
||||
case _ = <-clique.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)
|
||||
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!!!")
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@ var (
|
|||
|
||||
diffInTurn = big.NewInt(2) // Block difficulty for in-turn signatures
|
||||
diffNoTurn = big.NewInt(1) // Block difficulty for out-of-turn signatures
|
||||
Checkpoint chan int
|
||||
)
|
||||
|
||||
// Various error messages to mark blocks invalid. These should be private to
|
||||
|
|
@ -217,7 +216,6 @@ func New(config *params.CliqueConfig, db ethdb.Database) *Clique {
|
|||
if conf.Epoch == 0 {
|
||||
conf.Epoch = epochLength
|
||||
}
|
||||
Checkpoint = make(chan int)
|
||||
// Allocate the snapshot caches and create the engine
|
||||
recents, _ := lru.NewARC(inmemorySnapshots)
|
||||
signatures, _ := lru.NewARC(inmemorySignatures)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import (
|
|||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/mclock"
|
||||
"github.com/ethereum/go-ethereum/consensus"
|
||||
"github.com/ethereum/go-ethereum/consensus/clique"
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
|
|
@ -48,8 +47,8 @@ import (
|
|||
|
||||
var (
|
||||
blockInsertTimer = metrics.NewRegisteredTimer("chain/inserts", nil)
|
||||
|
||||
ErrNoGenesis = errors.New("Genesis not found in chain")
|
||||
Checkpoint = make(chan int)
|
||||
ErrNoGenesis = errors.New("Genesis not found in chain")
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -1188,7 +1187,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks) (int, []interface{}, []*ty
|
|||
stats.report(chain, i, bc.stateCache.TrieDB().Size())
|
||||
if i == len(chain)-1 {
|
||||
if (chain[i].NumberU64() % bc.chainConfig.Clique.Epoch) == 0 {
|
||||
clique.Checkpoint <- 1
|
||||
Checkpoint <- 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import (
|
|||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/consensus"
|
||||
"github.com/ethereum/go-ethereum/consensus/clique"
|
||||
"github.com/ethereum/go-ethereum/consensus/misc"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
|
|
@ -491,7 +490,7 @@ func (self *worker) commitNewWork() {
|
|||
}
|
||||
if (work.Block.NumberU64() % work.config.Clique.Epoch) == 0 {
|
||||
log.Info("hey checkpoint")
|
||||
clique.Checkpoint <- 1
|
||||
core.Checkpoint <- 1
|
||||
}
|
||||
self.push(work)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue