当前位置: 首页>>代码示例>>Golang>>正文


Golang xeth.New函数代码示例

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


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

示例1: StartRPC

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

	xeth := xeth.New(eth, nil)
	return rpc.Start(xeth, config)
}
开发者ID:CedarLogic,项目名称:go-ethereum,代码行数:10,代码来源:flags.go

示例2: testInit

func testInit(t *testing.T) (self *testFrontend) {
	// initialise and start minimal ethereum stack
	ethereum, err := testEth(t)
	if err != nil {
		t.Errorf("error creating ethereum: %v", err)
		return
	}
	err = ethereum.Start()
	if err != nil {
		t.Errorf("error starting ethereum: %v", err)
		return
	}

	// mock frontend
	self = &testFrontend{t: t, ethereum: ethereum}
	self.xeth = xe.New(ethereum, self)
	self.wait = self.xeth.UpdateState()
	addr, _ := self.ethereum.Etherbase()

	// initialise the registry contracts
	reg := registrar.New(self.xeth)
	var registrarTxhash, hashRegTxhash, urlHintTxhash string
	registrarTxhash, err = reg.SetGlobalRegistrar("", addr)
	if err != nil {
		t.Errorf("error creating GlobalRegistrar: %v", err)
	}

	hashRegTxhash, err = reg.SetHashReg("", addr)
	if err != nil {
		t.Errorf("error creating HashReg: %v", err)
	}
	urlHintTxhash, err = reg.SetUrlHint("", addr)
	if err != nil {
		t.Errorf("error creating UrlHint: %v", err)
	}
	if !processTxs(self, t, 3) {
		t.Errorf("error mining txs")
	}
	_ = registrarTxhash
	_ = hashRegTxhash
	_ = urlHintTxhash

	/* TODO:
	* lookup receipt and contract addresses by tx hash
	* name registration for HashReg and UrlHint addresses
	* mine those transactions
	* then set once more SetHashReg SetUrlHint
	 */

	return

}
开发者ID:NikonMcFly,项目名称:go-ethereum,代码行数:52,代码来源:natspec_e2e_test.go

示例3: NewUiLib

func NewUiLib(engine *qml.Engine, eth *eth.Ethereum, assetPath, libPath string) *UiLib {
	x := xeth.New(eth, nil)
	lib := &UiLib{
		XEth:            x,
		engine:          engine,
		eth:             eth,
		assetPath:       assetPath,
		filterCallbacks: make(map[int][]int),
	}
	lib.filterManager = filter.NewFilterManager(eth.EventMux())
	go lib.filterManager.Start()

	return lib
}
开发者ID:CedarLogic,项目名称:go-ethereum,代码行数:14,代码来源:ui_lib.go

示例4: 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

示例5: 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

示例6: 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

示例7: NewWindow

// Create GUI, but doesn't start it
func NewWindow(ethereum *eth.Ethereum) *Gui {
	db, err := ethdb.NewLDBDatabase(path.Join(ethereum.DataDir, "tx_database"))
	if err != nil {
		panic(err)
	}

	xeth := xeth.New(ethereum, nil)
	gui := &Gui{eth: ethereum,
		txDb:          db,
		xeth:          xeth,
		open:          false,
		plugins:       make(map[string]plugin),
		serviceEvents: make(chan ServEv, 1),
	}
	data, _ := ioutil.ReadFile(path.Join(ethereum.DataDir, "plugins.json"))
	json.Unmarshal(data, &gui.plugins)

	return gui
}
开发者ID:CedarLogic,项目名称:go-ethereum,代码行数:20,代码来源:gui.go

示例8: 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

示例9: testInit

func testInit(t *testing.T) (self *testFrontend) {

	core.GenesisData = []byte(`{
	"` + testAccount + `": {"balance": "` + testBalance + `"}
	}`)

	ethereum, err := testEth(t)
	if err != nil {
		t.Errorf("error creating ethereum: %v", err)
		return
	}
	err = ethereum.Start()
	if err != nil {
		t.Errorf("error starting ethereum: %v", err)
		return
	}

	self = &testFrontend{t: t, ethereum: ethereum}
	self.xeth = xe.New(ethereum, self)
	self.api = rpc.NewEthereumApi(self.xeth)

	addr := self.xeth.Coinbase()
	self.coinbase = addr
	if addr != "0x"+testAccount {
		t.Errorf("CoinBase %v does not match TestAccount 0x%v", addr, testAccount)
	}
	t.Logf("CoinBase is %v", addr)

	balance := self.xeth.BalanceAt(testAccount)
	/*if balance != core.TestBalance {
		t.Errorf("Balance %v does not match TestBalance %v", balance, core.TestBalance)
	}*/
	t.Logf("Balance is %v", balance)

	self.stateDb = self.ethereum.ChainManager().State().Copy()

	return

}
开发者ID:CedarLogic,项目名称:go-ethereum,代码行数:39,代码来源:natspec_e2e_test.go

示例10: startRPC

func (js *jsre) startRPC(call otto.FunctionCall) otto.Value {
	addr, err := call.Argument(0).ToString()
	if err != nil {
		fmt.Println(err)
		return otto.FalseValue()
	}

	port, err := call.Argument(1).ToInteger()
	if err != nil {
		fmt.Println(err)
		return otto.FalseValue()
	}

	corsDomain := js.corsDomain
	if len(call.ArgumentList) > 2 {
		corsDomain, err = call.Argument(2).ToString()
		if err != nil {
			fmt.Println(err)
			return otto.FalseValue()
		}
	}

	config := rpc.RpcConfig{
		ListenAddress: addr,
		ListenPort:    uint(port),
		CorsDomain:    corsDomain,
	}

	xeth := xeth.New(js.ethereum, nil)
	err = rpc.Start(xeth, config)

	if err != nil {
		fmt.Printf(err.Error())
		return otto.FalseValue()
	}

	return otto.TrueValue()
}
开发者ID:CedarLogic,项目名称:go-ethereum,代码行数:38,代码来源:admin.go

示例11: newJSRE

func newJSRE(ethereum *eth.Ethereum, libPath string, interactive bool, corsDomain string) *jsre {
	js := &jsre{ethereum: ethereum, ps1: "> "}
	// set default cors domain used by startRpc from CLI flag
	js.corsDomain = corsDomain
	js.xeth = xeth.New(ethereum, js)
	js.re = re.New(libPath)
	js.apiBindings()
	js.adminBindings()

	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.prompter = lr
		js.atexit = func() {
			js.withHistory(func(hist *os.File) { hist.Truncate(0); lr.WriteHistory(hist) })
			lr.Close()
		}
	}
	return js
}
开发者ID:CedarLogic,项目名称:go-ethereum,代码行数:23,代码来源:js.go

示例12: testInit

func testInit(t *testing.T) (self *testFrontend) {
	// initialise and start minimal ethereum stack
	ethereum, err := testEth(t)
	if err != nil {
		t.Errorf("error creating ethereum: %v", err)
		return
	}
	err = ethereum.Start(nil)
	if err != nil {
		t.Errorf("error starting ethereum: %v", err)
		return
	}

	// mock frontend
	self = &testFrontend{t: t, ethereum: ethereum}
	self.xeth = xe.New(nil, self)
	self.wait = self.xeth.UpdateState()
	addr, _ := self.ethereum.Etherbase()

	// initialise the registry contracts
	reg := registrar.New(self.xeth)
	registrar.GlobalRegistrarAddr = "0x0"

	var txG, txH, txU string
	txG, err = reg.SetGlobalRegistrar("", addr)
	if err != nil {
		t.Fatalf("error creating GlobalRegistrar: %v", err)
	}
	if !processTxs(self, t, 1) {
		t.Fatalf("error mining txs")
	}
	recG := self.xeth.GetTxReceipt(common.HexToHash(txG))
	if recG == nil {
		t.Fatalf("blockchain error creating GlobalRegistrar")
	}
	registrar.GlobalRegistrarAddr = recG.ContractAddress.Hex()

	txH, err = reg.SetHashReg("", addr)
	if err != nil {
		t.Errorf("error creating HashReg: %v", err)
	}
	if !processTxs(self, t, 1) {
		t.Errorf("error mining txs")
	}
	recH := self.xeth.GetTxReceipt(common.HexToHash(txH))
	if recH == nil {
		t.Fatalf("blockchain error creating HashReg")
	}
	registrar.HashRegAddr = recH.ContractAddress.Hex()

	txU, err = reg.SetUrlHint("", addr)
	if err != nil {
		t.Errorf("error creating UrlHint: %v", err)
	}
	if !processTxs(self, t, 1) {
		t.Errorf("error mining txs")
	}
	recU := self.xeth.GetTxReceipt(common.HexToHash(txU))
	if recU == nil {
		t.Fatalf("blockchain error creating UrlHint")
	}
	registrar.UrlHintAddr = recU.ContractAddress.Hex()

	return
}
开发者ID:Codzart,项目名称:go-ethereum,代码行数:65,代码来源:natspec_e2e_test.go


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