aboutsummaryrefslogtreecommitdiffstats
path: root/eth
diff options
context:
space:
mode:
Diffstat (limited to 'eth')
-rw-r--r--eth/backend.go55
1 files changed, 18 insertions, 37 deletions
diff --git a/eth/backend.go b/eth/backend.go
index 584d60c7e..8417b572b 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -8,6 +8,7 @@ import (
"strings"
"github.com/ethereum/ethash"
+ "github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/blockpool"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/crypto"
@@ -19,7 +20,6 @@ import (
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/nat"
- "github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/vm"
"github.com/ethereum/go-ethereum/whisper"
)
@@ -38,11 +38,9 @@ var (
type Config struct {
Name string
- KeyStore string
DataDir string
LogFile string
LogLevel int
- KeyRing string
LogFormat string
VmDebug bool
@@ -61,9 +59,8 @@ type Config struct {
Shh bool
Dial bool
- MinerThreads int
-
- KeyManager *crypto.KeyManager
+ MinerThreads int
+ AccountManager *accounts.Manager
}
func (cfg *Config) parseBootNodes() []*discover.Node {
@@ -120,6 +117,7 @@ type Ethereum struct {
txPool *core.TxPool
chainManager *core.ChainManager
blockPool *blockpool.BlockPool
+ accountManager *accounts.Manager
whisper *whisper.Whisper
net *p2p.Server
@@ -128,9 +126,6 @@ type Ethereum struct {
blockSub event.Subscription
miner *miner.Miner
- RpcServer rpc.RpcServer
- keyManager *crypto.KeyManager
-
logger logger.LogSystem
Mining bool
@@ -158,40 +153,31 @@ func New(config *Config) (*Ethereum, error) {
return nil, fmt.Errorf("Database version mismatch. Protocol(%d / %d). `rm -rf %s`", protov, ProtocolVersion, path)
}
- // Create new keymanager
- var keyManager *crypto.KeyManager
- switch config.KeyStore {
- case "db":
- keyManager = crypto.NewDBKeyManager(blockDb)
- case "file":
- keyManager = crypto.NewFileKeyManager(config.DataDir)
- default:
- return nil, fmt.Errorf("unknown keystore type: %s", config.KeyStore)
- }
- // Initialise the keyring
- keyManager.Init(config.KeyRing, 0, false)
-
saveProtocolVersion(blockDb)
//ethutil.Config.Db = db
eth := &Ethereum{
- shutdownChan: make(chan bool),
- blockDb: blockDb,
- stateDb: stateDb,
- keyManager: keyManager,
- eventMux: &event.TypeMux{},
- logger: ethlogger,
- DataDir: config.DataDir,
+ shutdownChan: make(chan bool),
+ blockDb: blockDb,
+ stateDb: stateDb,
+ eventMux: &event.TypeMux{},
+ logger: ethlogger,
+ accountManager: config.AccountManager,
+ DataDir: config.DataDir,
+ }
+
+ cb, err := eth.accountManager.Coinbase()
+ if err != nil {
+ return nil, fmt.Errorf("no coinbase: %v", err)
}
eth.chainManager = core.NewChainManager(blockDb, stateDb, eth.EventMux())
pow := ethash.New(eth.chainManager)
-
eth.txPool = core.NewTxPool(eth.EventMux())
eth.blockProcessor = core.NewBlockProcessor(stateDb, pow, eth.txPool, eth.chainManager, eth.EventMux())
eth.chainManager.SetProcessor(eth.blockProcessor)
eth.whisper = whisper.New()
- eth.miner = miner.New(keyManager.Address(), eth, pow, config.MinerThreads)
+ eth.miner = miner.New(cb, eth, pow, config.MinerThreads)
hasBlock := eth.chainManager.HasBlock
insertChain := eth.chainManager.InsertChain
@@ -225,9 +211,9 @@ func New(config *Config) (*Ethereum, error) {
return eth, nil
}
-func (s *Ethereum) KeyManager() *crypto.KeyManager { return s.keyManager }
func (s *Ethereum) Logger() logger.LogSystem { return s.logger }
func (s *Ethereum) Name() string { return s.net.Name }
+func (s *Ethereum) AccountManager() *accounts.Manager { return s.accountManager }
func (s *Ethereum) ChainManager() *core.ChainManager { return s.chainManager }
func (s *Ethereum) BlockProcessor() *core.BlockProcessor { return s.blockProcessor }
func (s *Ethereum) TxPool() *core.TxPool { return s.txPool }
@@ -241,7 +227,6 @@ func (s *Ethereum) IsListening() bool { return true } // Alwa
func (s *Ethereum) PeerCount() int { return s.net.PeerCount() }
func (s *Ethereum) Peers() []*p2p.Peer { return s.net.Peers() }
func (s *Ethereum) MaxPeers() int { return s.net.MaxPeers }
-func (s *Ethereum) Coinbase() []byte { return nil } // TODO
// Start the ethereum
func (s *Ethereum) Start() error {
@@ -292,10 +277,6 @@ func (s *Ethereum) Stop() {
s.txSub.Unsubscribe() // quits txBroadcastLoop
s.blockSub.Unsubscribe() // quits blockBroadcastLoop
- if s.RpcServer != nil {
- s.RpcServer.Stop()
- }
-
s.txPool.Stop()
s.eventMux.Stop()
s.blockPool.Stop()