Refactored ethutil.Config.Db out

This commit is contained in:
obscuren
2015-01-07 13:17:48 +01:00
parent 032ab66529
commit fed3e6a808
35 changed files with 125 additions and 493 deletions

View File

@ -129,10 +129,9 @@ func (self *JSRE) initStdFuncs() {
*/
func (self *JSRE) dump(call otto.FunctionCall) otto.Value {
var state *state.StateDB
var block *types.Block
if len(call.ArgumentList) > 0 {
var block *types.Block
if call.Argument(0).IsNumber() {
num, _ := call.Argument(0).ToInteger()
block = self.ethereum.ChainManager().GetBlockByNumber(uint64(num))
@ -149,12 +148,12 @@ func (self *JSRE) dump(call otto.FunctionCall) otto.Value {
return otto.UndefinedValue()
}
state = block.State()
} else {
state = self.ethereum.ChainManager().State()
block = self.ethereum.ChainManager().CurrentBlock()
}
v, _ := self.Vm.ToValue(state.Dump())
statedb := state.New(block.Root(), self.ethereum.Db())
v, _ := self.Vm.ToValue(statedb.Dump())
return v
}