udp pylint fixes

This commit is contained in:
lakshyacis 2019-09-12 15:24:18 +05:30
parent 498232dbea
commit e74affe636
No known key found for this signature in database
GPG Key ID: D2C539C8EC63E9EB

View File

@ -1,3 +1,7 @@
"""
src/network/udp.py
==================
"""
import time
import socket
@ -9,15 +13,16 @@ from objectracker import ObjectTracker
from queues import receiveDataQueue
class UDPSocket(BMProto):
class UDPSocket(BMProto): # pylint: disable=too-many-instance-attributes
"""Bitmessage protocol over UDP (class)"""
port = 8444
announceInterval = 60
def __init__(self, host=None, sock=None, announcing=False):
super(BMProto, self).__init__(sock=sock)
super(BMProto, self).__init__(sock=sock) # pylint: disable=bad-super-call
self.verackReceived = True
self.verackSent = True
# TODO sort out streams
# .. todo:: sort out streams
self.streams = [1]
self.fullyEstablished = True
self.connectedAt = 0
@ -44,6 +49,7 @@ class UDPSocket(BMProto):
self.set_state("bm_header", expectBytes=protocol.Header.size)
def set_socket_reuse(self):
"""Set socket reuse option"""
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
try:
@ -73,8 +79,7 @@ class UDPSocket(BMProto):
decodedIP = protocol.checkIPAddress(str(ip))
if stream not in state.streamsInWhichIAmParticipating:
continue
if (seenTime < time.time() - self.maxTimeOffset or
seenTime > time.time() + self.maxTimeOffset):
if (seenTime < time.time() - self.maxTimeOffset or seenTime > time.time() + self.maxTimeOffset):
continue
if decodedIP is False:
# if the address isn't local, interpret it as