From d65b64c8846636d3e58c1857eaff149d2f82a283 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Sat, 6 Jun 2015 00:02:32 -0400 Subject: Allow export command to take first and last args --- cmd/utils/cmd.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'cmd/utils') diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go index e5413973d..f7520a8e4 100644 --- a/cmd/utils/cmd.go +++ b/cmd/utils/cmd.go @@ -268,3 +268,18 @@ func ExportChain(chainmgr *core.ChainManager, fn string) error { glog.Infoln("Exported blockchain to", fn) return nil } + +func ExportAppendChain(chainmgr *core.ChainManager, fn string, first uint64, last uint64) error { + glog.Infoln("Exporting blockchain to", fn) + // TODO verify mode perms + fh, err := os.OpenFile(fn, os.O_CREATE|os.O_APPEND|os.O_WRONLY, os.ModePerm) + if err != nil { + return err + } + defer fh.Close() + if err := chainmgr.ExportN(fh, first, last); err != nil { + return err + } + glog.Infoln("Exported blockchain to", fn) + return nil +} -- cgit