@ -206,8 +206,8 @@ class singleListener(threading.Thread):
time.sleep(10)
a,(HOST,PORT)=sock.accept()
#Users are finding that if they run more than one node in the same network (thus with the same public IP), they can not connect with the second node. This is because this section of code won't accept the connection from the same IP. This problem will go away when the Bitmessage network grows beyond being tiny but in the mean time I'll comment out this code section.
"""while HOST in connectedHostsList:
print'incoming connection is from a host in connectedHostsList (we are already connected to it). Ignoring it.'
"""while HOST in shared.connectedHostsList:
print'incoming connection is from a host in shared.connectedHostsList (we are already connected to it). Ignoring it.'
a.close()
a,(HOST,PORT)=sock.accept()"""
rd=receiveDataThread()
@ -242,7 +242,7 @@ class receiveDataThread(threading.Thread):
self.payloadLength=0#This is the protocol payload length thus it doesn't include the 24 byte message header
self.receivedgetbiginv=False#Gets set to true once we receive a getbiginv message from our peer. An abusive peer might request it too much so we use this variable to check whether they have already asked for a big inv message.
connectedHostsList[self.HOST]=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.
shared.connectedHostsList[self.HOST]=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.
ifself.streamNumber==-1:#This was an incoming connection. Send out a version message if we accept the other node's version message.
self.initiatedConnection=False
@ -254,7 +254,7 @@ class receiveDataThread(threading.Thread):
defrun(self):
shared.printLock.acquire()
print'ID of the receiveDataThread is',str(id(self))+'. The size of the connectedHostsList is now',len(connectedHostsList)
print'ID of the receiveDataThread is',str(id(self))+'. The size of the shared.connectedHostsList is now',len(shared.connectedHostsList)
shared.printLock.release()
whileTrue:
try:
@ -294,21 +294,13 @@ class receiveDataThread(threading.Thread):
ifself.connectionIsOrWasFullyEstablished:#We don't want to decrement the number of connections and show the result if we never incremented it in the first place (which we only do if the connection is fully established- meaning that both nodes accepted each other's version packets.)
@ -1936,6 +1930,7 @@ class receiveDataThread(threading.Thread):
print'Closed connection to',self.HOST,'because they are interested in stream',self.streamNumber,'.'
shared.printLock.release()
return
shared.connectedHostsList[self.HOST]=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 sendData thread doesn't know the stream. We have to set it.
connectedHostsList={}#List of hosts to which we are connected. Used to guarantee that the outgoingSynSender threads won't connect to the same remote node twice.
neededPubkeys={}
successfullyDecryptMessageTimings=[]#A list of the amounts of time it took to successfully decrypt msg messages
#apiSignalQueue = Queue.Queue() #The singleAPI thread uses this queue to pass messages to a QT thread which can emit signals to do things like display a message in the UI.
totalNumberOfConnectionsFromAllStreams=0#One would think we could use len(sendDataQueues) for this but the number doesn't always match: just because we have a sendDataThread running doesn't mean that the connection has been fully established (with the exchange of version messages).
iftotalNumberOfConnectionsFromAllStreams>0andshared.statusIconColor=='red':#FYI: The 'singlelistener' thread sets the icon color to green when it receives an incoming connection, meaning that the user's firewall is configured correctly.
iflen(shared.connectedHostsList)>0andshared.statusIconColor=='red':#FYI: The 'singlelistener' thread sets the icon color to green when it receives an incoming connection, meaning that the user's firewall is configured correctly.
self.setStatusIcon('yellow')
eliftotalNumberOfConnectionsFromAllStreams==0:
eliflen(shared.connectedHostsList)==0:
self.setStatusIcon('red')
defsetStatusIcon(self,color):
@ -851,13 +867,13 @@ class MyForm(QtGui.QMainWindow):
@ -866,7 +882,7 @@ class MyForm(QtGui.QMainWindow):
#This function exists because of the API. The API thread starts an address generator thread and must somehow connect the address generator's signals to the QApplication thread. This function is used to connect the slots and signals.
#This function is called by the processmsg function when that function receives a message to an address that is acting as a pseudo-mailing-list. The message will be broadcast out. This function puts the message on the 'Sent' tab.
@ -26,6 +26,7 @@ inventoryLock = threading.Lock() #Guarantees that two receiveDataThreads don't r
printLock=threading.Lock()
appdata=''#holds the location of the application data storage directory
statusIconColor='red'
connectedHostsList={}#List of hosts to which we are connected. Used to guarantee that the outgoingSynSender threads won't connect to the same remote node twice.
#If changed, these values will cause particularly unexpected behavior: You won't be able to either send or receive messages because the proof of work you do (or demand) won't match that done or demanded by others. Don't change them!
networkDefaultProofOfWorkNonceTrialsPerByte=320#The amount of work that should be performed (and demanded) per byte of the payload. Double this number to double the work.