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 | |
parent | ef9d825cfaa274a4063bf7dcbf19c033e29b90aa (diff) | |
download | dexon-03dc760ca07682a61ed547c11a1c650a324a1b14.tar.gz dexon-03dc760ca07682a61ed547c11a1c650a324a1b14.tar.zst dexon-03dc760ca07682a61ed547c11a1c650a324a1b14.zip |
Tidy
Diffstat (limited to 'rpc')
-rw-r--r-- | rpc/api.go | 90 | ||||
-rw-r--r-- | rpc/args.go | 28 | ||||
-rw-r--r-- | rpc/messages.go | 2 |
3 files changed, 58 insertions, 62 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 +} diff --git a/rpc/args.go b/rpc/args.go index 3284a232a..f56051242 100644 --- a/rpc/args.go +++ b/rpc/args.go @@ -5,7 +5,6 @@ import ( "encoding/json" "math/big" - "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/ethutil" ) @@ -346,32 +345,6 @@ func (args *FilterOptions) UnmarshalJSON(b []byte) (err error) { return nil } -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 -} - // type FilterChangedArgs struct { // n int // } @@ -530,7 +503,6 @@ type WhisperFilterArgs struct { To string From string Topics []string - Fn func() } func (args *WhisperFilterArgs) UnmarshalJSON(b []byte) (err error) { diff --git a/rpc/messages.go b/rpc/messages.go index 4f5b00990..a3ebbf330 100644 --- a/rpc/messages.go +++ b/rpc/messages.go @@ -20,8 +20,6 @@ import ( "encoding/json" "errors" "fmt" - - "github.com/ethereum/go-ethereum/xeth" ) var ( |