aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorBas van Kervel <basvankervel@ziggo.nl>2015-04-13 16:13:52 +0800
committerBas van Kervel <basvankervel@ziggo.nl>2015-04-13 16:13:52 +0800
commit49a513bdebd7c4402b3a7f2f169a31c34f2ca9df (patch)
tree2cb976e970a8aa757ce31ee867970cf3d53ad15c /core
parent4de1e1609abb2e5be7e5cc5b8f206d305af8ce27 (diff)
downloadgo-tangerine-49a513bdebd7c4402b3a7f2f169a31c34f2ca9df.tar.gz
go-tangerine-49a513bdebd7c4402b3a7f2f169a31c34f2ca9df.tar.zst
go-tangerine-49a513bdebd7c4402b3a7f2f169a31c34f2ca9df.zip
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
}