<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def db_restore(self, block_number=None):
 """ Restore the database and clear the indexing lockfile. Restore to a given block if given; otherwise use the most recent valid backup. Return True on success Return False if there is no state to restore Raise exception on error """

        restored = False
        if block_number is not None:
            # restore a specific backup
            try:
                self.backup_restore(block_number, self.impl, self.working_dir)
                restored = True
            except AssertionError:
                log.error("Failed to restore state from {}".format(block_number))
                return False

        else:
            # find the latest block
            backup_blocks = self.get_backup_blocks(self.impl, self.working_dir)
            for block_number in reversed(sorted(backup_blocks)):
                try:
                    self.backup_restore(block_number, self.impl, self.working_dir)
                    restored = True
                    log.debug("Restored state from {}".format(block_number))
                    break
                except AssertionError:
                    log.debug("Failed to restore state from {}".format(block_number))
                    continue

            if not restored:
                # failed to restore
                log.error("Failed to restore state from {}".format(','.join(backup_blocks)))
                return False

        # woo!
        self.db_set_indexing(False, self.impl, self.working_dir)
        return self.db_setup()