def on_data_delivery(
        self, delivery: QuicDeliveryState, start: int, stop: int, fin: bool
    ) -> None:
        """
        Callback when sent data is ACK'd.
        """
        # If the frame had the FIN bit set, its end MUST match otherwise
        # we have a programming error.
        assert not fin or stop == self._buffer_fin, (
            "on_data_delivered() was called with inconsistent fin / stop"
        )

        # If a reset has been requested, stop processing data delivery.
        # The transition to the finished state only depends on the reset
        # being acknowledged.
        if self._reset_error_code is not None:
            return

        if delivery == QuicDeliveryState.ACKED:
            if stop > start:
                # Some data has been ACK'd, discard it.
                self._acked.add(start, stop)
                first_range = self._acked[0]
                if first_range.start == self._buffer_start:
                    size = first_range.stop - first_range.start
                    self._acked.shift()
                    self._buffer_start += size
                    del self._buffer[:size]

            if fin:
                # The FIN has been ACK'd.
                self._acked_fin = True

            if self._buffer_start == self._buffer_fin and self._acked_fin:
                # All data and the FIN have been ACK'd, we're done sending.
                self.is_finished = True
        else:
            if stop > start:
                # Some data has been lost, reschedule it.
                self.buffer_is_empty = False
                self._pending.add(start, stop)

            if fin:
                # The FIN has been lost, reschedule it.
                self.buffer_is_empty = False
                self._pending_eof = True

        Callback when sent data is ACK'd.
        
src/aioquic/quic/stream.py