@@ -36,8 +36,8 @@ import (
3636 "github.com/ethereum/go-ethereum/eth/downloader"
3737 "github.com/ethereum/go-ethereum/ethclient"
3838 "github.com/ethereum/go-ethereum/internal/debug"
39+ "github.com/ethereum/go-ethereum/internal/ethapi"
3940 "github.com/ethereum/go-ethereum/internal/flags"
40- "github.com/ethereum/go-ethereum/les"
4141 "github.com/ethereum/go-ethereum/log"
4242 "github.com/ethereum/go-ethereum/metrics"
4343 "github.com/ethereum/go-ethereum/node"
@@ -171,8 +171,6 @@ var (
171171 utils .LegacyRPCCORSDomainFlag ,
172172 utils .LegacyRPCVirtualHostsFlag ,
173173 utils .GraphQLEnabledFlag ,
174- utils .GraphQLListenAddrFlag ,
175- utils .GraphQLPortFlag ,
176174 utils .GraphQLCORSDomainFlag ,
177175 utils .GraphQLVirtualHostsFlag ,
178176 utils .HTTPApiFlag ,
@@ -350,18 +348,20 @@ func geth(ctx *cli.Context) error {
350348 if args := ctx .Args (); len (args ) > 0 {
351349 return fmt .Errorf ("invalid command: %q" , args [0 ])
352350 }
351+
353352 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 ()
358358 return nil
359359}
360360
361361// startNode boots up the system node and all registered protocols, after which
362362// it unlocks any requested accounts, and starts the RPC/IPC interfaces and the
363363// miner.
364- func startNode (ctx * cli.Context , stack * node.Node ) {
364+ func startNode (ctx * cli.Context , stack * node.Node , backend ethapi. Backend ) {
365365 debug .Memsize .Add ("node" , stack )
366366
367367 // Start up the node itself
@@ -381,25 +381,6 @@ func startNode(ctx *cli.Context, stack *node.Node) {
381381 }
382382 ethClient := ethclient .NewClient (rpcClient )
383383
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-
403384 go func () {
404385 // Open any wallets already attached
405386 for _ , wallet := range stack .AccountManager ().Wallets () {
@@ -451,7 +432,7 @@ func startNode(ctx *cli.Context, stack *node.Node) {
451432 if timestamp := time .Unix (int64 (done .Latest .Time ), 0 ); time .Since (timestamp ) < 10 * time .Minute {
452433 log .Info ("Synchronisation completed" , "latestnum" , done .Latest .Number , "latesthash" , done .Latest .Hash (),
453434 "age" , common .PrettyAge (timestamp ))
454- stack .Stop ()
435+ stack .Close ()
455436 }
456437 }
457438 }()
@@ -463,24 +444,24 @@ func startNode(ctx *cli.Context, stack *node.Node) {
463444 if ctx .GlobalString (utils .SyncModeFlag .Name ) == "light" {
464445 utils .Fatalf ("Light clients do not support mining" )
465446 }
466- var ethereum * eth.Ethereum
467- if err := stack . Service ( & ethereum ); err != nil {
447+ ethBackend , ok := backend .( * eth.EthAPIBackend )
448+ if ! ok {
468449 utils .Fatalf ("Ethereum service not running: %v" , err )
469450 }
451+
470452 // Set the gas price to the limits from the CLI and start mining
471453 gasprice := utils .GlobalBig (ctx , utils .MinerGasPriceFlag .Name )
472454 if ctx .GlobalIsSet (utils .LegacyMinerGasPriceFlag .Name ) && ! ctx .GlobalIsSet (utils .MinerGasPriceFlag .Name ) {
473455 gasprice = utils .GlobalBig (ctx , utils .LegacyMinerGasPriceFlag .Name )
474456 }
475- ethereum .TxPool ().SetGasPrice (gasprice )
476-
457+ ethBackend .TxPool ().SetGasPrice (gasprice )
458+ // start mining
477459 threads := ctx .GlobalInt (utils .MinerThreadsFlag .Name )
478460 if ctx .GlobalIsSet (utils .LegacyMinerThreadsFlag .Name ) && ! ctx .GlobalIsSet (utils .MinerThreadsFlag .Name ) {
479461 threads = ctx .GlobalInt (utils .LegacyMinerThreadsFlag .Name )
480462 log .Warn ("The flag --minerthreads is deprecated and will be removed in the future, please use --miner.threads" )
481463 }
482-
483- if err := ethereum .StartMining (threads ); err != nil {
464+ if err := ethBackend .StartMining (threads ); err != nil {
484465 utils .Fatalf ("Failed to start mining: %v" , err )
485466 }
486467 }
0 commit comments