From 49a513bdebd7c4402b3a7f2f169a31c34f2ca9df Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Mon, 13 Apr 2015 10:13:52 +0200 Subject: Added blockchain DB versioning support, closes #650 --- core/block_processor.go | 6 ++++++ core/chain_manager.go | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'core') 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 } -- cgit v1.2.3 From 3d57e377a4e95941fd3f572b42e073b40d10d27c Mon Sep 17 00:00:00 2001 From: zelig Date: Sun, 12 Apr 2015 20:25:09 +0100 Subject: blockpool stability fixes: - follow up locks and fix them - chainManager: call SetQueued for parentErr future blocks, uncomment TD checks, unskip test - make ErrIncorrectTD non-fatal to be forgiving to genuine mistaken nodes (temp) but demote them to guard against stuck best peers. - add purging to bounded nodeCache (config nodeCacheSize) - use nodeCache when creating blockpool entries and let non-best peers add blocks (performance boost) - minor error in addError - reduce idleBestPeerTimeout to 1 minute - correct status counts and unskip status passing status test - glogified logging --- core/chain_manager.go | 1 + 1 file changed, 1 insertion(+) (limited to 'core') diff --git a/core/chain_manager.go b/core/chain_manager.go index 5ad1dda83..676db405e 100644 --- a/core/chain_manager.go +++ b/core/chain_manager.go @@ -470,6 +470,7 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error { } if IsParentErr(err) && self.futureBlocks.Has(block.ParentHash()) { + block.SetQueued(true) self.futureBlocks.Push(block) stats.queued++ continue -- cgit v1.2.3