// 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: filters.NewFilterSystem(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(), gpo: eth.NewGasPriceOracle(ethereum), } if ethereum.Whisper() != nil { xeth.whisper = NewWhisper(ethereum.Whisper()) } ethereum.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 }
// New initialises a new abi and returns the contract. It does not // deploy the contract, hence the name. func New(db ethdb.Database, mux *event.TypeMux, blockchain *core.BlockChain, callState func() *state.StateDB) (*Contract, error) { contract := Contract{ blockchain: blockchain, subs: make(map[common.Hash]*Subscription), filters: filters.NewFilterSystem(mux), callState: callState, } contract.callKey, _ = crypto.GenerateKey() var err error contract.abi, err = abi.JSON(strings.NewReader(jsonAbi)) if err != nil { return nil, err } return &contract, nil }