Пример #1
0
// 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
}
Пример #2
0
func (self *XEth) DefaultGasPrice() *big.Int {
	if self.gpo == nil {
		self.gpo = eth.NewGasPriceOracle(self.backend)
	}
	return self.gpo.SuggestPrice()
}