diff options
author | obscuren <geffobscura@gmail.com> | 2015-04-07 18:32:55 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-04-07 18:32:55 +0800 |
commit | 7b6a8cc9ae56856f1c292243b57d658b67b92621 (patch) | |
tree | e959e2d89dc88c00c288a97ac659843b5e06f0bf /xeth | |
parent | 9c55576c7b415954773c062d404a736741fb9794 (diff) | |
download | dexon-7b6a8cc9ae56856f1c292243b57d658b67b92621.tar dexon-7b6a8cc9ae56856f1c292243b57d658b67b92621.tar.gz dexon-7b6a8cc9ae56856f1c292243b57d658b67b92621.tar.bz2 dexon-7b6a8cc9ae56856f1c292243b57d658b67b92621.tar.lz dexon-7b6a8cc9ae56856f1c292243b57d658b67b92621.tar.xz dexon-7b6a8cc9ae56856f1c292243b57d658b67b92621.tar.zst dexon-7b6a8cc9ae56856f1c292243b57d658b67b92621.zip |
Fixed pending states
Diffstat (limited to 'xeth')
-rw-r--r-- | xeth/xeth.go | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/xeth/xeth.go b/xeth/xeth.go index 825f26017..b8d9ecb08 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -136,13 +136,16 @@ func cTopics(t [][]string) [][]common.Hash { func (self *XEth) RemoteMining() *miner.RemoteAgent { return self.agent } func (self *XEth) AtStateNum(num int64) *XEth { - block := self.getBlockByHeight(num) - var st *state.StateDB - if block != nil { - st = state.New(block.Root(), self.backend.StateDb()) - } else { - st = self.backend.ChainManager().State() + switch num { + case -2: + st = self.backend.Miner().PendingState().Copy() + default: + if block := self.getBlockByHeight(num); block != nil { + st = state.New(block.Root(), self.backend.StateDb()) + } else { + st = state.New(self.backend.ChainManager().GetBlockByNumber(0).Root(), self.backend.StateDb()) + } } return self.withState(st) @@ -164,9 +167,16 @@ func (self *XEth) Whisper() *Whisper { return self.whisper } func (self *XEth) getBlockByHeight(height int64) *types.Block { var num uint64 - if height < 0 { - num = self.CurrentBlock().NumberU64() + uint64(-1*height) - } else { + switch height { + case -2: + return self.backend.Miner().PendingBlock() + case -1: + return self.CurrentBlock() + default: + if height < 0 { + return nil + } + num = uint64(height) } |