- version command sends list of all participating streams
- biginv sends lists of hosts for all streams the peer wants (plus
immediate children)
- objects will spread to all peers that advertise the associated stream
- please note these are just network subsystem adjustments, streams
aren't actually usable yet
@ -70,7 +71,7 @@ class receiveDataThread(threading.Thread):
self.hostIdent]=0# The very fact that this receiveData thread exists shows that we are connected to the remote host. Let's add it to this list so that an outgoingSynSender thread doesn't try to connect to it.
self.connectionIsOrWasFullyEstablished=False# set to true after the remote node and I accept each other's version messages. This is needed to allow the user interface to accurately reflect the current number of connections.
self.services=0
ifself.streamNumber==-1:# This was an incoming connection. Send out a version message if we accept the other node's version message.
ifstreamNumber==-1:# This was an incoming connection. Send out a version message if we accept the other node's version message.
self.initiatedConnection=False
else:
self.initiatedConnection=True
@ -120,7 +121,11 @@ class receiveDataThread(threading.Thread):
@ -182,7 +188,8 @@ class receiveDataThread(threading.Thread):
# that other peers can be made aware of its existance.
ifself.initiatedConnectionandself.connectionIsOrWasFullyEstablished:# The remote port is only something we should share with others if it is the remote node's incoming port (rather than some random operating-system-assigned outgoing port).
logger.info('inv message lists %s objects. Of those %s are new to me. It took %s seconds to figure that out.',numberOfItemsInInv,len(objectsNewToMe),time.time()-startTime)
foriteminobjectsNewToMe:
PendingDownload().add(item)
@ -532,7 +543,7 @@ class receiveDataThread(threading.Thread):
38*i):12+lengthOfNumberOfAddresses+(38*i)])
ifrecaddrStream==0:
continue
ifrecaddrStream!=self.streamNumberandrecaddrStream!=(self.streamNumber*2)andrecaddrStream!=((self.streamNumber*2)+1):# if the embedded stream number is not in my stream or either of my child streams then ignore it. Someone might be trying funny business.
ifrecaddrStreamnotinself.streamNumberand(recaddrStream/2)notinself.streamNumber:# if the embedded stream number and its parent are not in my streams then ignore it. Someone might be trying funny business.
logger.debug('Closed connection to '+str(self.peer)+' because they are interested in stream '+str(self.streamNumber)+'.')
logger.debug('Closed connection to '+str(self.peer)+' because there is no overlapping interest in streams.')
return
shared.connectedHostsList[
self.hostIdent]=1# We use this data structure to not only keep track of what hosts we are connected to so that we don't try to connect to them again, but also to list the connections count on the Network Status tab.
# If this was an incoming connection, then the sendDataThread
ifself.streamNumber==-1:# This was an incoming connection.
ifstreamNumber==-1:# This was an incoming connection.
self.initiatedConnection=False
else:
self.initiatedConnection=True
logger.debug('The streamNumber of this sendDataThread (ID: '+str(id(self))+') at setup() is'+str(self.streamNumber))
#logger.debug('The streamNumber of this sendDataThread (ID: ' + str(id(self)) + ') at setup() is' + str(self.streamNumber))
defsendVersionMessage(self):
datatosend=protocol.assembleVersionMessage(
self.peer.host,self.peer.port,self.streamNumber,notself.initiatedConnection)# the IP and port of the remote host, and my streamNumber.
self.peer.host,self.peer.port,state.streamsInWhichIAmParticipating,notself.initiatedConnection)# the IP and port of the remote host, and my streamNumber.
logger.debug('Sending version packet: '+repr(datatosend))
@ -102,7 +102,7 @@ class sendDataThread(threading.Thread):
logger.debug('sendDataThread (associated with '+str(self.peer)+') ID: '+str(id(self))+' shutting down now.')
break
@ -114,7 +114,7 @@ class sendDataThread(threading.Thread):
# streamNumber of this send data thread here:
elifcommand=='setStreamNumber':
self.streamNumber=data
logger.debug('setting the stream number in the sendData thread (ID: '+str(id(self))+') to '+str(self.streamNumber))
logger.debug('setting the stream number to %s',', '.join(str(x)forxinself.streamNumber))
elifcommand=='setRemoteProtocolVersion':
specifiedRemoteProtocolVersion=data
logger.debug('setting the remote node\'s protocol version in the sendDataThread (ID: '+str(id(self))+') to '+str(specifiedRemoteProtocolVersion))
@ -183,7 +183,7 @@ class sendDataThread(threading.Thread):
self.connectionIsOrWasFullyEstablished=True
self.services,self.sslSock=data
elifself.connectionIsOrWasFullyEstablished:
logger.error('sendDataThread ID: '+str(id(self))+' ignoring command '+command+' because the thread is not in stream '+str(deststream))
logger.error('sendDataThread ID: '+str(id(self))+' ignoring command '+command+' because the thread is not in stream '+str(deststream)+' but in streams '+', '.join(str(x)forxinself.streamNumber))