aboutsummaryrefslogtreecommitdiffstats
path: root/core/chain_manager.go
diff options
context:
space:
mode:
Diffstat (limited to 'core/chain_manager.go')
-rw-r--r--core/chain_manager.go11
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 {