diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-06 11:48:03 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-06 11:48:03 +0800 |
commit | 03dc760ca07682a61ed547c11a1c650a324a1b14 (patch) | |
tree | 645603633e069f5f701db6f6bac8f9c9a971c731 /rpc/api.go | |
parent | ef9d825cfaa274a4063bf7dcbf19c033e29b90aa (diff) | |
download | dexon-03dc760ca07682a61ed547c11a1c650a324a1b14.tar.gz dexon-03dc760ca07682a61ed547c11a1c650a324a1b14.tar.zst dexon-03dc760ca07682a61ed547c11a1c650a324a1b14.zip |
Tidy
Diffstat (limited to 'rpc/api.go')
-rw-r--r-- | rpc/api.go | 90 |
1 files changed, 58 insertions, 32 deletions
diff --git a/rpc/api.go b/rpc/api.go index 35c9c51d7..ded91def1 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -124,24 +124,24 @@ func (self *EthereumApi) stop() { close(self.quit) } -func (self *EthereumApi) Register(args string, reply *interface{}) error { - self.regmut.Lock() - defer self.regmut.Unlock() +// func (self *EthereumApi) Register(args string, reply *interface{}) error { +// self.regmut.Lock() +// defer self.regmut.Unlock() - if _, ok := self.register[args]; ok { - self.register[args] = nil // register with empty - } - return nil -} +// if _, ok := self.register[args]; ok { +// self.register[args] = nil // register with empty +// } +// return nil +// } -func (self *EthereumApi) Unregister(args string, reply *interface{}) error { - self.regmut.Lock() - defer self.regmut.Unlock() +// func (self *EthereumApi) Unregister(args string, reply *interface{}) error { +// self.regmut.Lock() +// defer self.regmut.Unlock() - delete(self.register, args) +// delete(self.register, args) - return nil -} +// return nil +// } // func (self *EthereumApi) WatchTx(args string, reply *interface{}) error { // self.regmut.Lock() @@ -574,24 +574,6 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error case "eth_getWork": case "eth_submitWork": return errNotImplemented - // case "eth_register": - // args, err := req.ToRegisterArgs() - // if err != nil { - // return err - // } - // return p.Register(args, reply) - // case "eth_unregister": - // args, err := req.ToRegisterArgs() - // if err != nil { - // return err - // } - // return p.Unregister(args, reply) - // case "eth_watchTx": - // args, err := req.ToWatchTxArgs() - // if err != nil { - // return err - // } - // return p.WatchTx(args, reply) case "db_put": args := new(DbArgs) if err := json.Unmarshal(req.Params, &args); err != nil { @@ -643,6 +625,24 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error return p.WhisperMessages(args.Id, reply) case "client_version": *reply = p.eth.GetClientVersion() + // case "eth_register": + // args, err := req.ToRegisterArgs() + // if err != nil { + // return err + // } + // return p.Register(args, reply) + // case "eth_unregister": + // args, err := req.ToRegisterArgs() + // if err != nil { + // return err + // } + // return p.Unregister(args, reply) + // case "eth_watchTx": + // args, err := req.ToWatchTxArgs() + // if err != nil { + // return err + // } + // return p.WatchTx(args, reply) default: return NewErrorWithMessage(errNotImplemented, req.Method) } @@ -675,3 +675,29 @@ func t(f ui.Frontend) { t, _ := ret.Get(0) fmt.Println("return:", t) } + +func toFilterOptions(options *FilterOptions) core.FilterOptions { + var opts core.FilterOptions + + // Convert optional address slice/string to byte slice + if str, ok := options.Address.(string); ok { + opts.Address = [][]byte{fromHex(str)} + } else if slice, ok := options.Address.([]interface{}); ok { + bslice := make([][]byte, len(slice)) + for i, addr := range slice { + if saddr, ok := addr.(string); ok { + bslice[i] = fromHex(saddr) + } + } + opts.Address = bslice + } + + opts.Earliest = options.Earliest + opts.Latest = options.Latest + opts.Topics = make([][]byte, len(options.Topic)) + for i, topic := range options.Topic { + opts.Topics[i] = fromHex(topic) + } + + return opts +} |