diff options
author | obscuren <geffobscura@gmail.com> | 2015-03-23 23:47:05 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-03-23 23:47:05 +0800 |
commit | 211cb03f83c8bdfd29af31fd27dc531dfcb13630 (patch) | |
tree | 7c1296a6194db41a8d8b25a89dd7aa442d6b4fe5 /xeth/xeth.go | |
parent | 253ecdc8bba1b522e80fdee69410854f19a5a972 (diff) | |
parent | 9562a9840f783e6252ebc6fb8da62b81004f62e8 (diff) | |
download | go-tangerine-211cb03f83c8bdfd29af31fd27dc531dfcb13630.tar go-tangerine-211cb03f83c8bdfd29af31fd27dc531dfcb13630.tar.gz go-tangerine-211cb03f83c8bdfd29af31fd27dc531dfcb13630.tar.bz2 go-tangerine-211cb03f83c8bdfd29af31fd27dc531dfcb13630.tar.lz go-tangerine-211cb03f83c8bdfd29af31fd27dc531dfcb13630.tar.xz go-tangerine-211cb03f83c8bdfd29af31fd27dc531dfcb13630.tar.zst go-tangerine-211cb03f83c8bdfd29af31fd27dc531dfcb13630.zip |
Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop
Diffstat (limited to 'xeth/xeth.go')
-rw-r--r-- | xeth/xeth.go | 15 |
1 files changed, 14 insertions, 1 deletions
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() } |