diff options
author | obscuren <geffobscura@gmail.com> | 2014-12-18 07:12:51 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-12-18 07:12:51 +0800 |
commit | e6fdf0c9f7564b8b08cf428e03af66fc423adcc1 (patch) | |
tree | 14fafd42083a9a5d57005b614740294ae0525bef /core/chain_manager.go | |
parent | 52b54631a47dfa46742635be178f2f8d33dd9f41 (diff) | |
parent | 4dbdcaecb117d7e1fcaf0869f5d4602312552991 (diff) | |
download | go-tangerine-e6fdf0c9f7564b8b08cf428e03af66fc423adcc1.tar go-tangerine-e6fdf0c9f7564b8b08cf428e03af66fc423adcc1.tar.gz go-tangerine-e6fdf0c9f7564b8b08cf428e03af66fc423adcc1.tar.bz2 go-tangerine-e6fdf0c9f7564b8b08cf428e03af66fc423adcc1.tar.lz go-tangerine-e6fdf0c9f7564b8b08cf428e03af66fc423adcc1.tar.xz go-tangerine-e6fdf0c9f7564b8b08cf428e03af66fc423adcc1.tar.zst go-tangerine-e6fdf0c9f7564b8b08cf428e03af66fc423adcc1.zip |
Merge branch 'develop' into poc8
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 f9fb3b3f8..a4ff5cb5c 100644 --- a/core/chain_manager.go +++ b/core/chain_manager.go @@ -152,6 +152,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) @@ -185,7 +195,6 @@ func (self *ChainManager) GetBlockHashesFromHash(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 { |