aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-04-13 23:34:34 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-04-13 23:34:34 +0800
commit5f9346bc7afd64706b3815aec6be2b2650929a6b (patch)
treeff02f1f4f36246e2431b43207f2400b49417e051 /core
parentad4891a09a4f7c7fa3e77c5370c01f16a0a3070e (diff)
parent49a513bdebd7c4402b3a7f2f169a31c34f2ca9df (diff)
downloadgo-tangerine-5f9346bc7afd64706b3815aec6be2b2650929a6b.tar.gz
go-tangerine-5f9346bc7afd64706b3815aec6be2b2650929a6b.tar.zst
go-tangerine-5f9346bc7afd64706b3815aec6be2b2650929a6b.zip
Merge pull request #700 from bas-vk/issue_650
Added blockchain DB versioning support, closes #650
Diffstat (limited to 'core')
-rw-r--r--core/block_processor.go6
-rw-r--r--core/chain_manager.go7
2 files changed, 11 insertions, 2 deletions
diff --git a/core/block_processor.go b/core/block_processor.go
index 7aded346a..d5a29b258 100644
--- a/core/block_processor.go
+++ b/core/block_processor.go
@@ -18,6 +18,12 @@ import (
"gopkg.in/fatih/set.v0"
)
+const (
+ // must be bumped when consensus algorithm is changed, this forces the upgradedb
+ // command to be run (forces the blocks to be imported again using the new algorithm)
+ BlockChainVersion = 1
+)
+
var statelogger = logger.NewLogger("BLOCK")
type BlockProcessor struct {
diff --git a/core/chain_manager.go b/core/chain_manager.go
index 5ad1dda83..25ee0eeef 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -284,11 +284,14 @@ func (self *ChainManager) Export(w io.Writer) error {
defer self.mu.RUnlock()
glog.V(logger.Info).Infof("exporting %v blocks...\n", self.currentBlock.Header().Number)
- for block := self.currentBlock; block != nil; block = self.GetBlock(block.Header().ParentHash) {
- if err := block.EncodeRLP(w); err != nil {
+ last := self.currentBlock.NumberU64()
+
+ for nr := uint64(0); nr <= last; nr++ {
+ if err := self.GetBlockByNumber(nr).EncodeRLP(w); err != nil {
return err
}
}
+
return nil
}