diff options
author | obscuren <geffobscura@gmail.com> | 2015-02-17 19:24:51 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-02-17 19:24:58 +0800 |
commit | 8135752a32837748e6d4a986912131736b1a0aa0 (patch) | |
tree | 0ad3b6abab8a4b0c013844f93ca665526d2a567a /eth/backend.go | |
parent | 164de5e22be39ba2bdc58f84f72572252634e7e1 (diff) | |
download | go-tangerine-8135752a32837748e6d4a986912131736b1a0aa0.tar go-tangerine-8135752a32837748e6d4a986912131736b1a0aa0.tar.gz go-tangerine-8135752a32837748e6d4a986912131736b1a0aa0.tar.bz2 go-tangerine-8135752a32837748e6d4a986912131736b1a0aa0.tar.lz go-tangerine-8135752a32837748e6d4a986912131736b1a0aa0.tar.xz go-tangerine-8135752a32837748e6d4a986912131736b1a0aa0.tar.zst go-tangerine-8135752a32837748e6d4a986912131736b1a0aa0.zip |
"centralised" mining to backend. Closes #323
Diffstat (limited to 'eth/backend.go')
-rw-r--r-- | eth/backend.go | 82 |
1 files changed, 19 insertions, 63 deletions
diff --git a/eth/backend.go b/eth/backend.go index 8c2073574..690c7136d 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/event" ethlogger "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/miner" "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p/discover" "github.com/ethereum/go-ethereum/p2p/nat" @@ -95,6 +96,7 @@ type Ethereum struct { eventMux *event.TypeMux txSub event.Subscription blockSub event.Subscription + miner *miner.Miner RpcServer rpc.RpcServer WsServer rpc.RpcServer @@ -151,6 +153,7 @@ func New(config *Config) (*Ethereum, error) { eth.blockProcessor = core.NewBlockProcessor(db, eth.txPool, eth.chainManager, eth.EventMux()) eth.chainManager.SetProcessor(eth.blockProcessor) eth.whisper = whisper.New() + eth.miner = miner.New(keyManager.Address(), eth) hasBlock := eth.chainManager.HasBlock insertChain := eth.chainManager.InsertChain @@ -181,69 +184,22 @@ func New(config *Config) (*Ethereum, error) { return eth, nil } -func (s *Ethereum) KeyManager() *crypto.KeyManager { - return s.keyManager -} - -func (s *Ethereum) Logger() ethlogger.LogSystem { - return s.logger -} - -func (s *Ethereum) Name() string { - return s.net.Name -} - -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 -} - -func (s *Ethereum) BlockPool() *BlockPool { - return s.blockPool -} - -func (s *Ethereum) Whisper() *whisper.Whisper { - return s.whisper -} - -func (s *Ethereum) EventMux() *event.TypeMux { - return s.eventMux -} -func (self *Ethereum) Db() ethutil.Database { - return self.db -} - -func (s *Ethereum) IsMining() bool { - return s.Mining -} - -func (s *Ethereum) IsListening() bool { - // XXX TODO - return false -} - -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 -} +func (s *Ethereum) KeyManager() *crypto.KeyManager { return s.keyManager } +func (s *Ethereum) Logger() ethlogger.LogSystem { return s.logger } +func (s *Ethereum) Name() string { return s.net.Name } +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 } +func (s *Ethereum) BlockPool() *BlockPool { return s.blockPool } +func (s *Ethereum) Whisper() *whisper.Whisper { return s.whisper } +func (s *Ethereum) EventMux() *event.TypeMux { return s.eventMux } +func (s *Ethereum) Db() ethutil.Database { return s.db } +func (s *Ethereum) Miner() *miner.Miner { return s.miner } +func (s *Ethereum) IsListening() bool { return true } // Always listening +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 { |