aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-05-19 21:44:31 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-05-19 21:44:31 +0800
commit9b825e272820c9624a9f5df19086b639d5a16e93 (patch)
tree7a50926b3c7699e6c70dc2ecd64b9d270b474968 /rpc/api.go
parent7d9a13e0d5a3c7745a0219957ccd2bcc5a301c58 (diff)
parent748263d2f011382c832cbebb8d4e10fba8a09f71 (diff)
downloadgo-tangerine-9b825e272820c9624a9f5df19086b639d5a16e93.tar
go-tangerine-9b825e272820c9624a9f5df19086b639d5a16e93.tar.gz
go-tangerine-9b825e272820c9624a9f5df19086b639d5a16e93.tar.bz2
go-tangerine-9b825e272820c9624a9f5df19086b639d5a16e93.tar.lz
go-tangerine-9b825e272820c9624a9f5df19086b639d5a16e93.tar.xz
go-tangerine-9b825e272820c9624a9f5df19086b639d5a16e93.tar.zst
go-tangerine-9b825e272820c9624a9f5df19086b639d5a16e93.zip
Merge pull request #1036 from tgerring/issue884
JSON RPC null field updates
Diffstat (limited to 'rpc/api.go')
-rw-r--r--rpc/api.go22
1 files changed, 16 insertions, 6 deletions
diff --git a/rpc/api.go b/rpc/api.go
index b59253ef7..0c1409d71 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -1,9 +1,9 @@
package rpc
import (
+ "bytes"
"encoding/json"
"math/big"
- // "sync"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
@@ -230,7 +230,14 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
block := api.xeth().EthBlockByNumber(args.BlockNumber)
br := NewBlockRes(block, args.IncludeTxs)
-
+ // If request was for "pending", nil nonsensical fields
+ if args.BlockNumber == -2 {
+ br.BlockHash = nil
+ br.BlockNumber = nil
+ br.Miner = nil
+ br.Nonce = nil
+ br.LogsBloom = nil
+ }
*reply = br
case "eth_getTransactionByHash":
args := new(HashArgs)
@@ -240,9 +247,12 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
tx, bhash, bnum, txi := api.xeth().EthTransactionByHash(args.Hash)
if tx != nil {
v := NewTransactionRes(tx)
- v.BlockHash = newHexData(bhash)
- v.BlockNumber = newHexNum(bnum)
- v.TxIndex = newHexNum(txi)
+ // if the blockhash is 0, assume this is a pending transaction
+ if bytes.Compare(bhash.Bytes(), bytes.Repeat([]byte{0}, 32)) != 0 {
+ v.BlockHash = newHexData(bhash)
+ v.BlockNumber = newHexNum(bnum)
+ v.TxIndex = newHexNum(txi)
+ }
*reply = v
}
case "eth_getTransactionByBlockHashAndIndex":
@@ -577,7 +587,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
return NewNotImplementedError(req.Method)
}
- glog.V(logger.Detail).Infof("Reply: %T %s\n", reply, reply)
+ // glog.V(logger.Detail).Infof("Reply: %v\n", reply)
return nil
}