Merge pull request #185 from Atheros1/master

initilize the ackdataForWhichImWatching data structure within the single worker thread
This commit is contained in:
Jonathan Warren 2013-06-03 12:50:48 -07:00
commit e721d3b1c0
2 changed files with 21 additions and 14 deletions

View File

@ -2626,7 +2626,7 @@ class singleWorker(threading.Thread):
def run(self): def run(self):
shared.sqlLock.acquire() 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('') shared.sqlSubmitQueue.put('')
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlLock.release() shared.sqlLock.release()
@ -2634,6 +2634,17 @@ class singleWorker(threading.Thread):
toripe, = row toripe, = row
neededPubkeys[toripe] = 0 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.sqlLock.acquire()
shared.sqlSubmitQueue.put('''SELECT DISTINCT toaddress FROM sent WHERE (status='doingpubkeypow' AND folder='sent')''') shared.sqlSubmitQueue.put('''SELECT DISTINCT toaddress FROM sent WHERE (status='doingpubkeypow' AND folder='sent')''')
shared.sqlSubmitQueue.put('') shared.sqlSubmitQueue.put('')
@ -2643,7 +2654,7 @@ class singleWorker(threading.Thread):
toaddress, = row toaddress, = row
self.requestPubKey(toaddress) 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.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. 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): def sendMsg(self):
#Check to see if there are any messages queued to be sent #Check to see if there are any messages queued to be sent
shared.sqlLock.acquire() 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('') shared.sqlSubmitQueue.put('')
queryreturn = shared.sqlReturnQueue.get() queryreturn = shared.sqlReturnQueue.get()
shared.sqlLock.release() shared.sqlLock.release()
@ -3194,6 +3205,11 @@ class singleWorker(threading.Thread):
def requestPubKey(self,toAddress): def requestPubKey(self,toAddress):
toStatus,addressVersionNumber,streamNumber,ripe = decodeAddress(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 neededPubkeys[ripe] = 0
payload = pack('>I',(int(time.time())+random.randrange(-300, 300)))#the current time plus or minus five minutes. payload = pack('>I',(int(time.time())+random.randrange(-300, 300)))#the current time plus or minus five minutes.
payload += encodeVarint(addressVersionNumber) payload += encodeVarint(addressVersionNumber)
@ -4054,15 +4070,6 @@ if __name__ == "__main__":
shared.reloadMyAddressHashes() shared.reloadMyAddressHashes()
shared.reloadBroadcastSendersForWhichImWatching() 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'): if shared.safeConfigGetBoolean('bitmessagesettings','apienabled'):
try: try:
apiNotifyPath = shared.config.get('bitmessagesettings','apinotifypath') apiNotifyPath = shared.config.get('bitmessagesettings','apinotifypath')

View File

@ -529,7 +529,7 @@ class MyForm(QtGui.QMainWindow):
# create application indicator # create application indicator
def appIndicatorInit(self,app): 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': if sys.platform[0:3] == 'win':
traySignal = "activated(QSystemTrayIcon::ActivationReason)" traySignal = "activated(QSystemTrayIcon::ActivationReason)"
QtCore.QObject.connect(self.tray, QtCore.SIGNAL(traySignal), self.__icon_activated) QtCore.QObject.connect(self.tray, QtCore.SIGNAL(traySignal), self.__icon_activated)