예제 #1
0
func (self *XEth) AllLogs(earliest, latest int64, skip, max int, address []string, topics [][]string) vm.Logs {
	filter := filters.New(self.backend.ChainDb())
	filter.SetBeginBlock(earliest)
	filter.SetEndBlock(latest)
	filter.SetAddresses(cAddress(address))
	filter.SetTopics(cTopics(topics))

	return filter.Find()
}
예제 #2
0
func (self *XEth) NewTransactionFilter() int {
	self.transactionMu.Lock()
	defer self.transactionMu.Unlock()

	filter := filters.New(self.backend.ChainDb())
	id := self.filterManager.Add(filter)
	self.transactionQueue[id] = &hashQueue{timeout: time.Now()}

	filter.TransactionCallback = func(tx *types.Transaction) {
		self.transactionMu.Lock()
		defer self.transactionMu.Unlock()

		if queue := self.transactionQueue[id]; queue != nil {
			queue.add(tx.Hash())
		}
	}
	return id
}
예제 #3
0
func (self *XEth) NewBlockFilter() int {
	self.blockMu.Lock()
	defer self.blockMu.Unlock()

	filter := filters.New(self.backend.ChainDb())
	id := self.filterManager.Add(filter)
	self.blockQueue[id] = &hashQueue{timeout: time.Now()}

	filter.BlockCallback = func(block *types.Block, logs vm.Logs) {
		self.blockMu.Lock()
		defer self.blockMu.Unlock()

		if queue := self.blockQueue[id]; queue != nil {
			queue.add(block.Hash())
		}
	}
	return id
}
예제 #4
0
func (self *XEth) NewLogFilter(earliest, latest int64, skip, max int, address []string, topics [][]string) int {
	self.logMu.Lock()
	defer self.logMu.Unlock()

	filter := filters.New(self.backend.ChainDb())
	id := self.filterManager.Add(filter)
	self.logQueue[id] = &logQueue{timeout: time.Now()}

	filter.SetBeginBlock(earliest)
	filter.SetEndBlock(latest)
	filter.SetAddresses(cAddress(address))
	filter.SetTopics(cTopics(topics))
	filter.LogsCallback = func(logs vm.Logs) {
		self.logMu.Lock()
		defer self.logMu.Unlock()

		if queue := self.logQueue[id]; queue != nil {
			queue.add(logs...)
		}
	}

	return id
}