cleanup
This commit is contained in:
parent
961e4da7d8
commit
a81d835e4d
@ -55,7 +55,7 @@ func (self jsonWrapper) ParseRequestBody(req *http.Request) (RpcRequest, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self jsonWrapper) GetRequestReply(xeth *EthereumApi, req *RpcRequest, reply *interface{}) error {
|
func (self jsonWrapper) GetRequestReply(xeth *EthereumApi, req *RpcRequest, reply *interface{}) error {
|
||||||
// call function for request method
|
// Spec at https://github.com/ethereum/wiki/wiki/Generic-JSON-RPC
|
||||||
jsonlogger.DebugDetailf("%T %s", req.Params, req.Params)
|
jsonlogger.DebugDetailf("%T %s", req.Params, req.Params)
|
||||||
switch req.Method {
|
switch req.Method {
|
||||||
case "eth_coinbase":
|
case "eth_coinbase":
|
||||||
|
@ -162,18 +162,6 @@ func (req *RpcRequest) ToGetCodeAtArgs() (*GetCodeAtArgs, error) {
|
|||||||
return args, nil
|
return args, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// func NewSuccessRes(object JsonResponse) string {
|
|
||||||
// e := SuccessRes{Error: false, Result: object}
|
|
||||||
// res, err := json.Marshal(e)
|
|
||||||
// if err != nil {
|
|
||||||
// // This should never happen
|
|
||||||
// panic("Creating json error response failed, help")
|
|
||||||
// }
|
|
||||||
// success := string(res)
|
|
||||||
// return success
|
|
||||||
// // return res
|
|
||||||
// }
|
|
||||||
|
|
||||||
func NewErrorResponse(msg string) error {
|
func NewErrorResponse(msg string) error {
|
||||||
return errors.New(msg)
|
return errors.New(msg)
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ For each request type, define the following:
|
|||||||
|
|
||||||
1. RpcRequest "To" method [message.go], which does basic validation and conversion to "Args" type via json.Decoder()
|
1. RpcRequest "To" method [message.go], which does basic validation and conversion to "Args" type via json.Decoder()
|
||||||
2. json.Decoder() calls "UnmarshalJSON" defined on each "Args" struct
|
2. json.Decoder() calls "UnmarshalJSON" defined on each "Args" struct
|
||||||
3. EthereumApi "Get" method, taking the "Args" type and replying with an interface to be marshalled to JSON
|
3. EthereumApi method, taking the "Args" type and replying with an interface to be marshalled to JSON
|
||||||
|
|
||||||
*/
|
*/
|
||||||
package rpc
|
package rpc
|
||||||
@ -173,7 +173,7 @@ func (obj *GetBlockArgs) UnmarshalJSON(b []byte) (err error) {
|
|||||||
obj.Hash = argstr
|
obj.Hash = argstr
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return NewErrorResponse("Could not determine JSON parameters")
|
return NewErrorResponse(ErrorDecodeArgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (obj *GetBlockArgs) requirements() error {
|
func (obj *GetBlockArgs) requirements() error {
|
||||||
@ -334,6 +334,7 @@ type BalanceRes struct {
|
|||||||
Balance string `json:"balance"`
|
Balance string `json:"balance"`
|
||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetCodeAtArgs struct {
|
type GetCodeAtArgs struct {
|
||||||
Address string
|
Address string
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ func (s *JsonRpcServer) Start() {
|
|||||||
http.Handle("/", h)
|
http.Handle("/", h)
|
||||||
|
|
||||||
err := http.Serve(s.listener, nil)
|
err := http.Serve(s.listener, nil)
|
||||||
// TODO Complains on shutdown due to listner already being closed
|
// FIX Complains on shutdown due to listner already being closed
|
||||||
if err != nil {
|
if err != nil {
|
||||||
jsonlogger.Errorln("Error on JSON-RPC interface:", err)
|
jsonlogger.Errorln("Error on JSON-RPC interface:", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user