code: func recoverFromReorg(chain *blockchain.BlockChain, minBlock, maxBlock int32,
  	lastBlock *chainhash.Hash) ([]chainhash.Hash, error) {
  
  	hashList, err := chain.HeightRange(minBlock, maxBlock)
  	if err != nil {
  		rpcsLog.Errorf("Error looking up block range: %v", err)
  		return nil, &btcjson.RPCError{
  			Code:    btcjson.ErrRPCDatabase,
  			Message: "Database error: " + err.Error(),
  		}
  	}
  	if lastBlock == nil || len(hashList) == 0 {
  		return hashList, nil
  	}
  
  	blk, err := chain.BlockByHash(&hashList[0])
  	if err != nil {
  		rpcsLog.Errorf("Error looking up possibly reorged block: %v",
  			err)
  		return nil, &btcjson.RPCError{
  			Code:    btcjson.ErrRPCDatabase,
  			Message: "Database error: " + err.Error(),
  		}
  	}
  	jsonErr := descendantBlock(lastBlock, blk)
  	if jsonErr != nil {
  		return nil, jsonErr
  	}
  	return hashList, nil
  }
docs: // recoverFromReorg attempts to recover from a detected reorganize during a
  // rescan.  It fetches a new range of block shas from the database and
  // verifies that the new range of blocks is on the same fork as a previous
  // range of blocks.  If this condition does not hold true, the JSON-RPC error
  // for an unrecoverable reorganize is returned.