aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-05-06 23:51:32 +0800
committerobscuren <geffobscura@gmail.com>2015-05-07 20:44:32 +0800
commit7e160a677d1590f97708a0d297f978a99977d398 (patch)
tree9cd71bfad14c06c381e3518f6fb11464225271ab /rpc
parent97c37356fdcfac8b704c3d75b33e322a737c4e55 (diff)
downloaddexon-7e160a677d1590f97708a0d297f978a99977d398.tar
dexon-7e160a677d1590f97708a0d297f978a99977d398.tar.gz
dexon-7e160a677d1590f97708a0d297f978a99977d398.tar.bz2
dexon-7e160a677d1590f97708a0d297f978a99977d398.tar.lz
dexon-7e160a677d1590f97708a0d297f978a99977d398.tar.xz
dexon-7e160a677d1590f97708a0d297f978a99977d398.tar.zst
dexon-7e160a677d1590f97708a0d297f978a99977d398.zip
xeth, core, event/filter, rpc: new block and transaction filters
Diffstat (limited to 'rpc')
-rw-r--r--rpc/api.go23
-rw-r--r--rpc/responses.go11
2 files changed, 27 insertions, 7 deletions
diff --git a/rpc/api.go b/rpc/api.go
index b79a1306e..a3312075b 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -322,14 +322,13 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
return err
}
- id := api.xeth().RegisterFilter(args.Earliest, args.Latest, args.Skip, args.Max, args.Address, args.Topics)
+ id := api.xeth().NewLogFilter(args.Earliest, args.Latest, args.Skip, args.Max, args.Address, args.Topics)
*reply = newHexNum(big.NewInt(int64(id)).Bytes())
+
case "eth_newBlockFilter":
- args := new(FilterStringArgs)
- if err := json.Unmarshal(req.Params, &args); err != nil {
- return err
- }
- *reply = newHexNum(api.xeth().NewFilterString(args.Word))
+ *reply = newHexNum(api.xeth().NewBlockFilter())
+ case "eth_transactionFilter":
+ *reply = newHexNum(api.xeth().NewTransactionFilter())
case "eth_uninstallFilter":
args := new(FilterIdArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
@@ -341,7 +340,17 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
if err := json.Unmarshal(req.Params, &args); err != nil {
return err
}
- *reply = NewLogsRes(api.xeth().FilterChanged(args.Id))
+
+ switch api.xeth().GetFilterType(args.Id) {
+ case xeth.BlockFilterTy:
+ *reply = NewHashesRes(api.xeth().BlockFilterChanged(args.Id))
+ case xeth.TransactionFilterTy:
+ *reply = NewHashesRes(api.xeth().TransactionFilterChanged(args.Id))
+ case xeth.LogFilterTy:
+ *reply = NewLogsRes(api.xeth().LogFilterChanged(args.Id))
+ default:
+ *reply = []string{} // reply empty string slice
+ }
case "eth_getFilterLogs":
args := new(FilterIdArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
diff --git a/rpc/responses.go b/rpc/responses.go
index 884b7e69b..9fdf60c02 100644
--- a/rpc/responses.go
+++ b/rpc/responses.go
@@ -3,6 +3,7 @@ package rpc
import (
"encoding/json"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
)
@@ -303,3 +304,13 @@ func NewLogsRes(logs state.Logs) (ls []LogRes) {
return
}
+
+func NewHashesRes(hs []common.Hash) []string {
+ hashes := make([]string, len(hs))
+
+ for i, hash := range hs {
+ hashes[i] = hash.Hex()
+ }
+
+ return hashes
+}