From b1c58b76a9588a90db5a773a997bb70265c378d3 Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 17 Dec 2014 12:57:35 +0100 Subject: moved err check --- core/chain_manager.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'core/chain_manager.go') diff --git a/core/chain_manager.go b/core/chain_manager.go index edf50e715..3e48579b9 100644 --- a/core/chain_manager.go +++ b/core/chain_manager.go @@ -148,6 +148,16 @@ func (bc *ChainManager) Reset() { bc.TD = ethutil.BigD(ethutil.Config.Db.LastKnownTD()) } +func (self *ChainManager) Export() []byte { + chainlogger.Infoln("exporting", self.CurrentBlock.Number, "blocks") + + blocks := make(types.Blocks, int(self.CurrentBlock.Number.Int64())+1) + for block := self.CurrentBlock; block != nil; block = self.GetBlock(block.PrevHash) { + blocks[block.Number.Int64()] = block + } + return ethutil.Encode(blocks) +} + func (bc *ChainManager) insert(block *types.Block) { encodedBlock := block.RlpEncode() ethutil.Config.Db.Put([]byte("LastBlock"), encodedBlock) @@ -181,7 +191,6 @@ func (self *ChainManager) GetChainHashesFromHash(hash []byte, max uint64) (chain // XXX Could be optimised by using a different database which only holds hashes (i.e., linked list) for i := uint64(0); i < max; i++ { - chain = append(chain, block.Hash()) if block.Number.Cmp(ethutil.Big0) <= 0 { -- cgit