aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-03-11 23:27:32 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-03-11 23:27:32 +0800
commit9e89c803f124e98530067c409a67c03d7ab99ef3 (patch)
tree3dfc79b65a89479fc9385de8c3f089be8a9e738c /rpc
parent53ac85cfd3188f96bc595a131732bbdbd5d49687 (diff)
downloadgo-tangerine-9e89c803f124e98530067c409a67c03d7ab99ef3.tar.gz
go-tangerine-9e89c803f124e98530067c409a67c03d7ab99ef3.tar.zst
go-tangerine-9e89c803f124e98530067c409a67c03d7ab99ef3.zip
Get Uncles
Diffstat (limited to 'rpc')
-rw-r--r--rpc/api.go37
1 files changed, 36 insertions, 1 deletions
diff --git a/rpc/api.go b/rpc/api.go
index 335f6cabd..90d09d281 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -627,8 +627,43 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
}
*reply = v.Transactions[args.Index]
case "eth_getUncleByBlockHashAndIndex":
+ args := new(HashIndexArgs)
+ if err := json.Unmarshal(req.Params, &args); err != nil {
+ return err
+ }
+
+ v, err := p.GetBlockByHash(args.BlockHash, false)
+ if err != nil {
+ return err
+ }
+ if args.Index > int64(len(v.Uncles)) || args.Index < 0 {
+ return NewErrorWithMessage(errDecodeArgs, "Uncle index does not exist")
+ }
+
+ uncle, err := p.GetBlockByHash(toHex(v.Uncles[args.Index]), false)
+ if err != nil {
+ return err
+ }
+ *reply = uncle
case "eth_getUncleByBlockNumberAndIndex":
- return errNotImplemented
+ args := new(BlockNumIndexArgs)
+ if err := json.Unmarshal(req.Params, &args); err != nil {
+ return err
+ }
+
+ v, err := p.GetBlockByNumber(args.BlockNumber, true)
+ if err != nil {
+ return err
+ }
+ if args.Index > int64(len(v.Uncles)) || args.Index < 0 {
+ return NewErrorWithMessage(errDecodeArgs, "Uncle index does not exist")
+ }
+
+ uncle, err := p.GetBlockByHash(toHex(v.Uncles[args.Index]), false)
+ if err != nil {
+ return err
+ }
+ *reply = uncle
case "eth_getCompilers":
return p.GetCompilers(reply)
case "eth_compileSolidity":