aboutsummaryrefslogtreecommitdiffstats
path: root/xeth/xeth.go
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-03-20 11:28:45 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-03-20 11:28:45 +0800
commit19360c00795d356d052a379663c3f36aedba3f9e (patch)
tree1cadbb43e1490221d8ae0e18d022514be39f4cce /xeth/xeth.go
parent6669ef5b701f8b060287c8a63e9f3c1116b4b74a (diff)
downloaddexon-19360c00795d356d052a379663c3f36aedba3f9e.tar.gz
dexon-19360c00795d356d052a379663c3f36aedba3f9e.tar.zst
dexon-19360c00795d356d052a379663c3f36aedba3f9e.zip
Move stateAt func to XEth
Diffstat (limited to 'xeth/xeth.go')
-rw-r--r--xeth/xeth.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/xeth/xeth.go b/xeth/xeth.go
index 922fce8f1..504a93f58 100644
--- a/xeth/xeth.go
+++ b/xeth/xeth.go
@@ -154,6 +154,24 @@ func (self *XEth) stop() {
close(self.quit)
}
+func (self *XEth) AtStateNum(num int64) *XEth {
+ chain := self.Backend().ChainManager()
+ var block *types.Block
+
+ if num < 0 {
+ num = chain.CurrentBlock().Number().Int64() + num + 1
+ }
+ block = chain.GetBlockByNumber(uint64(num))
+
+ var st *state.StateDB
+ if block != nil {
+ st = state.New(block.Root(), self.Backend().StateDb())
+ } else {
+ st = chain.State()
+ }
+ return self.WithState(st)
+}
+
func (self *XEth) Backend() Backend { return self.eth }
func (self *XEth) WithState(statedb *state.StateDB) *XEth {
xeth := &XEth{