From ec85458612e1d5374767f87005dd0ad5934f74d5 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 29 Jan 2015 00:24:00 +0100 Subject: updated ethereum.js and moved to subfolder * Previous subtree caused a lot of trouble * Implemented sha3 in our shiny new http JSON RPC --- rpc/message.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'rpc/message.go') diff --git a/rpc/message.go b/rpc/message.go index caf50a6c0..5785fcc87 100644 --- a/rpc/message.go +++ b/rpc/message.go @@ -56,6 +56,20 @@ type RpcRequest struct { Params []json.RawMessage `json:"params"` } +func (req *RpcRequest) ToSha3Args() (*Sha3Args, error) { + if len(req.Params) < 1 { + return nil, NewErrorResponse(ErrorArguments) + } + + args := new(Sha3Args) + r := bytes.NewReader(req.Params[0]) + if err := json.NewDecoder(r).Decode(args); err != nil { + return nil, NewErrorResponse(ErrorDecodeArgs) + } + rpclogger.DebugDetailf("%T %v", args, args) + return args, nil +} + func (req *RpcRequest) ToGetBlockArgs() (*GetBlockArgs, error) { if len(req.Params) < 1 { return nil, NewErrorResponse(ErrorArguments) -- cgit v1.2.3