// 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(ethereum *eth.Ethereum, frontend Frontend) *XEth { xeth := &XEth{ backend: ethereum, frontend: frontend, quit: make(chan struct{}), filterManager: filter.NewFilterManager(ethereum.EventMux()), logQueue: make(map[int]*logQueue), blockQueue: make(map[int]*hashQueue), transactionQueue: make(map[int]*hashQueue), messages: make(map[int]*whisperFilter), agent: miner.NewRemoteAgent(), } if ethereum.Whisper() != nil { xeth.whisper = NewWhisper(ethereum.Whisper()) } ethereum.Miner().Register(xeth.agent) if frontend == nil { xeth.frontend = dummyFrontend{} } xeth.state = NewState(xeth, xeth.backend.ChainManager().TransState()) go xeth.start() go xeth.filterManager.Start() return xeth }
// 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(eth *eth.Ethereum, frontend Frontend) *XEth { xeth := &XEth{ backend: eth, frontend: frontend, whisper: NewWhisper(eth.Whisper()), quit: make(chan struct{}), filterManager: filter.NewFilterManager(eth.EventMux()), logs: make(map[int]*logFilter), messages: make(map[int]*whisperFilter), agent: miner.NewRemoteAgent(), } eth.Miner().Register(xeth.agent) if frontend == nil { xeth.frontend = dummyFrontend{} } xeth.state = NewState(xeth, xeth.backend.ChainManager().TransState()) go xeth.start() go xeth.filterManager.Start() return xeth }
// New creates a new Ether APIs instance, connects with it to the Ethereum network // via an embedded Geth instance and attaches an RPC in-process endpoint to it. func New(datadir string, network geth.EthereumNetwork, address common.Address) (*EtherAPIs, error) { // Create a Geth instance and boot it up client, err := geth.New(datadir, network) if err != nil { return nil, err } if err := client.Start(); err != nil { return nil, err } // Retrieve the underlying ethereum service and attach global RPC interface var ethereum *eth.Ethereum if err := client.Stack().Service(ðereum); err != nil { return nil, err } api, err := client.Attach() if err != nil { return nil, err } // Assemble an interface around the consensus contract contract, err := contract.New(ethereum.ChainDb(), ethereum.EventMux(), ethereum.BlockChain(), ethereum.Miner().PendingState) if err != nil { return nil, err } // Assemble and return the Ether APIs instance return &EtherAPIs{ client: client, ethereum: ethereum, eventmux: client.Stack().EventMux(), rpcapi: api, contract: contract, }, nil }