diff options
author | obscuren <geffobscura@gmail.com> | 2014-12-17 19:57:35 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-12-17 19:57:35 +0800 |
commit | b1c58b76a9588a90db5a773a997bb70265c378d3 (patch) | |
tree | 0d2631ec0b9324f08fcd2e82cec797fab75e9d4d /core/chain_manager.go | |
parent | ef4135eabe5cb25f8972371c5681e1611ce0cde9 (diff) | |
download | dexon-b1c58b76a9588a90db5a773a997bb70265c378d3.tar.gz dexon-b1c58b76a9588a90db5a773a997bb70265c378d3.tar.zst dexon-b1c58b76a9588a90db5a773a997bb70265c378d3.zip |
moved err check
Diffstat (limited to 'core/chain_manager.go')
-rw-r--r-- | core/chain_manager.go | 11 |
1 files changed, 10 insertions, 1 deletions
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 { |