aboutsummaryrefslogtreecommitdiffstats
path: root/xeth/xeth.go
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-03-27 23:36:01 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-03-27 23:36:01 +0800
commit43d521e90e9516429dd0499ff88bf3f37ec78c48 (patch)
tree42e912588cd5a5effdf319a30a641600caf93186 /xeth/xeth.go
parent0ac346f7078dba597d60f991c32ddbfd7be167ba (diff)
downloaddexon-43d521e90e9516429dd0499ff88bf3f37ec78c48.tar
dexon-43d521e90e9516429dd0499ff88bf3f37ec78c48.tar.gz
dexon-43d521e90e9516429dd0499ff88bf3f37ec78c48.tar.bz2
dexon-43d521e90e9516429dd0499ff88bf3f37ec78c48.tar.lz
dexon-43d521e90e9516429dd0499ff88bf3f37ec78c48.tar.xz
dexon-43d521e90e9516429dd0499ff88bf3f37ec78c48.tar.zst
dexon-43d521e90e9516429dd0499ff88bf3f37ec78c48.zip
Decouple core from rpc
Diffstat (limited to 'xeth/xeth.go')
-rw-r--r--xeth/xeth.go36
1 files changed, 32 insertions, 4 deletions
diff --git a/xeth/xeth.go b/xeth/xeth.go
index 5bb271591..7e1548964 100644
--- a/xeth/xeth.go
+++ b/xeth/xeth.go
@@ -110,6 +110,24 @@ func (self *XEth) stop() {
close(self.quit)
}
+func cAddress(a []string) []common.Address {
+ bslice := make([]common.Address, len(a))
+ for i, addr := range a {
+ bslice[i] = common.HexToAddress(addr)
+ }
+ return bslice
+}
+
+func cTopics(t [][]string) [][]common.Hash {
+ topics := make([][]common.Hash, len(t))
+ for i, iv := range t {
+ for j, jv := range iv {
+ topics[i][j] = common.HexToHash(jv)
+ }
+ }
+ return topics
+}
+
func (self *XEth) DefaultGas() *big.Int { return defaultGas }
func (self *XEth) DefaultGasPrice() *big.Int { return defaultGasPrice }
@@ -301,10 +319,15 @@ func (self *XEth) SecretToAddress(key string) string {
return common.ToHex(pair.Address())
}
-func (self *XEth) RegisterFilter(args *core.FilterOptions) int {
+func (self *XEth) RegisterFilter(earliest, latest int64, skip, max int, address []string, topics [][]string) int {
var id int
filter := core.NewFilter(self.backend)
- filter.SetOptions(args)
+ filter.SetEarliestBlock(earliest)
+ filter.SetLatestBlock(latest)
+ filter.SetSkip(skip)
+ filter.SetMax(max)
+ filter.SetAddress(cAddress(address))
+ filter.SetTopics(cTopics(topics))
filter.LogsCallback = func(logs state.Logs) {
self.logMut.Lock()
defer self.logMut.Unlock()
@@ -380,9 +403,14 @@ func (self *XEth) Logs(id int) state.Logs {
return nil
}
-func (self *XEth) AllLogs(args *core.FilterOptions) state.Logs {
+func (self *XEth) AllLogs(earliest, latest int64, skip, max int, address []string, topics [][]string) state.Logs {
filter := core.NewFilter(self.backend)
- filter.SetOptions(args)
+ filter.SetEarliestBlock(earliest)
+ filter.SetLatestBlock(latest)
+ filter.SetSkip(skip)
+ filter.SetMax(max)
+ filter.SetAddress(cAddress(address))
+ filter.SetTopics(cTopics(topics))
return filter.Find()
}