def HandleRequest(self, msg_request):
"""Handle incomming REQUEST message"""
for x in range(msg_request.start_chunk, msg_request.end_chunk + 1):
# Ignore requests for discarded chunks
if x <= self._swarm._last_discarded_id:
continue
self.set_requested.add(x)
# TODO: We might want a more intelligent ACK mechanism than this, but this works well for now
self.set_sent.discard(x)
if self._logger.isEnabledFor(logging.DEBUG):
logging.debug("FROM > {0} > REQUEST: {1}".format(self._peer_num, msg_request))
# Try to send some data
if self._sending_handle == None:
self._sending_handle = asyncio.get_event_loop().call_soon(self.SendRequestedChunks)
评论列表
文章目录