# Path: oppy/cell/definitions.py
# MAX_RPAYLOAD_LEN = 498


import logging
from twisted.internet import defer
from oppy.cell.definitions import MAX_RPAYLOAD_LEN
        # XXX we should be checking how many cells we have left to flush
        #     here before just blindly writing a RELAY_SENDME
        self._deliver_window -= 1
        if self._deliver_window <= SENDME_THRESHOLD:
            self.circuit.sendStreamSendMe(self)
            self._deliver_window += STREAM_WINDOW_SIZE
        self._pollReadQueue()

    def _decPackageWindow(self):
        '''Decrement this stream's package window and, if we still can,
        listen for more data from the attached SOCKS protocol instance.

        If the package window <= 0, we need to wait until we receive a
        sendme cell before writing anymore local data from this stream to
        the attached circuit.
        '''
        self._package_window -= 1
        if self._package_window > 0:
            self._pollWriteQueue()
        else:
            self._write_deferred = None


def _chunkRelayData(data):
    '''Split *data* into chunks that can fit inside a RelayData cell.

    :param str data: data to split
    :returns **list, str** list of pieces of data split into sizes that
        fit into a RelayData cell
    '''

# Path: oppy/cell/definitions.py
# MAX_RPAYLOAD_LEN = 498


# Path: oppy/stream/stream.py
import logging
from twisted.internet import defer
from oppy.cell.definitions import MAX_RPAYLOAD_LEN

        # XXX we should be checking how many cells we have left to flush
        #     here before just blindly writing a RELAY_SENDME
        self._deliver_window -= 1
        if self._deliver_window <= SENDME_THRESHOLD:
            self.circuit.sendStreamSendMe(self)
            self._deliver_window += STREAM_WINDOW_SIZE
        self._pollReadQueue()

    def _decPackageWindow(self):
        '''Decrement this stream's package window and, if we still can,
        listen for more data from the attached SOCKS protocol instance.

        If the package window <= 0, we need to wait until we receive a
        sendme cell before writing anymore local data from this stream to
        the attached circuit.
        '''
        self._package_window -= 1
        if self._package_window > 0:
            self._pollWriteQueue()
        else:
            self._write_deferred = None


def _chunkRelayData(data):
    '''Split *data* into chunks that can fit inside a RelayData cell.

    :param str data: data to split
    :returns **list, str** list of pieces of data split into sizes that
        fit into a RelayData cell
    '''

    LEN = MAX_RPAYLOAD_LEN