aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-03-23 23:36:12 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-03-23 23:36:12 +0800
commit5707912e2f7d49b3654d616ddae3439e6dc201c4 (patch)
tree6d26bcdf317bfe8780511ea06f2a15027e6146e9
parent2f8601ef382aeff6cdb31fe163cfac3b26bf56de (diff)
downloadgo-tangerine-5707912e2f7d49b3654d616ddae3439e6dc201c4.tar
go-tangerine-5707912e2f7d49b3654d616ddae3439e6dc201c4.tar.gz
go-tangerine-5707912e2f7d49b3654d616ddae3439e6dc201c4.tar.bz2
go-tangerine-5707912e2f7d49b3654d616ddae3439e6dc201c4.tar.lz
go-tangerine-5707912e2f7d49b3654d616ddae3439e6dc201c4.tar.xz
go-tangerine-5707912e2f7d49b3654d616ddae3439e6dc201c4.tar.zst
go-tangerine-5707912e2f7d49b3654d616ddae3439e6dc201c4.zip
"pending" convention should be -2 instead of 0
-rw-r--r--rpc/args.go2
-rw-r--r--xeth/xeth.go15
2 files changed, 15 insertions, 2 deletions
diff --git a/rpc/args.go b/rpc/args.go
index 4b59f83b7..6e02b65ef 100644
--- a/rpc/args.go
+++ b/rpc/args.go
@@ -26,7 +26,7 @@ func blockHeight(raw interface{}, number *int64) (err error) {
case "latest":
*number = -1
case "pending":
- *number = 0
+ *number = -2
default:
*number = common.String2Big(str).Int64()
}
diff --git a/xeth/xeth.go b/xeth/xeth.go
index 23e523980..f7f4ce0cf 100644
--- a/xeth/xeth.go
+++ b/xeth/xeth.go
@@ -176,9 +176,12 @@ func (self *XEth) AtStateNum(num int64) *XEth {
chain := self.Backend().ChainManager()
var block *types.Block
+ // -1 generally means "latest"
+ // -2 means "pending", which has no blocknum
if num < 0 {
- num = chain.CurrentBlock().Number().Int64() + num + 1
+ num = chain.CurrentBlock().Number().Int64()
}
+
block = chain.GetBlockByNumber(uint64(num))
var st *state.StateDB
@@ -229,6 +232,11 @@ func (self *XEth) EthTransactionByHash(hash string) *types.Transaction {
}
func (self *XEth) BlockByNumber(num int64) *Block {
+ if num == -2 {
+ // "pending" is non-existant
+ return &Block{}
+ }
+
if num == -1 {
return NewBlock(self.chainManager.CurrentBlock())
}
@@ -237,6 +245,11 @@ func (self *XEth) BlockByNumber(num int64) *Block {
}
func (self *XEth) EthBlockByNumber(num int64) *types.Block {
+ if num == -2 {
+ // "pending" is non-existant
+ return &types.Block{}
+ }
+
if num == -1 {
return self.chainManager.CurrentBlock()
}