- rearranged code to reduce cyclic dependencies
- doCleanShutdown is separated in shutdown.py
- shared queues are separated in queues.py
- some default values were moved to defaults.py
- knownnodes partially moved to knownnodes.py
@ -349,13 +350,13 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
raiseAPIError(4,'Why would you ask me to generate 0 addresses for you?')
ifnumberOfAddresses>999:
raiseAPIError(5,'You have (accidentally?) specified too many addresses to make. Maximum 999. This check only exists to prevent mischief; if you really want to create more addresses than this, contact the Bitmessage developers and we can modify the check or you can do it yourself by searching the source code for this message.')
@ -329,7 +330,7 @@ class objectProcessor(threading.Thread):
'ackreceived',
int(time.time()),
data[-32:])
shared.UISignalQueue.put(('updateSentItemStatusByAckdata',(data[-32:],tr._translate("MainWindow",'Acknowledgement of the message received %1').arg(l10n.formatTimestamp()))))
queues.UISignalQueue.put(('updateSentItemStatusByAckdata',(data[-32:],tr._translate("MainWindow",'Acknowledgement of the message received %1').arg(l10n.formatTimestamp()))))
return
else:
logger.info('This was NOT an acknowledgement bound for me.')
@ -505,7 +506,7 @@ class objectProcessor(threading.Thread):
# If we are behaving as an API then we might need to run an
@ -808,7 +809,7 @@ class objectProcessor(threading.Thread):
sqlExecute(
'''UPDATE sent SET status='doingmsgpow', retrynumber=0 WHERE toaddress=? AND (status='awaitingpubkey' or status='doingpubkeypow') AND folder='sent'''',
if(int(time.time())-timeLastSeen)>172800andlen(shared.knownNodes[self.streamNumber])>1000:# for nodes older than 48 hours old if we have more than 1000 hosts in our list, delete from the shared.knownNodes data-structure.
if(int(time.time())-timeLastSeen)>172800andlen(knownnodes.knownNodes[self.streamNumber])>1000:# for nodes older than 48 hours old if we have more than 1000 hosts in our list, delete from the knownnodes.knownNodes data-structure.
delknownnodes.knownNodes[self.streamNumber][peer]
deletedPeer=peer
ifdeletedPeer:
str('deleting '+str(peer)+' from shared.knownNodes because it is more than 48 hours old and we could not connect to it.')
str('deleting '+str(peer)+' from knownnodes.knownNodes because it is more than 48 hours old and we could not connect to it.')
exceptsocks.Socks5AuthErroraserr:
shared.UISignalQueue.put((
queues.UISignalQueue.put((
'updateStatusBar',tr._translate(
"MainWindow","SOCKS5 Authentication problem: %1. Please check your SOCKS5 settings.").arg(str(err))))
exceptsocks.Socks5Erroraserr:
@ -272,22 +274,22 @@ class outgoingSynSender(threading.Thread, StoppableThread):
logger.debug('Could NOT connect to '+str(peer)+'during outgoing attempt. '+str(err))
if(int(time.time())-timeLastSeen)>172800andlen(shared.knownNodes[self.streamNumber])>1000:# for nodes older than 48 hours old if we have more than 1000 hosts in our list, delete from the shared.knownNodes data-structure.
if(int(time.time())-timeLastSeen)>172800andlen(knownnodes.knownNodes[self.streamNumber])>1000:# for nodes older than 48 hours old if we have more than 1000 hosts in our list, delete from the knownnodes.knownNodes data-structure.
delknownnodes.knownNodes[self.streamNumber][peer]
deletedPeer=peer
ifdeletedPeer:
logger.debug('deleting '+str(peer)+' from shared.knownNodes because it is more than 48 hours old and we could not connect to it.')
logger.debug('deleting '+str(peer)+' from knownnodes.knownNodes because it is more than 48 hours old and we could not connect to it.')
shared.UISignalQueue.put(('updateStatusBar',tr._translate("MainWindow","The time on your computer, %1, may be wrong. Please verify your settings.").arg(datetime.datetime.now().strftime("%H:%M:%S"))))
queues.UISignalQueue.put(('updateStatusBar',tr._translate("MainWindow","The time on your computer, %1, may be wrong. Please verify your settings.").arg(datetime.datetime.now().strftime("%H:%M:%S"))))
defprocessData(self):
iflen(self.data)<protocol.Header.size:# if so little of the data has arrived that we can't even read the checksum then wait for more data.
@ -198,9 +200,9 @@ class receiveDataThread(threading.Thread):
# just received valid data from it. So update the knownNodes list so
# 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).
38*i):8+lengthOfNumberOfAddresses+(38*i)])# This is the 'time' value in the received addr message. 64-bit.
ifrecaddrStreamnotinshared.knownNodes:# knownNodes is a dictionary of dictionaries with one outer dictionary for each stream. If the outer stream dictionary doesn't exist yet then we must make it.
withshared.knownNodesLock:
shared.knownNodes[recaddrStream]={}
ifrecaddrStreamnotinknownnodes.knownNodes:# knownNodes is a dictionary of dictionaries with one outer dictionary for each stream. If the outer stream dictionary doesn't exist yet then we must make it.
iflen(shared.knownNodes[recaddrStream])<20000andtimeSomeoneElseReceivedMessageFromThisNode>(int(time.time())-10800)andtimeSomeoneElseReceivedMessageFromThisNode<(int(time.time())+10800):# If we have more than 20000 nodes in our list already then just forget about adding more. Also, make sure that the time that someone else received a message from this node is within three hours from now.
iflen(knownnodes.knownNodes[recaddrStream])<20000andtimeSomeoneElseReceivedMessageFromThisNode>(int(time.time())-10800)andtimeSomeoneElseReceivedMessageFromThisNode<(int(time.time())+10800):# If we have more than 20000 nodes in our list already then just forget about adding more. Also, make sure that the time that someone else received a message from this node is within three hours from now.
if(timeLastReceivedMessageFromThisNode<timeSomeoneElseReceivedMessageFromThisNode)and(timeSomeoneElseReceivedMessageFromThisNode<int(time.time())+900):# 900 seconds for wiggle-room in case other nodes' clocks aren't quite right.