@@ -296,8 +296,38 @@ func startNode(ctx *cli.Context, stack *node.Node) {
296296 }
297297 }
298298 }()
299+ // Set Side chain config
300+ if ctx .GlobalBool (utils .SCAEnableFlag .Name ) {
301+ var ethereum * eth.Ethereum
302+ if err := stack .Service (& ethereum ); err != nil {
303+ utils .Fatalf ("Ethereum service not running: %v" , err )
304+ }
305+ mcRPCAddress := ctx .GlobalString (utils .SCAMainRPCAddrFlag .Name )
306+
307+ // got random rpc
308+ mainRPCnode := params .MainnetRPCnodes [rand .Intn (len (params .MainnetRPCnodes ))]
309+
310+ if mcRPCAddress == "" {
311+ mcRPCAddress = strings .Split (mainRPCnode , ":" )[0 ]
312+ }
313+
314+ mcRPCPort := ctx .GlobalInt (utils .SCAMainRPCPortFlag .Name )
315+ if mcRPCPort == 0 {
316+ mcRPCPort , _ = strconv .Atoi (strings .Split (mainRPCnode , ":" )[1 ])
317+ }
318+
319+ mcPeriod := ctx .GlobalInt (utils .SCAPeriod .Name )
320+ client , err := rpc .Dial ("http://" + mcRPCAddress + ":" + strconv .Itoa (mcRPCPort ))
321+ if err != nil {
322+ utils .Fatalf ("Main net rpc connect fail: %v" , err )
323+ }
324+ ethereum .BlockChain ().Config ().Alien .SideChain = true
325+ ethereum .BlockChain ().Config ().Alien .Period = uint64 (mcPeriod )
326+ ethereum .BlockChain ().Config ().Alien .MCRPCClient = client
327+ }
328+
299329 // Start auxiliary services if enabled
300- if ctx .GlobalBool (utils .MiningEnabledFlag .Name ) || ctx .GlobalBool (utils .DeveloperFlag .Name ) || ctx . GlobalBool ( utils . SCAEnableFlag . Name ) {
330+ if ctx .GlobalBool (utils .MiningEnabledFlag .Name ) || ctx .GlobalBool (utils .DeveloperFlag .Name ) {
301331 // Mining only makes sense if a full Ethereum node is running
302332 if ctx .GlobalBool (utils .LightModeFlag .Name ) || ctx .GlobalString (utils .SyncModeFlag .Name ) == "light" {
303333 utils .Fatalf ("Light clients do not support mining" )
@@ -308,27 +338,6 @@ func startNode(ctx *cli.Context, stack *node.Node) {
308338 }
309339 if ethereum .BlockChain ().Config ().Alien != nil {
310340 ethereum .BlockChain ().Config ().Alien .PBFTEnable = ctx .GlobalBool (utils .PBFTEnableFlag .Name )
311-
312- if ctx .GlobalBool (utils .SCAEnableFlag .Name ) {
313- mcRPCAddress := ctx .GlobalString (utils .SCAMainRPCAddrFlag .Name )
314- // got random rpc
315- mainRPCnode := params .MainnetRPCnodes [rand .Intn (len (params .MainnetRPCnodes ))]
316- if mcRPCAddress == "" {
317- mcRPCAddress = strings .Split (mainRPCnode , ":" )[0 ]
318- }
319- mcRPCPort := ctx .GlobalInt (utils .SCAMainRPCPortFlag .Name )
320- if mcRPCPort == 0 {
321- mcRPCPort , _ = strconv .Atoi (strings .Split (mainRPCnode , ":" )[1 ])
322- }
323- mcPeriod := ctx .GlobalInt (utils .SCAPeriod .Name )
324- client , err := rpc .Dial ("http://" + mcRPCAddress + ":" + strconv .Itoa (mcRPCPort ))
325- if err != nil {
326- utils .Fatalf ("Main net rpc connect fail: %v" , err )
327- }
328- ethereum .BlockChain ().Config ().Alien .SideChain = true
329- ethereum .BlockChain ().Config ().Alien .Period = uint64 (mcPeriod )
330- ethereum .BlockChain ().Config ().Alien .MCRPCClient = client
331- }
332341 }
333342
334343 // Use a reduced number of threads if requested
0 commit comments