Resolve storage/storageat

pull/444/head
Taylor Gerring 10 years ago
parent a6599404e4
commit 9f5e9eb38d
  1. 10
      rpc/api.go
  2. 6
      rpc/args.go
  3. 24
      rpc/messages.go

@ -311,7 +311,7 @@ func (p *EthereumApi) PushTx(args *PushTxArgs, reply *interface{}) error {
return nil
}
func (p *EthereumApi) GetStateAt(args *GetStateArgs, reply *interface{}) error {
func (p *EthereumApi) GetStorageAt(args *GetStorageAtArgs, reply *interface{}) error {
err := args.requirements()
if err != nil {
return err
@ -333,7 +333,7 @@ func (p *EthereumApi) GetStateAt(args *GetStateArgs, reply *interface{}) error {
return nil
}
func (p *EthereumApi) GetStorageAt(args *GetStorageArgs, reply *interface{}) error {
func (p *EthereumApi) GetStorage(args *GetStorageArgs, reply *interface{}) error {
err := args.requirements()
if err != nil {
return err
@ -527,14 +527,14 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return p.GetBalanceAt(args, reply)
case "eth_getStorage":
// TODO handle defaultBlock
args, err := req.ToGetStateArgs()
args, err := req.ToStorageArgs()
if err != nil {
return err
}
return p.GetStateAt(args, reply)
return p.GetStorage(args, reply)
case "eth_getStorageAt":
// TODO handle defaultBlock
args, err := req.ToStorageAtArgs()
args, err := req.ToGetStorageAtArgs()
if err != nil {
return err
}

@ -102,12 +102,12 @@ func (a *GetStorageArgs) requirements() error {
return nil
}
type GetStateArgs struct {
type GetStorageAtArgs struct {
Address string
Key string
}
func (obj *GetStateArgs) UnmarshalJSON(b []byte) (err error) {
func (obj *GetStorageAtArgs) UnmarshalJSON(b []byte) (err error) {
arg0 := ""
if err = json.Unmarshal(b, &arg0); err == nil {
obj.Address = arg0
@ -116,7 +116,7 @@ func (obj *GetStateArgs) UnmarshalJSON(b []byte) (err error) {
return errDecodeArgs
}
func (a *GetStateArgs) requirements() error {
func (a *GetStorageAtArgs) requirements() error {
if a.Address == "" {
return NewErrorWithMessage(errArguments, "GetStorageAt requires an 'address' value as argument")
}

@ -120,23 +120,31 @@ func (req *RpcRequest) ToPushTxArgs() (*PushTxArgs, error) {
return args, nil
}
func (req *RpcRequest) ToGetStateArgs() (*GetStateArgs, error) {
if len(req.Params) < 1 {
func (req *RpcRequest) ToGetStorageAtArgs() (*GetStorageAtArgs, error) {
if len(req.Params) < 2 {
return nil, errArguments
}
args := new(GetStateArgs)
// TODO need to pass both arguments
r := bytes.NewReader(req.Params[0])
err := json.NewDecoder(r).Decode(args)
if err != nil {
args := new(GetStorageAtArgs)
var arg0, arg1 string
r0 := bytes.NewReader(req.Params[0])
if err := json.NewDecoder(r0).Decode(arg0); err != nil {
return nil, errDecodeArgs
}
r1 := bytes.NewReader(req.Params[1])
if err := json.NewDecoder(r1).Decode(arg1); err != nil {
return nil, errDecodeArgs
}
args.Address = arg0
args.Key = arg1
return args, nil
}
func (req *RpcRequest) ToStorageAtArgs() (*GetStorageArgs, error) {
func (req *RpcRequest) ToStorageArgs() (*GetStorageArgs, error) {
if len(req.Params) < 1 {
return nil, errArguments
}

Loading…
Cancel
Save