Пример #1
0
func startEth(ctx *cli.Context, eth *eth.Ethereum) {
	// Start Ethereum itself
	utils.StartEthereum(eth)

	am := eth.AccountManager()
	account := ctx.GlobalString(utils.UnlockedAccountFlag.Name)
	accounts := strings.Split(account, " ")
	for i, account := range accounts {
		if len(account) > 0 {
			if account == "primary" {
				utils.Fatalf("the 'primary' keyword is deprecated. You can use integer indexes, but the indexes are not permanent, they can change if you add external keys, export your keys or copy your keystore to another node.")
			}
			unlockAccount(ctx, am, account, i)
		}
	}
	// Start auxiliary services if enabled.
	if !ctx.GlobalBool(utils.IPCDisabledFlag.Name) {
		if err := utils.StartIPC(eth, ctx); err != nil {
			utils.Fatalf("Error string IPC: %v", err)
		}
	}
	if ctx.GlobalBool(utils.RPCEnabledFlag.Name) {
		if err := utils.StartRPC(eth, ctx); err != nil {
			utils.Fatalf("Error starting RPC: %v", err)
		}
	}
	if ctx.GlobalBool(utils.MiningEnabledFlag.Name) {
		if err := eth.StartMining(ctx.GlobalInt(utils.MinerThreadsFlag.Name)); err != nil {
			utils.Fatalf("%v", err)
		}
	}
}
Пример #2
0
func startEth(ctx *cli.Context, eth *eth.Ethereum) {
	// Start Ethereum itself
	utils.StartEthereum(eth)
	am := eth.AccountManager()

	account := ctx.GlobalString(utils.UnlockedAccountFlag.Name)
	if len(account) > 0 {
		if account == "primary" {
			accbytes, err := am.Primary()
			if err != nil {
				utils.Fatalf("no primary account: %v", err)
			}
			account = common.ToHex(accbytes)
		}
		unlockAccount(ctx, am, account)
	}
	// Start auxiliary services if enabled.
	if ctx.GlobalBool(utils.RPCEnabledFlag.Name) {
		if err := utils.StartRPC(eth, ctx); err != nil {
			utils.Fatalf("Error starting RPC: %v", err)
		}
	}
	if ctx.GlobalBool(utils.MiningEnabledFlag.Name) {
		if err := eth.StartMining(); err != nil {
			utils.Fatalf("%v", err)
		}
	}
}
Пример #3
0
func runBlockTest(ctx *cli.Context) {
	var (
		file, testname string
		rpc            bool
	)
	args := ctx.Args()
	switch {
	case len(args) == 1:
		file = args[0]
	case len(args) == 2:
		file, testname = args[0], args[1]
	case len(args) == 3:
		file, testname = args[0], args[1]
		rpc = true
	default:
		utils.Fatalf(`Usage: ethereum blocktest <path-to-test-file> [ <test-name> [ "rpc" ] ]`)
	}
	bt, err := tests.LoadBlockTests(file)
	if err != nil {
		utils.Fatalf("%v", err)
	}

	// run all tests if no test name is specified
	if testname == "" {
		ecode := 0
		for name, test := range bt {
			fmt.Printf("----------------- Running Block Test %q\n", name)
			ethereum, err := runOneBlockTest(ctx, test)
			if err != nil {
				fmt.Println(err)
				fmt.Println("FAIL")
				ecode = 1
			}
			if ethereum != nil {
				ethereum.Stop()
				ethereum.WaitForShutdown()
			}
		}
		os.Exit(ecode)
		return
	}
	// otherwise, run the given test
	test, ok := bt[testname]
	if !ok {
		utils.Fatalf("Test file does not contain test named %q", testname)
	}
	ethereum, err := runOneBlockTest(ctx, test)
	if err != nil {
		utils.Fatalf("%v", err)
	}
	defer ethereum.Stop()
	if rpc {
		fmt.Println("Block Test post state validated, starting RPC interface.")
		startEth(ctx, ethereum)
		utils.StartRPC(ethereum, ctx)
		ethereum.WaitForShutdown()
	}
}
Пример #4
0
func run(ctx *cli.Context) {
	importer := NewImporter(ctx)
	utils.HandleInterrupt()

	cfg := utils.MakeEthConfig("EthChainParser", Version, ctx)

	ethereum, err := eth.New(cfg)
	if err != nil {
		utils.Fatalf("%v", err)
	}
	utils.StartEthereum(ethereum)

	if ctx.GlobalBool(utils.RPCEnabledFlag.Name) {
		utils.StartRPC(ethereum, ctx)
	}

	events := ethereum.EventMux().Subscribe(
		core.ChainEvent{},
		core.TxPreEvent{},
	)

	defer events.Unsubscribe()
	for {
		select {
		case ev, isopen := <-events.Chan():
			if !isopen {
				return
			}
			switch ev := ev.(type) {
			case core.ChainEvent:
				importer.importBlock(ev.Block)
			case core.TxPreEvent:
				// Not dealing with incoming txes for now
				//importer.importTx(ev.Tx)
			}
		}
	}

	ethereum.WaitForShutdown()
	logger.Flush()
	fmt.Printf("Shutting down\n")
}
Пример #5
0
func startEth(ctx *cli.Context, eth *eth.Ethereum) {
	// Start Ethereum itself

	utils.StartEthereum(eth)
	am := eth.AccountManager()

	account := ctx.GlobalString(utils.UnlockedAccountFlag.Name)
	accounts := strings.Split(account, " ")
	for _, account := range accounts {
		if len(account) > 0 {
			if account == "primary" {
				primaryAcc, err := am.Primary()
				if err != nil {
					utils.Fatalf("no primary account: %v", err)
				}
				account = primaryAcc.Hex()
			}
			unlockAccount(ctx, am, account)
		}
	}
	// Start auxiliary services if enabled.
	if !ctx.GlobalBool(utils.IPCDisabledFlag.Name) {
		if err := utils.StartIPC(eth, ctx); err != nil {
			utils.Fatalf("Error string IPC: %v", err)
		}
	}
	if ctx.GlobalBool(utils.RPCEnabledFlag.Name) {
		if err := utils.StartRPC(eth, ctx); err != nil {
			utils.Fatalf("Error starting RPC: %v", err)
		}
	}
	if ctx.GlobalBool(utils.MiningEnabledFlag.Name) {
		if err := eth.StartMining(ctx.GlobalInt(utils.MinerThreadsFlag.Name)); err != nil {
			utils.Fatalf("%v", err)
		}
	}
}
Пример #6
0
func run(ctx *cli.Context) {
	tstart := time.Now()

	// TODO: show qml popup instead of exiting if initialization fails.
	cfg := utils.MakeEthConfig(ClientIdentifier, nodeNameVersion, ctx)
	cfg.Shh = true
	ethereum, err := eth.New(cfg)
	if err != nil {
		utils.Fatalf("%v", err)
	}
	utils.StartRPC(ethereum, ctx)
	go utils.StartEthereum(ethereum)
	fmt.Println("initializing eth stack took", time.Since(tstart))

	// Open the window
	qml.Run(func() error {
		webengine.Initialize()
		gui := NewWindow(ethereum)
		utils.RegisterInterrupt(func(os.Signal) { gui.Stop() })
		// gui blocks the main thread
		gui.Start(ctx.GlobalString(assetPathFlag.Name), ctx.GlobalString(utils.JSpathFlag.Name))
		return nil
	})
}