diff options
author | obscuren <geffobscura@gmail.com> | 2014-08-17 18:41:23 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-08-17 18:41:23 +0800 |
commit | 27735bbdfc4e32e2e5ca11f48591d62b766aa3f5 (patch) | |
tree | ceb02da5048d2f592944ff7bc41186fc81f8e76b /ethereal/gui.go | |
parent | 2eab964a00b998068f49b088949730f4896e256c (diff) | |
download | go-tangerine-27735bbdfc4e32e2e5ca11f48591d62b766aa3f5.tar go-tangerine-27735bbdfc4e32e2e5ca11f48591d62b766aa3f5.tar.gz go-tangerine-27735bbdfc4e32e2e5ca11f48591d62b766aa3f5.tar.bz2 go-tangerine-27735bbdfc4e32e2e5ca11f48591d62b766aa3f5.tar.lz go-tangerine-27735bbdfc4e32e2e5ca11f48591d62b766aa3f5.tar.xz go-tangerine-27735bbdfc4e32e2e5ca11f48591d62b766aa3f5.tar.zst go-tangerine-27735bbdfc4e32e2e5ca11f48591d62b766aa3f5.zip |
State dumps from gui
Diffstat (limited to 'ethereal/gui.go')
-rw-r--r-- | ethereal/gui.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/ethereal/gui.go b/ethereal/gui.go index 066db48b9..6149b39b7 100644 --- a/ethereal/gui.go +++ b/ethereal/gui.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" "math/big" + "os" "strconv" "strings" "time" @@ -155,6 +156,40 @@ func (gui *Gui) showWallet(context *qml.Context) (*qml.Window, error) { return gui.win, nil } +func (self *Gui) DumpState(hash, path string) { + var stateDump []byte + + if len(hash) == 0 { + stateDump = self.eth.StateManager().CurrentState().Dump() + } else { + var block *ethchain.Block + if hash[0] == '#' { + i, _ := strconv.Atoi(hash[1:]) + block = self.eth.BlockChain().GetBlockByNumber(uint64(i)) + } else { + block = self.eth.BlockChain().GetBlock(ethutil.Hex2Bytes(hash)) + } + + if block == nil { + logger.Infof("block err: not found %s\n", hash) + return + } + + stateDump = block.State().Dump() + } + + file, err := os.OpenFile(path[7:], os.O_CREATE|os.O_RDWR, os.ModePerm) + if err != nil { + logger.Infoln("dump err: ", err) + return + } + defer file.Close() + + logger.Infof("dumped state (%s) to %s\n", hash, path) + + file.Write(stateDump) +} + // The done handler will be called by QML when all views have been loaded func (gui *Gui) Done() { gui.qmlDone = true |