1
+ """
2
+ src/network/udp.py
3
+ ==================
4
+ """
1
5
import time
2
6
import socket
3
7
9
13
from queues import receiveDataQueue
10
14
11
15
12
- class UDPSocket (BMProto ):
16
+ class UDPSocket (BMProto ): # pylint: disable=too-many-instance-attributes
17
+ """Bitmessage protocol over UDP (class)"""
13
18
port = 8444
14
19
announceInterval = 60
15
20
16
21
def __init__ (self , host = None , sock = None , announcing = False ):
17
- super (BMProto , self ).__init__ (sock = sock )
22
+ super (BMProto , self ).__init__ (sock = sock ) # pylint: disable=bad-super-call
18
23
self .verackReceived = True
19
24
self .verackSent = True
20
- # TODO sort out streams
25
+ # .. todo:: sort out streams
21
26
self .streams = [1 ]
22
27
self .fullyEstablished = True
23
28
self .connectedAt = 0
@@ -44,6 +49,7 @@ def __init__(self, host=None, sock=None, announcing=False):
44
49
self .set_state ("bm_header" , expectBytes = protocol .Header .size )
45
50
46
51
def set_socket_reuse (self ):
52
+ """Set socket reuse option"""
47
53
self .socket .setsockopt (socket .SOL_SOCKET , socket .SO_BROADCAST , 1 )
48
54
self .socket .setsockopt (socket .SOL_SOCKET , socket .SO_REUSEADDR , 1 )
49
55
try :
@@ -73,8 +79,7 @@ def bm_command_addr(self):
73
79
decodedIP = protocol .checkIPAddress (str (ip ))
74
80
if stream not in state .streamsInWhichIAmParticipating :
75
81
continue
76
- if (seenTime < time .time () - self .maxTimeOffset or
77
- seenTime > time .time () + self .maxTimeOffset ):
82
+ if (seenTime < time .time () - self .maxTimeOffset or seenTime > time .time () + self .maxTimeOffset ):
78
83
continue
79
84
if decodedIP is False :
80
85
# if the address isn't local, interpret it as
0 commit comments