@@ -176,7 +176,7 @@ func (self *EthereumApi) UninstallFilter(id int, reply *interface{}) error {
176176 return nil
177177}
178178
179- func (self * EthereumApi ) NewFilterString (args string , reply * interface {}) error {
179+ func (self * EthereumApi ) NewFilterString (args * FilterStringArgs , reply * interface {}) error {
180180 var id int
181181 filter := core .NewFilter (self .xeth ().Backend ())
182182
@@ -186,10 +186,14 @@ func (self *EthereumApi) NewFilterString(args string, reply *interface{}) error
186186
187187 self .logs [id ].add (& state.StateLog {})
188188 }
189- if args == "pending" {
189+
190+ switch args .Word {
191+ case "pending" :
190192 filter .PendingCallback = callback
191- } else if args == "chain" {
193+ case "latest" :
192194 filter .BlockCallback = callback
195+ default :
196+ return NewValidationError ("Word" , "Must be `latest` or `pending`" )
193197 }
194198
195199 id = self .filterManager .InstallFilter (filter )
@@ -477,6 +481,10 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
477481 return err
478482 }
479483 * reply = toHex (crypto .Sha3 (fromHex (args .Data )))
484+ case "web3_clientVersion" :
485+ * reply = p .xeth ().Backend ().Version ()
486+ case "net_version" :
487+ return NewNotImplementedError (req .Method )
480488 case "net_listening" :
481489 * reply = p .xeth ().IsListening ()
482490 case "net_peerCount" :
@@ -578,7 +586,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
578586 }
579587 return p .Call (args , reply )
580588 case "eth_flush" :
581- return errNotImplemented
589+ return NewNotImplementedError ( req . Method )
582590 case "eth_getBlockByHash" :
583591 args := new (GetBlockByHashArgs )
584592 if err := json .Unmarshal (req .Params , & args ); err != nil {
@@ -618,7 +626,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
618626 return err
619627 }
620628 if args .Index > int64 (len (v .Transactions )) || args .Index < 0 {
621- return NewErrorWithMessage ( errDecodeArgs , "Transaction index does not exist" )
629+ return NewValidationError ( "Index" , "does not exist" )
622630 }
623631 * reply = v .Transactions [args .Index ]
624632 case "eth_getTransactionByBlockNumberAndIndex" :
@@ -632,7 +640,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
632640 return err
633641 }
634642 if args .Index > int64 (len (v .Transactions )) || args .Index < 0 {
635- return NewErrorWithMessage ( errDecodeArgs , "Transaction index does not exist" )
643+ return NewValidationError ( "Index" , "does not exist" )
636644 }
637645 * reply = v .Transactions [args .Index ]
638646 case "eth_getUncleByBlockHashAndIndex" :
@@ -646,7 +654,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
646654 return err
647655 }
648656 if args .Index > int64 (len (v .Uncles )) || args .Index < 0 {
649- return NewErrorWithMessage ( errDecodeArgs , "Uncle index does not exist" )
657+ return NewValidationError ( "Index" , "does not exist" )
650658 }
651659
652660 uncle , err := p .GetBlockByHash (toHex (v .Uncles [args .Index ]), false )
@@ -665,7 +673,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
665673 return err
666674 }
667675 if args .Index > int64 (len (v .Uncles )) || args .Index < 0 {
668- return NewErrorWithMessage ( errDecodeArgs , "Uncle index does not exist" )
676+ return NewValidationError ( "Index" , "does not exist" )
669677 }
670678
671679 uncle , err := p .GetBlockByHash (toHex (v .Uncles [args .Index ]), false )
@@ -675,10 +683,8 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
675683 * reply = uncle
676684 case "eth_getCompilers" :
677685 return p .GetCompilers (reply )
678- case "eth_compileSolidity" :
679- case "eth_compileLLL" :
680- case "eth_compileSerpent" :
681- return errNotImplemented
686+ case "eth_compileSolidity" , "eth_compileLLL" , "eth_compileSerpent" :
687+ return NewNotImplementedError (req .Method )
682688 case "eth_newFilter" :
683689 args := new (FilterOptions )
684690 if err := json .Unmarshal (req .Params , & args ); err != nil {
@@ -690,7 +696,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
690696 if err := json .Unmarshal (req .Params , & args ); err != nil {
691697 return err
692698 }
693- return p .NewFilterString (args . Word , reply )
699+ return p .NewFilterString (args , reply )
694700 case "eth_uninstallFilter" :
695701 args := new (FilterIdArgs )
696702 if err := json .Unmarshal (req .Params , & args ); err != nil {
@@ -715,21 +721,22 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
715721 return err
716722 }
717723 return p .AllLogs (args , reply )
718- case "eth_getWork" :
719- case "eth_submitWork" :
720- return errNotImplemented
721- case "db_put" :
724+ case "eth_getWork" , "eth_submitWork" :
725+ return NewNotImplementedError (req .Method )
726+ case "db_putString" :
722727 args := new (DbArgs )
723728 if err := json .Unmarshal (req .Params , & args ); err != nil {
724729 return err
725730 }
726731 return p .DbPut (args , reply )
727- case "db_get " :
732+ case "db_getString " :
728733 args := new (DbArgs )
729734 if err := json .Unmarshal (req .Params , & args ); err != nil {
730735 return err
731736 }
732737 return p .DbGet (args , reply )
738+ case "db_putHex" , "db_getHex" :
739+ return NewNotImplementedError (req .Method )
733740 case "shh_post" :
734741 args := new (WhisperMessageArgs )
735742 if err := json .Unmarshal (req .Params , & args ); err != nil {
@@ -744,9 +751,8 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
744751 return err
745752 }
746753 return p .HasWhisperIdentity (args .Identity , reply )
747- case "shh_newGroup" :
748- case "shh_addToGroup" :
749- return errNotImplemented
754+ case "shh_newGroup" , "shh_addToGroup" :
755+ return NewNotImplementedError (req .Method )
750756 case "shh_newFilter" :
751757 args := new (WhisperFilterArgs )
752758 if err := json .Unmarshal (req .Params , & args ); err != nil {
@@ -790,7 +796,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
790796 // }
791797 // return p.WatchTx(args, reply)
792798 default :
793- return NewErrorWithMessage ( errNotImplemented , req .Method )
799+ return NewNotImplementedError ( req .Method )
794800 }
795801
796802 rpclogger .DebugDetailf ("Reply: %T %s" , reply , reply )
0 commit comments