inline GetStorageAt
This commit is contained in:
parent
28e5fc8352
commit
739c36ad4d
31
rpc/api.go
31
rpc/api.go
|
@ -4,7 +4,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"math/big"
|
"math/big"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
@ -43,27 +42,6 @@ func (self *EthereumApi) xeth() *xeth.XEth {
|
||||||
return self.eth
|
return self.eth
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *EthereumApi) GetStorageAt(args *GetStorageAtArgs, reply *interface{}) error {
|
|
||||||
if err := args.requirements(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
state := p.xeth().AtStateNum(args.BlockNumber).State().SafeGet(args.Address)
|
|
||||||
value := state.StorageString(args.Key)
|
|
||||||
|
|
||||||
var hx string
|
|
||||||
if strings.Index(args.Key, "0x") == 0 {
|
|
||||||
hx = string([]byte(args.Key)[2:])
|
|
||||||
} else {
|
|
||||||
// Convert the incoming string (which is a bigint) into hex
|
|
||||||
i, _ := new(big.Int).SetString(args.Key, 10)
|
|
||||||
hx = common.Bytes2Hex(i.Bytes())
|
|
||||||
}
|
|
||||||
rpclogger.Debugf("GetStateAt(%s, %s)\n", args.Address, hx)
|
|
||||||
*reply = map[string]string{args.Key: value.Str()}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// func (self *EthereumApi) Register(args string, reply *interface{}) error {
|
// func (self *EthereumApi) Register(args string, reply *interface{}) error {
|
||||||
// self.regmut.Lock()
|
// self.regmut.Lock()
|
||||||
// defer self.regmut.Unlock()
|
// defer self.regmut.Unlock()
|
||||||
|
@ -159,7 +137,14 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
|
||||||
if err := json.Unmarshal(req.Params, &args); err != nil {
|
if err := json.Unmarshal(req.Params, &args); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return p.GetStorageAt(args, reply)
|
if err := args.requirements(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
state := p.xeth().AtStateNum(args.BlockNumber).State().SafeGet(args.Address)
|
||||||
|
value := state.StorageString(args.Key)
|
||||||
|
|
||||||
|
*reply = common.Bytes2Hex(value.Bytes())
|
||||||
case "eth_getTransactionCount":
|
case "eth_getTransactionCount":
|
||||||
args := new(GetTxCountArgs)
|
args := new(GetTxCountArgs)
|
||||||
if err := json.Unmarshal(req.Params, &args); err != nil {
|
if err := json.Unmarshal(req.Params, &args); err != nil {
|
||||||
|
|
Loading…
Reference in New Issue