fix import cycle

This commit is contained in:
Tuna 2018-05-31 16:34:17 +07:00
parent a546ae74bd
commit 0ae49c74fa
4 changed files with 33 additions and 40 deletions

View file

@ -29,8 +29,8 @@ import (
"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/common"
"github.com/ethereum/go-ethereum/consensus/clique"
"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"
@ -316,11 +316,9 @@ func startNode(ctx *cli.Context, stack *node.Node) {
started = true started = true
log.Info("Enabled mining node!!!") log.Info("Enabled mining node!!!")
} }
defer close(clique.Checkpoint) defer close(core.Checkpoint)
for { for range core.Checkpoint {
select {
case _ = <-clique.Checkpoint:
log.Info("Checkpoint!!! It's time to reconcile node's state...") log.Info("Checkpoint!!! It's time to reconcile node's state...")
ok, err := ethereum.ValidateMiner() ok, err := ethereum.ValidateMiner()
if err != nil { if err != nil {
@ -353,7 +351,6 @@ func startNode(ctx *cli.Context, stack *node.Node) {
log.Info("Enabled mining node!!!") log.Info("Enabled mining node!!!")
} }
} }
}
}() }()
} }
} }

View file

@ -65,7 +65,6 @@ var (
diffInTurn = big.NewInt(2) // Block difficulty for in-turn signatures diffInTurn = big.NewInt(2) // Block difficulty for in-turn signatures
diffNoTurn = big.NewInt(1) // Block difficulty for out-of-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 // 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 { if conf.Epoch == 0 {
conf.Epoch = epochLength conf.Epoch = epochLength
} }
Checkpoint = make(chan int)
// Allocate the snapshot caches and create the engine // Allocate the snapshot caches and create the engine
recents, _ := lru.NewARC(inmemorySnapshots) recents, _ := lru.NewARC(inmemorySnapshots)
signatures, _ := lru.NewARC(inmemorySignatures) signatures, _ := lru.NewARC(inmemorySignatures)

View file

@ -30,7 +30,6 @@ import (
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/mclock" "github.com/ethereum/go-ethereum/common/mclock"
"github.com/ethereum/go-ethereum/consensus" "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/state"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/core/vm"
@ -48,7 +47,7 @@ import (
var ( var (
blockInsertTimer = metrics.NewRegisteredTimer("chain/inserts", nil) blockInsertTimer = metrics.NewRegisteredTimer("chain/inserts", nil)
Checkpoint = make(chan int)
ErrNoGenesis = errors.New("Genesis not found in chain") ErrNoGenesis = errors.New("Genesis not found in chain")
) )
@ -1188,7 +1187,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks) (int, []interface{}, []*ty
stats.report(chain, i, bc.stateCache.TrieDB().Size()) stats.report(chain, i, bc.stateCache.TrieDB().Size())
if i == len(chain)-1 { if i == len(chain)-1 {
if (chain[i].NumberU64() % bc.chainConfig.Clique.Epoch) == 0 { if (chain[i].NumberU64() % bc.chainConfig.Clique.Epoch) == 0 {
clique.Checkpoint <- 1 Checkpoint <- 1
} }
} }
} }

View file

@ -26,7 +26,6 @@ import (
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus" "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/consensus/misc"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/state"
@ -491,7 +490,7 @@ func (self *worker) commitNewWork() {
} }
if (work.Block.NumberU64() % work.config.Clique.Epoch) == 0 { if (work.Block.NumberU64() % work.config.Clique.Epoch) == 0 {
log.Info("hey checkpoint") log.Info("hey checkpoint")
clique.Checkpoint <- 1 core.Checkpoint <- 1
} }
self.push(work) self.push(work)
} }