• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang api.Merge函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/ethereum/go-ethereum/rpc/api.Merge函数的典型用法代码示例。如果您正苦于以下问题:Golang Merge函数的具体用法?Golang Merge怎么用?Golang Merge使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Merge函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: StartIPC

func StartIPC(eth *eth.Ethereum, ctx *cli.Context) error {
	config := comms.IpcConfig{
		Endpoint: IpcSocketPath(ctx),
	}

	xeth := xeth.New(eth, nil)
	codec := codec.JSON

	apis, err := api.ParseApiString(ctx.GlobalString(IPCApiFlag.Name), codec, xeth, eth)
	if err != nil {
		return err
	}

	return comms.StartIpc(config, codec, api.Merge(apis...))
}
开发者ID:ssonneborn22,项目名称:go-ethereum,代码行数:15,代码来源:flags.go


示例2: StartRPC

func StartRPC(eth *eth.Ethereum, ctx *cli.Context) error {
	config := comms.HttpConfig{
		ListenAddress: ctx.GlobalString(RPCListenAddrFlag.Name),
		ListenPort:    uint(ctx.GlobalInt(RPCPortFlag.Name)),
		CorsDomain:    ctx.GlobalString(RPCCORSDomainFlag.Name),
	}

	xeth := xeth.New(eth, nil)
	codec := codec.JSON

	apis, err := api.ParseApiString(ctx.GlobalString(RpcApiFlag.Name), codec, xeth, eth)
	if err != nil {
		return err
	}

	return comms.StartHttp(config, codec, api.Merge(apis...))
}
开发者ID:General-Beck,项目名称:go-ethereum,代码行数:17,代码来源:flags.go


示例3: StartIPC

func StartIPC(eth *eth.Ethereum, ctx *cli.Context) error {
	config := comms.IpcConfig{
		Endpoint: IpcSocketPath(ctx),
	}

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

	return comms.StartIpc(config, codec.JSON, initializer)
}
开发者ID:General-Beck,项目名称:go-ethereum,代码行数:17,代码来源:flags.go


示例4: StartIPC

func (app *EthereumApplication) StartIPC(ctx *cli.Context) error {
	eth := app.ethereum
	config := comms.IpcConfig{
		Endpoint: utils.IpcSocketPath(ctx),
	}

	initializer := func(conn net.Conn) (comms.Stopper, shared.EthereumApi, error) {
		fe := useragent.NewRemoteFrontend(conn, eth.AccountManager())
		xeth := xeth.NewFromApp(app, fe)
		ethApi := api.NewEthApi(xeth, eth, codec.JSON)
		personalApi := api.NewPersonalApi(xeth, eth, codec.JSON)
		web3Api := api.NewWeb3Api(xeth, codec.JSON)
		return xeth, api.Merge(ethApi, personalApi, web3Api), nil
	}

	return comms.StartIpc(config, codec.JSON, initializer)
}
开发者ID:zramsay,项目名称:geth-tmsp,代码行数:17,代码来源:eth.go


示例5: StartRPC

// Start the local RPC server
func (app *EthereumApplication) StartRPC(ctx *cli.Context) error {
	config := comms.HttpConfig{
		ListenAddress: ctx.GlobalString(utils.RPCListenAddrFlag.Name),
		ListenPort:    uint(ctx.GlobalInt(utils.RPCPortFlag.Name)),
		CorsDomain:    ctx.GlobalString(utils.RPCCORSDomainFlag.Name),
	}

	eth := app.ethereum
	xeth := xeth.NewFromApp(app, nil)
	codec := codec.JSON

	// We only run a few of the APIs.
	// For now, all block related functionality will fail (ie. only state!)
	// Eventually, replace with calls to tendermint core
	ethApi := api.NewEthApi(xeth, eth, codec)
	personalApi := api.NewPersonalApi(xeth, eth, codec)
	web3Api := api.NewWeb3Api(xeth, codec)
	return comms.StartHttp(config, codec, api.Merge(ethApi, personalApi, web3Api))
}
开发者ID:zramsay,项目名称:geth-tmsp,代码行数:20,代码来源:eth.go


示例6: newJSRE

func newJSRE(ethereum *eth.Ethereum, libPath, corsDomain string, client comms.EthereumClient, interactive bool, f xeth.Frontend) *jsre {
	js := &jsre{ethereum: ethereum, ps1: "> "}
	// set default cors domain used by startRpc from CLI flag
	js.corsDomain = corsDomain
	if f == nil {
		f = js
	}
	js.ds = docserver.New("/")
	js.xeth = xeth.New(ethereum, f)
	js.wait = js.xeth.UpdateState()
	js.client = client
	if clt, ok := js.client.(*comms.InProcClient); ok {
		if offeredApis, err := api.ParseApiString(shared.AllApis, codec.JSON, js.xeth, ethereum); err == nil {
			clt.Initialize(api.Merge(offeredApis...))
		}
	}

	// update state in separare forever blocks
	js.re = re.New(libPath)
	if err := js.apiBindings(f); err != nil {
		utils.Fatalf("Unable to connect - %v", err)
	}

	if !liner.TerminalSupported() || !interactive {
		js.prompter = dumbterm{bufio.NewReader(os.Stdin)}
	} else {
		lr := liner.NewLiner()
		js.withHistory(func(hist *os.File) { lr.ReadHistory(hist) })
		lr.SetCtrlCAborts(true)
		js.loadAutoCompletion()
		lr.SetWordCompleter(apiWordCompleter)
		lr.SetTabCompletionStyle(liner.TabPrints)
		js.prompter = lr
		js.atexit = func() {
			js.withHistory(func(hist *os.File) { hist.Truncate(0); lr.WriteHistory(hist) })
			lr.Close()
			close(js.wait)
		}
	}
	return js
}
开发者ID:RepublicMaster,项目名称:go-ethereum,代码行数:41,代码来源:js.go


示例7: apiBindings

func (js *jsre) apiBindings(f xeth.Frontend) error {
	apis, err := js.supportedApis()
	if err != nil {
		return err
	}

	apiNames := make([]string, 0, len(apis))
	for a, _ := range apis {
		apiNames = append(apiNames, a)
	}

	apiImpl, err := api.ParseApiString(strings.Join(apiNames, ","), codec.JSON, js.xeth, js.ethereum)
	if err != nil {
		utils.Fatalf("Unable to determine supported api's: %v", err)
	}

	jeth := rpc.NewJeth(api.Merge(apiImpl...), js.re, js.client)
	js.re.Set("jeth", struct{}{})
	t, _ := js.re.Get("jeth")
	jethObj := t.Object()

	jethObj.Set("send", jeth.Send)
	jethObj.Set("sendAsync", jeth.Send)

	err = js.re.Compile("bignumber.js", re.BigNumber_JS)
	if err != nil {
		utils.Fatalf("Error loading bignumber.js: %v", err)
	}

	err = js.re.Compile("ethereum.js", re.Web3_JS)
	if err != nil {
		utils.Fatalf("Error loading web3.js: %v", err)
	}

	_, err = js.re.Eval("var web3 = require('web3');")
	if err != nil {
		utils.Fatalf("Error requiring web3: %v", err)
	}

	_, err = js.re.Eval("web3.setProvider(jeth)")
	if err != nil {
		utils.Fatalf("Error setting web3 provider: %v", err)
	}

	// load only supported API's in javascript runtime
	shortcuts := "var eth = web3.eth; "
	for _, apiName := range apiNames {
		if apiName == shared.Web3ApiName {
			continue // manually mapped
		}

		if err = js.re.Compile(fmt.Sprintf("%s.js", apiName), api.Javascript(apiName)); err == nil {
			shortcuts += fmt.Sprintf("var %s = web3.%s; ", apiName, apiName)
		} else {
			utils.Fatalf("Error loading %s.js: %v", apiName, err)
		}
	}

	_, err = js.re.Eval(shortcuts)

	if err != nil {
		utils.Fatalf("Error setting namespaces: %v", err)
	}

	js.re.Eval(`var GlobalRegistrar = eth.contract(` + registrar.GlobalRegistrarAbi + `);	 registrar = GlobalRegistrar.at("` + registrar.GlobalRegistrarAddr + `");`)
	return nil
}
开发者ID:RepublicMaster,项目名称:go-ethereum,代码行数:67,代码来源:js.go



注:本文中的github.com/ethereum/go-ethereum/rpc/api.Merge函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang codec.Codec类代码示例发布时间:2022-05-23
下一篇:
Golang rpc.HexNumber类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap