@@ -11,6 +11,7 @@ import (
11
11
"github.com/ethereum/go-ethereum/ethutil"
12
12
"github.com/ethereum/go-ethereum/event"
13
13
ethlogger "github.com/ethereum/go-ethereum/logger"
14
+ "github.com/ethereum/go-ethereum/miner"
14
15
"github.com/ethereum/go-ethereum/p2p"
15
16
"github.com/ethereum/go-ethereum/p2p/discover"
16
17
"github.com/ethereum/go-ethereum/p2p/nat"
@@ -95,6 +96,7 @@ type Ethereum struct {
95
96
eventMux * event.TypeMux
96
97
txSub event.Subscription
97
98
blockSub event.Subscription
99
+ miner * miner.Miner
98
100
99
101
RpcServer rpc.RpcServer
100
102
WsServer rpc.RpcServer
@@ -151,6 +153,7 @@ func New(config *Config) (*Ethereum, error) {
151
153
eth .blockProcessor = core .NewBlockProcessor (db , eth .txPool , eth .chainManager , eth .EventMux ())
152
154
eth .chainManager .SetProcessor (eth .blockProcessor )
153
155
eth .whisper = whisper .New ()
156
+ eth .miner = miner .New (keyManager .Address (), eth )
154
157
155
158
hasBlock := eth .chainManager .HasBlock
156
159
insertChain := eth .chainManager .InsertChain
@@ -181,69 +184,22 @@ func New(config *Config) (*Ethereum, error) {
181
184
return eth , nil
182
185
}
183
186
184
- func (s * Ethereum ) KeyManager () * crypto.KeyManager {
185
- return s .keyManager
186
- }
187
-
188
- func (s * Ethereum ) Logger () ethlogger.LogSystem {
189
- return s .logger
190
- }
191
-
192
- func (s * Ethereum ) Name () string {
193
- return s .net .Name
194
- }
195
-
196
- func (s * Ethereum ) ChainManager () * core.ChainManager {
197
- return s .chainManager
198
- }
199
-
200
- func (s * Ethereum ) BlockProcessor () * core.BlockProcessor {
201
- return s .blockProcessor
202
- }
203
-
204
- func (s * Ethereum ) TxPool () * core.TxPool {
205
- return s .txPool
206
- }
207
-
208
- func (s * Ethereum ) BlockPool () * BlockPool {
209
- return s .blockPool
210
- }
211
-
212
- func (s * Ethereum ) Whisper () * whisper.Whisper {
213
- return s .whisper
214
- }
215
-
216
- func (s * Ethereum ) EventMux () * event.TypeMux {
217
- return s .eventMux
218
- }
219
- func (self * Ethereum ) Db () ethutil.Database {
220
- return self .db
221
- }
222
-
223
- func (s * Ethereum ) IsMining () bool {
224
- return s .Mining
225
- }
226
-
227
- func (s * Ethereum ) IsListening () bool {
228
- // XXX TODO
229
- return false
230
- }
231
-
232
- func (s * Ethereum ) PeerCount () int {
233
- return s .net .PeerCount ()
234
- }
235
-
236
- func (s * Ethereum ) Peers () []* p2p.Peer {
237
- return s .net .Peers ()
238
- }
239
-
240
- func (s * Ethereum ) MaxPeers () int {
241
- return s .net .MaxPeers
242
- }
243
-
244
- func (s * Ethereum ) Coinbase () []byte {
245
- return nil // TODO
246
- }
187
+ func (s * Ethereum ) KeyManager () * crypto.KeyManager { return s .keyManager }
188
+ func (s * Ethereum ) Logger () ethlogger.LogSystem { return s .logger }
189
+ func (s * Ethereum ) Name () string { return s .net .Name }
190
+ func (s * Ethereum ) ChainManager () * core.ChainManager { return s .chainManager }
191
+ func (s * Ethereum ) BlockProcessor () * core.BlockProcessor { return s .blockProcessor }
192
+ func (s * Ethereum ) TxPool () * core.TxPool { return s .txPool }
193
+ func (s * Ethereum ) BlockPool () * BlockPool { return s .blockPool }
194
+ func (s * Ethereum ) Whisper () * whisper.Whisper { return s .whisper }
195
+ func (s * Ethereum ) EventMux () * event.TypeMux { return s .eventMux }
196
+ func (s * Ethereum ) Db () ethutil.Database { return s .db }
197
+ func (s * Ethereum ) Miner () * miner.Miner { return s .miner }
198
+ func (s * Ethereum ) IsListening () bool { return true } // Always listening
199
+ func (s * Ethereum ) PeerCount () int { return s .net .PeerCount () }
200
+ func (s * Ethereum ) Peers () []* p2p.Peer { return s .net .Peers () }
201
+ func (s * Ethereum ) MaxPeers () int { return s .net .MaxPeers }
202
+ func (s * Ethereum ) Coinbase () []byte { return nil } // TODO
247
203
248
204
// Start the ethereum
249
205
func (s * Ethereum ) Start () error {
0 commit comments