Typos and formatting
This commit is contained in:
parent
07722fb606
commit
2c72b337c1
|
@ -313,24 +313,28 @@ class receiveDataThread(threading.Thread):
|
||||||
|
|
||||||
def peerValidityChecks(self):
|
def peerValidityChecks(self):
|
||||||
if self.remoteProtocolVersion < 3:
|
if self.remoteProtocolVersion < 3:
|
||||||
self.sendDataThreadQueue.put((0, 'sendRawData', protocol.assembleErrorMessage(fatal=2, errorText="Your is using an old protocol. Closing connection.")))
|
self.sendDataThreadQueue.put((0, 'sendRawData',protocol.assembleErrorMessage(
|
||||||
|
fatal=2, errorText="Your is using an old protocol. Closing connection.")))
|
||||||
logger.debug ('Closing connection to old protocol version ' + str(self.remoteProtocolVersion) + ' node: ' + str(self.peer))
|
logger.debug ('Closing connection to old protocol version ' + str(self.remoteProtocolVersion) + ' node: ' + str(self.peer))
|
||||||
return False
|
return False
|
||||||
if self.timeOffset > 3600:
|
if self.timeOffset > 3600:
|
||||||
self.sendDataThreadQueue.put((0, 'sendRawData', protocol.assembleErrorMessage(fatal=2, errorText="Your time is too far in the future compared to mine. Closing connection.")))
|
self.sendDataThreadQueue.put((0, 'sendRawData', protocol.assembleErrorMessage(
|
||||||
logger.info("%s's time is too far in the future (%s seconds). Closing connection to it." % (self.peer, self.timeOffset))
|
fatal=2, errorText="Your time is too far in the future compared to mine. Closing connection.")))
|
||||||
|
logger.info("%s's time is too far in the future (%s seconds). Closing connection to it.", self.peer, self.timeOffset)
|
||||||
shared.timeOffsetWrongCount += 1
|
shared.timeOffsetWrongCount += 1
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
return False
|
return False
|
||||||
elif self.timeOffset < -3600:
|
elif self.timeOffset < -3600:
|
||||||
self.sendDataThreadQueue.put((0, 'sendRawData', protocol.assembleErrorMessage(fatal=2, errorText="Your time is too far in the past compared to mine. Closing connection.")))
|
self.sendDataThreadQueue.put((0, 'sendRawData', protocol.assembleErrorMessage(
|
||||||
logger.info("%s's time is too far in the past (timeOffset %s seconds). Closing connection to it." % (self.peer, self.timeOffset))
|
fatal=2, errorText="Your time is too far in the past compared to mine. Closing connection.")))
|
||||||
|
logger.info("%s's time is too far in the past (timeOffset %s seconds). Closing connection to it.", self.peer, self.timeOffset)
|
||||||
shared.timeOffsetWrongCount += 1
|
shared.timeOffsetWrongCount += 1
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
shared.timeOffsetWrongCount = 0
|
shared.timeOffsetWrongCount = 0
|
||||||
if len(self.streamNumber) == 0:
|
if len(self.streamNumber) == 0:
|
||||||
self.sendDataThreadQueue.put((0, 'sendRawData', protocol.assembleErrorMessage(fatal=2, errorText="We don't have shared stream interests. Closing connection.")))
|
self.sendDataThreadQueue.put((0, 'sendRawData', protocol.assembleErrorMessage(
|
||||||
|
fatal=2, errorText="We don't have shared stream interests. Closing connection.")))
|
||||||
logger.debug ('Closed connection to ' + str(self.peer) + ' because there is no overlapping interest in streams.')
|
logger.debug ('Closed connection to ' + str(self.peer) + ' because there is no overlapping interest in streams.')
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
@ -754,7 +758,7 @@ class receiveDataThread(threading.Thread):
|
||||||
|
|
||||||
# version check
|
# version check
|
||||||
try:
|
try:
|
||||||
userAgentName, userAgentVersion = userAgent[1:-1].split(":", 2)
|
userAgentName, userAgentVersion = self.userAgent[1:-1].split(":", 2)
|
||||||
except:
|
except:
|
||||||
userAgentName = self.userAgent
|
userAgentName = self.userAgent
|
||||||
userAgentVersion = "0.0.0"
|
userAgentVersion = "0.0.0"
|
||||||
|
@ -781,7 +785,8 @@ class receiveDataThread(threading.Thread):
|
||||||
newStreamNumber, lengthOfRemoteStreamNumber = decodeVarint(data[readPosition:])
|
newStreamNumber, lengthOfRemoteStreamNumber = decodeVarint(data[readPosition:])
|
||||||
readPosition += lengthOfRemoteStreamNumber
|
readPosition += lengthOfRemoteStreamNumber
|
||||||
self.remoteStreams.append(newStreamNumber)
|
self.remoteStreams.append(newStreamNumber)
|
||||||
logger.debug('Remote node useragent: %s, streams: (%s), time offset: %is.', self.userAgent, ', '.join(str(x) for x in self.remoteStreams), self.timeOffset)
|
logger.debug('Remote node useragent: %s, streams: (%s), time offset: %is.',
|
||||||
|
self.userAgent, ', '.join(str(x) for x in self.remoteStreams), self.timeOffset)
|
||||||
|
|
||||||
# find shared streams
|
# find shared streams
|
||||||
self.streamNumber = sorted(set(state.streamsInWhichIAmParticipating).intersection(self.remoteStreams))
|
self.streamNumber = sorted(set(state.streamsInWhichIAmParticipating).intersection(self.remoteStreams))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user