aboutsummaryrefslogtreecommitdiffstats
path: root/eth/backend.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-03-14 01:34:43 +0800
committerFelix Lange <fjl@twurst.com>2015-03-14 01:41:09 +0800
commite463479b6c7770e783a47aedcd07b02d3ee250b6 (patch)
tree0f83cc490715bb1f07c35c1ebed15a5e4fad276c /eth/backend.go
parent6f8a2d6b84f0ef3f783fa86bbb97c357ab0cb0c2 (diff)
downloadgo-tangerine-e463479b6c7770e783a47aedcd07b02d3ee250b6.tar
go-tangerine-e463479b6c7770e783a47aedcd07b02d3ee250b6.tar.gz
go-tangerine-e463479b6c7770e783a47aedcd07b02d3ee250b6.tar.bz2
go-tangerine-e463479b6c7770e783a47aedcd07b02d3ee250b6.tar.lz
go-tangerine-e463479b6c7770e783a47aedcd07b02d3ee250b6.tar.xz
go-tangerine-e463479b6c7770e783a47aedcd07b02d3ee250b6.tar.zst
go-tangerine-e463479b6c7770e783a47aedcd07b02d3ee250b6.zip
eth: add ResetWithGenesisBlock
This depends on a change in ethash which exposes UpdateCache.
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 {