aboutsummaryrefslogtreecommitdiffstats
path: root/core/chain_manager.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-03-06 00:43:56 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-03-06 00:43:56 +0800
commit3b307653786bef0f3925e434981496bc444903b0 (patch)
tree3f2ee6f28636b0a05f39daf2a4e8dc5a6d38ea1f /core/chain_manager.go
parent377c8a13de3405424f16a67c2f3ae3485290a0ca (diff)
parent871dfd399be8ee657109112d527645c2c1b3a8f9 (diff)
downloaddexon-3b307653786bef0f3925e434981496bc444903b0.tar.gz
dexon-3b307653786bef0f3925e434981496bc444903b0.tar.zst
dexon-3b307653786bef0f3925e434981496bc444903b0.zip
Merge pull request #426 from Gustav-Simonsson/add_blockchain_tests
Add initial implementation of block tests
Diffstat (limited to 'core/chain_manager.go')
-rw-r--r--core/chain_manager.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/core/chain_manager.go b/core/chain_manager.go
index d2a6560c1..1152e3fa2 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -234,6 +234,21 @@ func (bc *ChainManager) Reset() {
bc.setTotalDifficulty(ethutil.Big("0"))
}
+func (bc *ChainManager) ResetWithGenesisBlock(gb *types.Block) {
+ bc.mu.Lock()
+ defer bc.mu.Unlock()
+
+ for block := bc.currentBlock; block != nil; block = bc.GetBlock(block.Header().ParentHash) {
+ bc.db.Delete(block.Hash())
+ }
+
+ // Prepare the genesis block
+ bc.genesisBlock = gb
+ bc.write(bc.genesisBlock)
+ bc.insert(bc.genesisBlock)
+ bc.currentBlock = bc.genesisBlock
+}
+
func (self *ChainManager) Export() []byte {
self.mu.RLock()
defer self.mu.RUnlock()