diff options
author | obscuren <geffobscura@gmail.com> | 2015-03-06 00:48:46 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-03-06 00:48:46 +0800 |
commit | 76e4e233adfd4ea50e801a1c6a7d08310651db93 (patch) | |
tree | de48b3f21bf6071d711f47bd9b9d95099db14aba /core | |
parent | d44fe4ec627f0aecdb891b5ae415b8c89315d131 (diff) | |
parent | 3b307653786bef0f3925e434981496bc444903b0 (diff) | |
download | go-tangerine-76e4e233adfd4ea50e801a1c6a7d08310651db93.tar go-tangerine-76e4e233adfd4ea50e801a1c6a7d08310651db93.tar.gz go-tangerine-76e4e233adfd4ea50e801a1c6a7d08310651db93.tar.bz2 go-tangerine-76e4e233adfd4ea50e801a1c6a7d08310651db93.tar.lz go-tangerine-76e4e233adfd4ea50e801a1c6a7d08310651db93.tar.xz go-tangerine-76e4e233adfd4ea50e801a1c6a7d08310651db93.tar.zst go-tangerine-76e4e233adfd4ea50e801a1c6a7d08310651db93.zip |
Merge branch 'poc-9' of github.com-obscure:ethereum/go-ethereum into poc-9
Diffstat (limited to 'core')
-rw-r--r-- | core/chain_manager.go | 15 | ||||
-rw-r--r-- | core/error.go | 2 |
2 files changed, 16 insertions, 1 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() diff --git a/core/error.go b/core/error.go index fb1eaed84..514cd076b 100644 --- a/core/error.go +++ b/core/error.go @@ -22,7 +22,7 @@ func (err *ParentErr) Error() string { } func ParentError(hash []byte) error { - return &ParentErr{Message: fmt.Sprintf("Block's parent unkown %x", hash)} + return &ParentErr{Message: fmt.Sprintf("Block's parent unknown %x", hash)} } func IsParentErr(err error) bool { |