ResetWithGenesisBlock purges the entire blockchain, restoring it to the specified genesis state.
(genesis *types.Block)
| 542 | // ResetWithGenesisBlock purges the entire blockchain, restoring it to the |
| 543 | // specified genesis state. |
| 544 | func (bc *BlockChain) ResetWithGenesisBlock(genesis *types.Block) error { |
| 545 | // Dump the entire block chain and purge the caches |
| 546 | if err := bc.SetHead(0); err != nil { |
| 547 | return err |
| 548 | } |
| 549 | bc.mu.Lock() |
| 550 | defer bc.mu.Unlock() |
| 551 | |
| 552 | // Prepare the genesis block and reinitialise the chain |
| 553 | rawdb.WriteBlock(bc.db, genesis) |
| 554 | |
| 555 | bc.genesisBlock = genesis |
| 556 | bc.insert(bc.genesisBlock) |
| 557 | bc.currentBlock.Store(bc.genesisBlock) |
| 558 | bc.hc.SetGenesis(bc.genesisBlock.Header()) |
| 559 | bc.hc.SetCurrentHeader(bc.genesisBlock.Header()) |
| 560 | bc.currentFastBlock.Store(bc.genesisBlock) |
| 561 | |
| 562 | return nil |
| 563 | } |
| 564 | |
| 565 | // repair tries to repair the current blockchain by rolling back the current block |
| 566 | // until one with associated state is found. This is needed to fix incomplete db |
no test coverage detected