aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-03-05 22:58:46 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-03-05 22:58:46 +0800
commit90ceb5218cec788de83842e9b38d63af24af5ffd (patch)
tree177ab18283b0e659ab5bc3919d6f19d51113ebbd /rpc
parent15765517417001a8dffc1180d7621b4284f4443e (diff)
downloaddexon-90ceb5218cec788de83842e9b38d63af24af5ffd.tar
dexon-90ceb5218cec788de83842e9b38d63af24af5ffd.tar.gz
dexon-90ceb5218cec788de83842e9b38d63af24af5ffd.tar.bz2
dexon-90ceb5218cec788de83842e9b38d63af24af5ffd.tar.lz
dexon-90ceb5218cec788de83842e9b38d63af24af5ffd.tar.xz
dexon-90ceb5218cec788de83842e9b38d63af24af5ffd.tar.zst
dexon-90ceb5218cec788de83842e9b38d63af24af5ffd.zip
Update RPC methods
Re-order to match spec and explicitly list unimplemented methods
Diffstat (limited to 'rpc')
-rw-r--r--rpc/api.go199
1 files changed, 115 insertions, 84 deletions
diff --git a/rpc/api.go b/rpc/api.go
index d82432d79..d0181463d 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -344,8 +344,7 @@ func (p *EthereumApi) GetStorageAt(args *GetStorageArgs, reply *interface{}) err
}
func (p *EthereumApi) GetPeerCount(reply *interface{}) error {
- c := p.xeth().PeerCount()
- *reply = toHex(big.NewInt(int64(c)).Bytes())
+ *reply = p.xeth().PeerCount()
return nil
}
@@ -370,7 +369,7 @@ func (p *EthereumApi) GetIsMining(reply *interface{}) error {
}
func (p *EthereumApi) BlockNumber(reply *interface{}) error {
- *reply = toHex(p.xeth().Backend().ChainManager().CurrentBlock().Number().Bytes())
+ *reply = p.xeth().Backend().ChainManager().CurrentBlock().Number()
return nil
}
@@ -497,51 +496,68 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
// Spec at https://github.com/ethereum/wiki/wiki/Generic-JSON-RPC
rpclogger.DebugDetailf("%T %s", req.Params, req.Params)
switch req.Method {
+ case "web3_sha3":
+ args, err := req.ToSha3Args()
+ if err != nil {
+ return err
+ }
+ return p.Sha3(args, reply)
+ case "net_listening":
+ return p.GetIsListening(reply)
+ case "net_peerCount":
+ return p.GetPeerCount(reply)
case "eth_coinbase":
return p.GetCoinbase(reply)
case "eth_mining":
return p.GetIsMining(reply)
- case "eth_number":
- return p.BlockNumber(reply)
+ case "eth_gasPrice":
+ *reply = toHex(defaultGasPrice.Bytes())
+ return nil
case "eth_accounts":
return p.Accounts(reply)
- case "eth_countAt":
- args, err := req.ToGetTxCountArgs()
- if err != nil {
- return err
- }
- return p.GetTxCountAt(args, reply)
- case "eth_codeAt":
- args, err := req.ToGetCodeAtArgs()
- if err != nil {
- return err
- }
- return p.GetCodeAt(args, reply)
- case "eth_balanceAt":
+ case "eth_blockNumber":
+ return p.BlockNumber(reply)
+ case "eth_getBalance":
+ // TODO handle defaultBlock
args, err := req.ToGetBalanceArgs()
if err != nil {
return err
}
return p.GetBalanceAt(args, reply)
- case "eth_stateAt":
+ case "eth_getStorage":
+ // TODO handle defaultBlock
args, err := req.ToGetStateArgs()
if err != nil {
return err
}
return p.GetStateAt(args, reply)
- case "eth_storageAt":
+ case "eth_getStorageAt":
+ // TODO handle defaultBlock
args, err := req.ToStorageAtArgs()
if err != nil {
return err
}
return p.GetStorageAt(args, reply)
- case "eth_blockByNumber", "eth_blockByHash":
- args, err := req.ToGetBlockArgs()
+ case "eth_getTransactionCount":
+ // TODO handle defaultBlock
+ args, err := req.ToGetTxCountArgs()
if err != nil {
return err
}
- return p.GetBlock(args, reply)
- case "eth_transact":
+ return p.GetTxCountAt(args, reply)
+ case "eth_getBlockTransactionCountByHash":
+ case "eth_getBlockTransactionCountByNumber":
+ case "eth_getUncleCountByBlockHash":
+ case "eth_getUncleCountByBlockNumber":
+ return errNotImplemented
+ case "eth_getData":
+ // TODO handle defaultBlock
+ args, err := req.ToGetCodeAtArgs()
+ if err != nil {
+ return err
+ }
+ return p.GetCodeAt(args, reply)
+ case "eth_sendTransaction":
args, err := req.ToNewTxArgs()
if err != nil {
return err
@@ -553,77 +569,91 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err
}
return p.Call(args, reply)
- case "eth_newFilter":
- args, err := req.ToFilterArgs()
+ case "eth_flush":
+ return errNotImplemented
+ case "eth_getBlockByNumber", "eth_getBlockByHash":
+ // TODO handle second param for "include transaction objects"
+ args, err := req.ToGetBlockArgs()
if err != nil {
return err
}
- return p.NewFilter(args, reply)
- case "eth_newFilterString":
- args, err := req.ToFilterStringArgs()
+ return p.GetBlock(args, reply)
+ case "eth_getTransactionByHash":
+ case "eth_getTransactionByBlockHashAndIndex":
+ case "eth_getTransactionByBlockNumberAndIndex":
+ case "eth_getUncleByBlockHashAndIndex":
+ case "eth_getUncleByBlockNumberAndIndex":
+ return errNotImplemented
+ case "eth_getCompilers":
+ return p.GetCompilers(reply)
+ case "eth_compileSolidity":
+ case "eth_compileLLL":
+ return errNotImplemented
+ case "eth_compileSerpent":
+ args, err := req.ToCompileArgs()
+ if err != nil {
+ return err
+ }
+ return p.CompileSerpent(args, reply)
+ case "eth_newFilter":
+ args, err := req.ToFilterArgs()
if err != nil {
return err
}
- return p.NewFilterString(args, reply)
+ return p.NewFilter(args, reply)
+ // case "eth_newFilterString":
+ // args, err := req.ToFilterStringArgs()
+ // if err != nil {
+ // return err
+ // }
+ // return p.NewFilterString(args, reply)
+ case "eth_newBlockFilter":
+ return errNotImplemented
case "eth_uninstallFilter":
args, err := req.ToUninstallFilterArgs()
if err != nil {
return err
}
return p.UninstallFilter(args, reply)
- case "eth_changed":
+ case "eth_getFilterChanges":
args, err := req.ToIdArgs()
if err != nil {
return err
}
return p.FilterChanged(args, reply)
- case "eth_filterLogs":
+ case "eth_getFilterLogs":
args, err := req.ToIdArgs()
if err != nil {
return err
}
return p.Logs(args, reply)
- case "eth_logs":
+ case "eth_getLogs":
args, err := req.ToFilterArgs()
if err != nil {
return err
}
return p.AllLogs(args, reply)
- case "eth_gasPrice":
- *reply = toHex(defaultGasPrice.Bytes())
- return nil
- 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 "eth_compilers":
- return p.GetCompilers(reply)
- case "eth_serpent":
- args, err := req.ToCompileArgs()
- if err != nil {
- return err
- }
- return p.CompileSerpent(args, reply)
- case "web3_sha3":
- args, err := req.ToSha3Args()
- if err != nil {
- return err
- }
- return p.Sha3(args, reply)
+ 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, err := req.ToDbPutArgs()
if err != nil {
@@ -636,36 +666,37 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err
}
return p.DbGet(args, reply)
- case "net_listening":
- return p.GetIsListening(reply)
- case "net_peerCount":
- return p.GetPeerCount(reply)
+ case "shh_post":
+ args, err := req.ToWhisperPostArgs()
+ if err != nil {
+ return err
+ }
+ return p.WhisperPost(args, reply)
case "shh_newIdentity":
return p.NewWhisperIdentity(reply)
+ case "shh_hasIdentity":
+ args, err := req.ToWhisperHasIdentityArgs()
+ if err != nil {
+ return err
+ }
+ return p.HasWhisperIdentity(args, reply)
+ case "shh_newGroup":
+ case "shh_addToGroup":
+ return errNotImplemented
case "shh_newFilter":
args, err := req.ToWhisperFilterArgs()
if err != nil {
return err
}
return p.NewWhisperFilter(args, reply)
+ case "shh_uninstallFilter":
+ return errNotImplemented
case "shh_changed":
args, err := req.ToIdArgs()
if err != nil {
return err
}
return p.MessagesChanged(args, reply)
- case "shh_post":
- args, err := req.ToWhisperPostArgs()
- if err != nil {
- return err
- }
- return p.WhisperPost(args, reply)
- case "shh_haveIdentity":
- args, err := req.ToWhisperHasIdentityArgs()
- if err != nil {
- return err
- }
- return p.HasWhisperIdentity(args, reply)
case "shh_getMessages":
args, err := req.ToIdArgs()
if err != nil {