aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-02-06 03:55:03 +0800
committerobscuren <geffobscura@gmail.com>2015-02-06 03:55:03 +0800
commitc64852dbccd0c8eb57cab994aefd0243c65b351b (patch)
tree84104fd5d12afbd0c3f53311d9b000d22e8935c3 /rpc
parentbcacaaa4f418d51751cd841a22a8455b165f2375 (diff)
downloaddexon-c64852dbccd0c8eb57cab994aefd0243c65b351b.tar
dexon-c64852dbccd0c8eb57cab994aefd0243c65b351b.tar.gz
dexon-c64852dbccd0c8eb57cab994aefd0243c65b351b.tar.bz2
dexon-c64852dbccd0c8eb57cab994aefd0243c65b351b.tar.lz
dexon-c64852dbccd0c8eb57cab994aefd0243c65b351b.tar.xz
dexon-c64852dbccd0c8eb57cab994aefd0243c65b351b.tar.zst
dexon-c64852dbccd0c8eb57cab994aefd0243c65b351b.zip
pending / chain event
Diffstat (limited to 'rpc')
-rw-r--r--rpc/message.go16
-rw-r--r--rpc/packages.go26
2 files changed, 41 insertions, 1 deletions
diff --git a/rpc/message.go b/rpc/message.go
index e110bdf3e..78dc6e2ff 100644
--- a/rpc/message.go
+++ b/rpc/message.go
@@ -205,7 +205,6 @@ func (req *RpcRequest) ToFilterArgs() (*FilterOptions, error) {
if len(req.Params) < 1 {
return nil, NewErrorResponse(ErrorArguments)
}
- fmt.Println("FILTER PARAMS", string(req.Params[0]))
args := new(FilterOptions)
r := bytes.NewReader(req.Params[0])
@@ -217,6 +216,21 @@ func (req *RpcRequest) ToFilterArgs() (*FilterOptions, error) {
return args, nil
}
+func (req *RpcRequest) ToFilterStringArgs() (string, error) {
+ if len(req.Params) < 1 {
+ return "", NewErrorResponse(ErrorArguments)
+ }
+
+ var args string
+ err := json.Unmarshal(req.Params[0], &args)
+ if err != nil {
+ return "", NewErrorResponse(ErrorDecodeArgs)
+ }
+
+ rpclogger.DebugDetailf("%T %v", args, args)
+ return args, nil
+}
+
func (req *RpcRequest) ToFilterChangedArgs() (int, error) {
if len(req.Params) < 1 {
return 0, NewErrorResponse(ErrorArguments)
diff --git a/rpc/packages.go b/rpc/packages.go
index 047bbda9a..ac3127356 100644
--- a/rpc/packages.go
+++ b/rpc/packages.go
@@ -32,6 +32,7 @@ import (
"sync"
"github.com/ethereum/go-ethereum/core"
+ "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethutil"
@@ -88,6 +89,25 @@ func (self *EthereumApi) NewFilter(args *FilterOptions, reply *interface{}) erro
return nil
}
+func (self *EthereumApi) NewFilterString(args string, reply *interface{}) error {
+ var id int
+ filter := core.NewFilter(self.xeth.Backend())
+
+ callback := func(block *types.Block) {
+ self.logs[id] = append(self.logs[id], &state.StateLog{})
+ }
+ if args == "pending" {
+ filter.PendingCallback = callback
+ } else if args == "chain" {
+ filter.BlockCallback = callback
+ }
+
+ id = self.filterManager.InstallFilter(filter)
+ *reply = id
+
+ return nil
+}
+
func (self *EthereumApi) FilterChanged(id int, reply *interface{}) error {
self.logMut.RLock()
defer self.logMut.RUnlock()
@@ -389,6 +409,12 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err
}
return p.NewFilter(args, reply)
+ case "eth_newFilterString":
+ args, err := req.ToFilterStringArgs()
+ if err != nil {
+ return err
+ }
+ return p.NewFilterString(args, reply)
case "eth_changed":
args, err := req.ToFilterChangedArgs()
if err != nil {