func (bc *ChainManager) ResetWithGenesisBlock(gb *types.Block) { bc.mu.Lock() defer bc.mu.Unlock() for block := bc.currentBlock; block != nil; block = bc.GetBlock(block.ParentHash()) { bc.removeBlock(block) } // Prepare the genesis block gb.Td = gb.Difficulty() bc.genesisBlock = gb err := WriteBlock(bc.chainDb, bc.genesisBlock) if err != nil { glog.Fatalln("db err:", err) } bc.insert(bc.genesisBlock) bc.currentBlock = bc.genesisBlock bc.makeCache() bc.td = gb.Difficulty() }