@@ -36,8 +36,8 @@ import (
36
36
"github.com/ethereum/go-ethereum/eth/downloader"
37
37
"github.com/ethereum/go-ethereum/ethclient"
38
38
"github.com/ethereum/go-ethereum/internal/debug"
39
+ "github.com/ethereum/go-ethereum/internal/ethapi"
39
40
"github.com/ethereum/go-ethereum/internal/flags"
40
- "github.com/ethereum/go-ethereum/les"
41
41
"github.com/ethereum/go-ethereum/log"
42
42
"github.com/ethereum/go-ethereum/metrics"
43
43
"github.com/ethereum/go-ethereum/node"
@@ -171,8 +171,6 @@ var (
171
171
utils .LegacyRPCCORSDomainFlag ,
172
172
utils .LegacyRPCVirtualHostsFlag ,
173
173
utils .GraphQLEnabledFlag ,
174
- utils .GraphQLListenAddrFlag ,
175
- utils .GraphQLPortFlag ,
176
174
utils .GraphQLCORSDomainFlag ,
177
175
utils .GraphQLVirtualHostsFlag ,
178
176
utils .HTTPApiFlag ,
@@ -350,18 +348,20 @@ func geth(ctx *cli.Context) error {
350
348
if args := ctx .Args (); len (args ) > 0 {
351
349
return fmt .Errorf ("invalid command: %q" , args [0 ])
352
350
}
351
+
353
352
prepare (ctx )
354
- node := makeFullNode (ctx )
355
- defer node .Close ()
356
- startNode (ctx , node )
357
- node .Wait ()
353
+ stack , backend := makeFullNode (ctx )
354
+ defer stack .Close ()
355
+
356
+ startNode (ctx , stack , backend )
357
+ stack .Wait ()
358
358
return nil
359
359
}
360
360
361
361
// startNode boots up the system node and all registered protocols, after which
362
362
// it unlocks any requested accounts, and starts the RPC/IPC interfaces and the
363
363
// miner.
364
- func startNode (ctx * cli.Context , stack * node.Node ) {
364
+ func startNode (ctx * cli.Context , stack * node.Node , backend ethapi. Backend ) {
365
365
debug .Memsize .Add ("node" , stack )
366
366
367
367
// Start up the node itself
@@ -381,25 +381,6 @@ func startNode(ctx *cli.Context, stack *node.Node) {
381
381
}
382
382
ethClient := ethclient .NewClient (rpcClient )
383
383
384
- // Set contract backend for ethereum service if local node
385
- // is serving LES requests.
386
- if ctx .GlobalInt (utils .LegacyLightServFlag .Name ) > 0 || ctx .GlobalInt (utils .LightServeFlag .Name ) > 0 {
387
- var ethService * eth.Ethereum
388
- if err := stack .Service (& ethService ); err != nil {
389
- utils .Fatalf ("Failed to retrieve ethereum service: %v" , err )
390
- }
391
- ethService .SetContractBackend (ethClient )
392
- }
393
- // Set contract backend for les service if local node is
394
- // running as a light client.
395
- if ctx .GlobalString (utils .SyncModeFlag .Name ) == "light" {
396
- var lesService * les.LightEthereum
397
- if err := stack .Service (& lesService ); err != nil {
398
- utils .Fatalf ("Failed to retrieve light ethereum service: %v" , err )
399
- }
400
- lesService .SetContractBackend (ethClient )
401
- }
402
-
403
384
go func () {
404
385
// Open any wallets already attached
405
386
for _ , wallet := range stack .AccountManager ().Wallets () {
@@ -451,7 +432,7 @@ func startNode(ctx *cli.Context, stack *node.Node) {
451
432
if timestamp := time .Unix (int64 (done .Latest .Time ), 0 ); time .Since (timestamp ) < 10 * time .Minute {
452
433
log .Info ("Synchronisation completed" , "latestnum" , done .Latest .Number , "latesthash" , done .Latest .Hash (),
453
434
"age" , common .PrettyAge (timestamp ))
454
- stack .Stop ()
435
+ stack .Close ()
455
436
}
456
437
}
457
438
}()
@@ -463,24 +444,24 @@ func startNode(ctx *cli.Context, stack *node.Node) {
463
444
if ctx .GlobalString (utils .SyncModeFlag .Name ) == "light" {
464
445
utils .Fatalf ("Light clients do not support mining" )
465
446
}
466
- var ethereum * eth.Ethereum
467
- if err := stack . Service ( & ethereum ); err != nil {
447
+ ethBackend , ok := backend .( * eth.EthAPIBackend )
448
+ if ! ok {
468
449
utils .Fatalf ("Ethereum service not running: %v" , err )
469
450
}
451
+
470
452
// Set the gas price to the limits from the CLI and start mining
471
453
gasprice := utils .GlobalBig (ctx , utils .MinerGasPriceFlag .Name )
472
454
if ctx .GlobalIsSet (utils .LegacyMinerGasPriceFlag .Name ) && ! ctx .GlobalIsSet (utils .MinerGasPriceFlag .Name ) {
473
455
gasprice = utils .GlobalBig (ctx , utils .LegacyMinerGasPriceFlag .Name )
474
456
}
475
- ethereum .TxPool ().SetGasPrice (gasprice )
476
-
457
+ ethBackend .TxPool ().SetGasPrice (gasprice )
458
+ // start mining
477
459
threads := ctx .GlobalInt (utils .MinerThreadsFlag .Name )
478
460
if ctx .GlobalIsSet (utils .LegacyMinerThreadsFlag .Name ) && ! ctx .GlobalIsSet (utils .MinerThreadsFlag .Name ) {
479
461
threads = ctx .GlobalInt (utils .LegacyMinerThreadsFlag .Name )
480
462
log .Warn ("The flag --minerthreads is deprecated and will be removed in the future, please use --miner.threads" )
481
463
}
482
-
483
- if err := ethereum .StartMining (threads ); err != nil {
464
+ if err := ethBackend .StartMining (threads ); err != nil {
484
465
utils .Fatalf ("Failed to start mining: %v" , err )
485
466
}
486
467
}
0 commit comments