# print 'The magic bytes were not correct. First 40 bytes of data: ' + repr(self.data[0:40])
self.data=""
return
ifpayloadLength>20000000:
logger.info('The incoming message, which we have not yet download, is too large. Ignoring it. (unfortunately there is no way to tell the other node to stop sending it except to disconnect.) Message size: %s'%payloadLength)
self.data=view[payloadLength:].tobytes()
delview,magic,command,payloadLength,checksum# we don't need these anymore and better to clean them now before the recursive call rather than after
self.peer]# this data structure is maintained so that we can keep track of how many total objects, across all connections, are currently outstanding. If it goes too high it can indicate that we are under attack by multiple nodes working together.
@ -221,9 +208,9 @@ class receiveDataThread(threading.Thread):
self.peer]# this data structure is maintained so that we can keep track of how many total objects, across all connections, are currently outstanding. If it goes too high it can indicate that we are under attack by multiple nodes working together.
@ -239,12 +226,14 @@ class receiveDataThread(threading.Thread):
self.someObjectsOfWhichThisRemoteNodeIsAlreadyAware.clear()# To save memory, let us clear this data structure from time to time. As its function is to help us keep from sending inv messages to peers which sent us the same inv message mere seconds earlier, it will be fine to clear this data structure from time to time.
ifself.lastTimeISentData<(int(time.time())-298):
@ -148,16 +143,16 @@ class sendDataThread(threading.Thread):
packet=shared.CreatePacket('pong')
try:
self.sendBytes(packet)
self.lastTimeISentData=int(time.time())
except:
print'send pong failed'
withshared.printLock:
print'send pong failed'
break
elifcommand=='sendRawData':
try:
self.sendBytes(data)
self.lastTimeISentData=int(time.time())
except:
print'Sending of data to',self.peer,'failed. sendDataThread thread',self,'ending now.'
withshared.printLock:
print'Sending of data to',self.peer,'failed. sendDataThread thread',self,'ending now.'
break
elifcommand=='connectionIsOrWasFullyEstablished':
self.connectionIsOrWasFullyEstablished=True
@ -172,5 +167,5 @@ class sendDataThread(threading.Thread):