From 483e51ad0473426373deabd8efc7dc025346510a Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Mon, 3 Jun 2013 15:48:53 -0400 Subject: [PATCH] initilize the ackdataForWhichImWatching data structure within the single worker thread --- src/bitmessagemain.py | 31 +++++++++++++++++++------------ src/bitmessageqt/__init__.py | 4 ++-- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index 100d6d30..c12be4d3 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -2626,7 +2626,7 @@ class singleWorker(threading.Thread): def run(self): shared.sqlLock.acquire() - shared.sqlSubmitQueue.put('''SELECT toripe FROM sent WHERE (status='awaitingpubkey' AND folder='sent')''') + shared.sqlSubmitQueue.put('''SELECT toripe FROM sent WHERE ((status='awaitingpubkey' OR status='doingpubkeypow') AND folder='sent')''') shared.sqlSubmitQueue.put('') queryreturn = shared.sqlReturnQueue.get() shared.sqlLock.release() @@ -2634,6 +2634,17 @@ class singleWorker(threading.Thread): toripe, = row neededPubkeys[toripe] = 0 + #Initialize the ackdataForWhichImWatching data structure using data from the sql database. + shared.sqlLock.acquire() + shared.sqlSubmitQueue.put('''SELECT ackdata FROM sent where (status='msgsent' OR status='doingmsgpow')''') + shared.sqlSubmitQueue.put('') + queryreturn = shared.sqlReturnQueue.get() + shared.sqlLock.release() + for row in queryreturn: + ackdata, = row + print 'Watching for ackdata', ackdata.encode('hex') + ackdataForWhichImWatching[ackdata] = 0 + shared.sqlLock.acquire() shared.sqlSubmitQueue.put('''SELECT DISTINCT toaddress FROM sent WHERE (status='doingpubkeypow' AND folder='sent')''') shared.sqlSubmitQueue.put('') @@ -2643,7 +2654,7 @@ class singleWorker(threading.Thread): toaddress, = row self.requestPubKey(toaddress) - time.sleep(10) #give some time for the GUI to start before we start on any existing POW tasks. + time.sleep(10) #give some time for the GUI to start before we start on existing POW tasks. self.sendMsg() #just in case there are any pending tasks for msg messages that have yet to be sent. self.sendBroadcast() #just in case there are any tasks for Broadcasts that have yet to be sent. @@ -2950,7 +2961,7 @@ class singleWorker(threading.Thread): def sendMsg(self): #Check to see if there are any messages queued to be sent shared.sqlLock.acquire() - shared.sqlSubmitQueue.put('''SELECT toaddress FROM sent WHERE (status='msgqueued' AND folder='sent')''') + shared.sqlSubmitQueue.put('''SELECT DISTINCT toaddress FROM sent WHERE (status='msgqueued' AND folder='sent')''') shared.sqlSubmitQueue.put('') queryreturn = shared.sqlReturnQueue.get() shared.sqlLock.release() @@ -3194,6 +3205,11 @@ class singleWorker(threading.Thread): def requestPubKey(self,toAddress): toStatus,addressVersionNumber,streamNumber,ripe = decodeAddress(toAddress) + if toStatus != 'success': + shared.printLock.acquire() + sys.stderr.write('Very abnormal error occurred in requestPubKey. toAddress is: '+repr(toAddress)+'. Please report this error to Atheros.') + shared.printLock.release() + return neededPubkeys[ripe] = 0 payload = pack('>I',(int(time.time())+random.randrange(-300, 300)))#the current time plus or minus five minutes. payload += encodeVarint(addressVersionNumber) @@ -4054,15 +4070,6 @@ if __name__ == "__main__": shared.reloadMyAddressHashes() shared.reloadBroadcastSendersForWhichImWatching() - #Initialize the ackdataForWhichImWatching data structure using data from the sql database. - shared.sqlSubmitQueue.put('''SELECT ackdata FROM sent where (status='msgsent' OR status='doingmsgpow')''') - shared.sqlSubmitQueue.put('') - queryreturn = shared.sqlReturnQueue.get() - for row in queryreturn: - ackdata, = row - print 'Watching for ackdata', ackdata.encode('hex') - ackdataForWhichImWatching[ackdata] = 0 - if shared.safeConfigGetBoolean('bitmessagesettings','apienabled'): try: apiNotifyPath = shared.config.get('bitmessagesettings','apinotifypath') diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index 2326bf53..0179ff7f 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -529,7 +529,7 @@ class MyForm(QtGui.QMainWindow): # create application indicator def appIndicatorInit(self,app): - self.tray = QSystemTrayIcon(QtGui.QIcon("images/can-icon-24px-red.png"), app) + self.tray = QSystemTrayIcon(QtGui.QIcon(":/newPrefix/images/can-icon-24px-red.png"), app) if sys.platform[0:3] == 'win': traySignal = "activated(QSystemTrayIcon::ActivationReason)" QtCore.QObject.connect(self.tray, QtCore.SIGNAL(traySignal), self.__icon_activated) @@ -1979,7 +1979,7 @@ class MyForm(QtGui.QMainWindow): if len(self.ui.tableWidgetInbox.item(currentRow,2).data(Qt.UserRole).toPyObject()) < 30000: self.ui.textEditInboxMessage.setPlainText(self.ui.tableWidgetInbox.item(currentRow,2).data(Qt.UserRole).toPyObject())#Only show the first 30K characters else: - self.ui.textEditInboxMessage.setPlainText(self.ui.tableWidgetInbox.item(currentRow,2).data(Qt.UserRole).toPyObject()[:30000]+'\n\nDisplay of the remainder of the message truncated because it is too long.')#Only show the first 30K characters + self.ui.textEditInboxMessage.setPlainText(self.ui.tableWidgetInbox.item(currentRow,2).data(Qt.UserRole).toPyObject()[:30000]+'\n\nDisplay of the remainder of the message truncated because it is too long.')#Only show the first 30K characters font = QFont() font.setBold(False)