示例#1
0
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...))
}
示例#2
0
文件: eth.go 项目: zramsay/geth-tmsp
// 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))
}
示例#3
0
func (self *adminApi) StartRPC(req *shared.Request) (interface{}, error) {
	args := new(StartRPCArgs)
	if err := self.coder.Decode(req.Params, &args); err != nil {
		return nil, shared.NewDecodeParamError(err.Error())
	}

	cfg := comms.HttpConfig{
		ListenAddress: args.ListenAddress,
		ListenPort:    args.ListenPort,
		CorsDomain:    args.CorsDomain,
	}

	apis, err := ParseApiString(args.Apis, self.codec, self.xeth, self.ethereum)
	if err != nil {
		return false, err
	}

	err = comms.StartHttp(cfg, self.codec, Merge(apis...))
	if err == nil {
		return true, nil
	}
	return false, err
}