コード例 #1
0
ファイル: main.go プロジェクト: este-xx/go-expanse
func startEth(ctx *cli.Context, exp *exp.Expanse) {
	// Start Expanse itself
	utils.StartExpanse(exp)

	am := exp.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(exp, ctx); err != nil {
			utils.Fatalf("Error string IPC: %v", err)
		}
	}
	if ctx.GlobalBool(utils.RPCEnabledFlag.Name) {
		if err := utils.StartRPC(exp, ctx); err != nil {
			utils.Fatalf("Error starting RPC: %v", err)
		}
	}
	if ctx.GlobalBool(utils.MiningEnabledFlag.Name) {
		if err := exp.StartMining(ctx.GlobalInt(utils.MinerThreadsFlag.Name)); err != nil {
			utils.Fatalf("%v", err)
		}
	}
}
コード例 #2
0
ファイル: main.go プロジェクト: expanse-project/go-expanse
// startNode boots up the system node and all registered protocols, after which
// it unlocks any requested accounts, and starts the RPC/IPC interfaces and the
// miner.
func startNode(ctx *cli.Context, stack *node.Node) {
	// Start up the node itself
	utils.StartNode(stack)

	// Unlock any account specifically requested
	var expanse *exp.Expanse
	if err := stack.Service(&expanse); err != nil {
		utils.Fatalf("ethereum service not running: %v", err)
	}
	accman := expanse.AccountManager()
	passwords := utils.MakePasswordList(ctx)

	accounts := strings.Split(ctx.GlobalString(utils.UnlockedAccountFlag.Name), ",")
	for i, account := range accounts {
		if trimmed := strings.TrimSpace(account); trimmed != "" {
			unlockAccount(ctx, accman, trimmed, i, passwords)
		}
	}
	// Start auxiliary services if enabled
	if ctx.GlobalBool(utils.MiningEnabledFlag.Name) {
		if err := expanse.StartMining(ctx.GlobalInt(utils.MinerThreadsFlag.Name), ctx.GlobalString(utils.MiningGPUFlag.Name)); err != nil {
			utils.Fatalf("Failed to start mining: %v", err)
		}
	}
}
コード例 #3
0
ファイル: xeth.go プロジェクト: Cisko-Rijken/go-expanse
// New creates an XEth that uses the given frontend.
// If a nil Frontend is provided, a default frontend which
// confirms all transactions will be used.
func New(expanse *exp.Expanse, frontend Frontend) *XEth {
	xeth := &XEth{
		backend:          expanse,
		frontend:         frontend,
		quit:             make(chan struct{}),
		filterManager:    filters.NewFilterSystem(expanse.EventMux()),
		logQueue:         make(map[int]*logQueue),
		blockQueue:       make(map[int]*hashQueue),
		transactionQueue: make(map[int]*hashQueue),
		messages:         make(map[int]*whisperFilter),
		agent:            miner.NewRemoteAgent(),
		gpo:              exp.NewGasPriceOracle(expanse),
	}
	if expanse.Whisper() != nil {
		xeth.whisper = NewWhisper(expanse.Whisper())
	}
	expanse.Miner().Register(xeth.agent)
	if frontend == nil {
		xeth.frontend = dummyFrontend{}
	}
	state, _ := xeth.backend.BlockChain().State()
	xeth.state = NewState(xeth, state)
	go xeth.start()
	return xeth
}
コード例 #4
0
ファイル: flags.go プロジェクト: 5mil/go-expanse
func StartIPC(exp *exp.Expanse, ctx *cli.Context) error {
	config := comms.IpcConfig{
		Endpoint: IpcSocketPath(ctx),
	}

	initializer := func(conn net.Conn) (comms.Stopper, shared.ExpanseApi, error) {
		fe := useragent.NewRemoteFrontend(conn, exp.AccountManager())
		xeth := xeth.New(exp, fe)
		apis, err := api.ParseApiString(ctx.GlobalString(IPCApiFlag.Name), codec.JSON, xeth, exp)
		if err != nil {
			return nil, nil, err
		}
		return xeth, api.Merge(apis...), nil
	}

	return comms.StartIpc(config, codec.JSON, initializer)
}
コード例 #5
0
ファイル: cmd.go プロジェクト: Cisko-Rijken/go-expanse
func StartExpanse(expanse *exp.Expanse) {
	glog.V(logger.Info).Infoln("Starting", expanse.Name())
	if err := expanse.Start(); err != nil {
		Fatalf("Error starting Expanse: %v", err)
	}
	go func() {
		sigc := make(chan os.Signal, 1)
		signal.Notify(sigc, os.Interrupt)
		defer signal.Stop(sigc)
		<-sigc
		glog.V(logger.Info).Infoln("Got interrupt, shutting down...")
		go expanse.Stop()
		logger.Flush()
		for i := 10; i > 0; i-- {
			<-sigc
			if i > 1 {
				glog.V(logger.Info).Infoln("Already shutting down, please be patient.")
				glog.V(logger.Info).Infoln("Interrupt", i-1, "more times to induce panic.")
			}
		}
		glog.V(logger.Error).Infof("Force quitting: this might not end so well.")
		panic("boom")
	}()
}