From d34114d14c8cf2595199c2fab03f8b4b7d518de1 Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Wed, 6 Nov 2013 23:38:19 -0500 Subject: [PATCH] Fix #541 --- src/class_singleWorker.py | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/class_singleWorker.py b/src/class_singleWorker.py index 2680f307..59d72ac3 100644 --- a/src/class_singleWorker.py +++ b/src/class_singleWorker.py @@ -147,17 +147,26 @@ class singleWorker(threading.Thread): shared.broadcastToSendDataQueues(( streamNumber, 'advertiseobject', inventoryHash)) shared.UISignalQueue.put(('updateStatusBar', '')) - shared.config.set( - myAddress, 'lastpubkeysendtime', str(int(time.time()))) - with open(shared.appdata + 'keys.dat', 'wb') as configfile: - shared.config.write(configfile) + try: + shared.config.set( + myAddress, 'lastpubkeysendtime', str(int(time.time()))) + with open(shared.appdata + 'keys.dat', 'wb') as configfile: + shared.config.write(configfile) + except: + # The user deleted the address out of the keys.dat file before this + # finished. + pass # If this isn't a chan address, this function assembles the pubkey data, # does the necessary POW and sends it out. If it *is* a chan then it # assembles the pubkey and stores is in the pubkey table so that we can # send messages to "ourselves". def sendOutOrStoreMyV3Pubkey(self, hash): - myAddress = shared.myAddressesByHash[hash] + try: + myAddress = shared.myAddressesByHash[hash] + except: + #The address has been deleted. + return if shared.safeConfigGetBoolean(myAddress, 'chan'): with shared.printLock: print 'This is a chan address. Not sending pubkey.' @@ -224,14 +233,22 @@ class singleWorker(threading.Thread): shared.broadcastToSendDataQueues(( streamNumber, 'advertiseobject', inventoryHash)) shared.UISignalQueue.put(('updateStatusBar', '')) - shared.config.set( - myAddress, 'lastpubkeysendtime', str(int(time.time()))) - with open(shared.appdata + 'keys.dat', 'wb') as configfile: - shared.config.write(configfile) + try: + shared.config.set( + myAddress, 'lastpubkeysendtime', str(int(time.time()))) + with open(shared.appdata + 'keys.dat', 'wb') as configfile: + shared.config.write(configfile) + except: + # The user deleted the address out of the keys.dat file before this + # finished. + pass # If this isn't a chan address, this function assembles the pubkey data, # does the necessary POW and sends it out. def sendOutOrStoreMyV4Pubkey(self, myAddress): + if not shared.config.has_section(myAddress): + #The address has been deleted. + return if shared.safeConfigGetBoolean(myAddress, 'chan'): with shared.printLock: print 'This is a chan address. Not sending pubkey.'