From 7e160a677d1590f97708a0d297f978a99977d398 Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 6 May 2015 17:51:32 +0200 Subject: xeth, core, event/filter, rpc: new block and transaction filters --- rpc/api.go | 23 ++++++++++++++++------- rpc/responses.go | 11 +++++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) (limited to 'rpc') 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 +} -- cgit v1.2.3 From b3c9b66f2958bb09ecffdb7a8064121e3a27b989 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 7 May 2015 13:56:19 +0200 Subject: rpc: eth_transactionFilter => eth_newPendingTransactionFilter --- rpc/api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'rpc') diff --git a/rpc/api.go b/rpc/api.go index a3312075b..f75ae42c4 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -327,7 +327,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err case "eth_newBlockFilter": *reply = newHexNum(api.xeth().NewBlockFilter()) - case "eth_transactionFilter": + case "eth_newPendingTransactionFilter": *reply = newHexNum(api.xeth().NewTransactionFilter()) case "eth_uninstallFilter": args := new(FilterIdArgs) -- cgit v1.2.3