aboutsummaryrefslogtreecommitdiffstats
path: root/eth/backend.go
diff options
context:
space:
mode:
Diffstat (limited to 'eth/backend.go')
-rw-r--r--eth/backend.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/eth/backend.go b/eth/backend.go
index 2c7c7d792..7a30902c9 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -11,6 +11,7 @@ import (
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/blockpool"
"github.com/ethereum/go-ethereum/core"
+ "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethutil"
@@ -123,6 +124,7 @@ type Ethereum struct {
blockPool *blockpool.BlockPool
accountManager *accounts.Manager
whisper *whisper.Whisper
+ pow *ethash.Ethash
net *p2p.Server
eventMux *event.TypeMux
@@ -175,16 +177,16 @@ func New(config *Config) (*Ethereum, error) {
}
eth.chainManager = core.NewChainManager(blockDb, stateDb, eth.EventMux())
- pow := ethash.New(eth.chainManager)
+ eth.pow = ethash.New(eth.chainManager)
eth.txPool = core.NewTxPool(eth.EventMux())
- eth.blockProcessor = core.NewBlockProcessor(stateDb, pow, eth.txPool, eth.chainManager, eth.EventMux())
+ eth.blockProcessor = core.NewBlockProcessor(stateDb, eth.pow, eth.txPool, eth.chainManager, eth.EventMux())
eth.chainManager.SetProcessor(eth.blockProcessor)
eth.whisper = whisper.New()
- eth.miner = miner.New(eth, pow, config.MinerThreads)
+ eth.miner = miner.New(eth, eth.pow, config.MinerThreads)
hasBlock := eth.chainManager.HasBlock
insertChain := eth.chainManager.InsertChain
- eth.blockPool = blockpool.New(hasBlock, insertChain, pow.Verify)
+ eth.blockPool = blockpool.New(hasBlock, insertChain, eth.pow.Verify)
netprv, err := config.nodeKey()
if err != nil {
@@ -214,6 +216,11 @@ func New(config *Config) (*Ethereum, error) {
return eth, nil
}
+func (s *Ethereum) ResetWithGenesisBlock(gb *types.Block) {
+ s.chainManager.ResetWithGenesisBlock(gb)
+ s.pow.UpdateCache(true)
+}
+
func (s *Ethereum) StartMining() error {
cb, err := s.accountManager.Coinbase()
if err != nil {