本文整理汇总了Golang中github.com/expanse-project/go-expanse/exp.Expanse类的典型用法代码示例。如果您正苦于以下问题:Golang Expanse类的具体用法?Golang Expanse怎么用?Golang Expanse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Expanse类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: startEth
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)
}
}
}
开发者ID:este-xx,项目名称:go-expanse,代码行数:32,代码来源:main.go
示例2: startNode
// 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)
}
}
}
开发者ID:expanse-project,项目名称:go-expanse,代码行数:28,代码来源:main.go
示例3: New
// 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
}
开发者ID:Cisko-Rijken,项目名称:go-expanse,代码行数:28,代码来源:xeth.go
示例4: StartIPC
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)
}
开发者ID:5mil,项目名称:go-expanse,代码行数:17,代码来源:flags.go
示例5: StartExpanse
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")
}()
}
开发者ID:Cisko-Rijken,项目名称:go-expanse,代码行数:24,代码来源:cmd.go
注:本文中的github.com/expanse-project/go-expanse/exp.Expanse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论