Merge pull request #92 from Atheros1/master

Fix bug introduced in last commit by tpltnt: exception when updating status
This commit is contained in:
Jonathan Warren 2013-04-01 09:40:21 -07:00
commit 872cae5ff1
2 changed files with 30 additions and 31 deletions

View File

@ -1252,10 +1252,11 @@ class receiveDataThread(QThread):
#We have received a getdata request from our peer #We have received a getdata request from our peer
def recgetdata(self, data): def recgetdata(self, data):
value, lengthOfVarint = decodeVarint(data[:10]) numberOfRequestedInventoryItems, lengthOfVarint = decodeVarint(data[:10])
#print 'Number of items in getdata request:', value if len(data) < lengthOfVarint + (32 * numberOfRequestedInventoryItems):
try: print 'getdata message does not contain enough data. Ignoring.'
for i in xrange(value): return
for i in xrange(numberOfRequestedInventoryItems):
hash = data[lengthOfVarint+(i*32):32+lengthOfVarint+(i*32)] hash = data[lengthOfVarint+(i*32):32+lengthOfVarint+(i*32)]
printLock.acquire() printLock.acquire()
print 'received getdata request for item:', hash.encode('hex') print 'received getdata request for item:', hash.encode('hex')
@ -1278,9 +1279,6 @@ class receiveDataThread(QThread):
else: else:
print 'Someone asked for an object with a getdata which is not in either our memory inventory or our SQL inventory. That shouldn\'t have happened.' print 'Someone asked for an object with a getdata which is not in either our memory inventory or our SQL inventory. That shouldn\'t have happened.'
except:
pass #someone is probably trying to cause a program error by, for example, making a request for 10 items but only including the hashes for 5.
#Our peer has requested (in a getdata message) that we send an object. #Our peer has requested (in a getdata message) that we send an object.
def sendData(self,objectType,payload): def sendData(self,objectType,payload):
if objectType == 'pubkey': if objectType == 'pubkey':
@ -1343,7 +1341,7 @@ class receiveDataThread(QThread):
if numberOfAddressesIncluded > 1000 or numberOfAddressesIncluded == 0: if numberOfAddressesIncluded > 1000 or numberOfAddressesIncluded == 0:
return return
if self.payloadLength < lengthOfNumberOfAddresses + (34 * numberOfAddressesIncluded): if len(data) < lengthOfNumberOfAddresses + (34 * numberOfAddressesIncluded):
print 'addr message does not contain enough data. Ignoring.' print 'addr message does not contain enough data. Ignoring.'
return return
@ -2298,7 +2296,7 @@ class singleWorker(QThread):
print 'sending inv (within sendBroadcast function)' print 'sending inv (within sendBroadcast function)'
broadcastToSendDataQueues((streamNumber, 'sendinv', inventoryHash)) broadcastToSendDataQueues((streamNumber, 'sendinv', inventoryHash))
self.emit(SIGNAL("updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"),ackdata,'Broadcast sent at '+unicode(strftime(config.get('bitmessagesettings', 'timeformat'),localtime(int(time.time()))))) self.emit(SIGNAL("updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"),ackdata,'Broadcast sent on '+unicode(strftime(config.get('bitmessagesettings', 'timeformat'),localtime(int(time.time())))))
#Update the status of the message in the 'sent' table to have a 'broadcastsent' status #Update the status of the message in the 'sent' table to have a 'broadcastsent' status
sqlLock.acquire() sqlLock.acquire()
@ -3903,7 +3901,8 @@ class MyForm(QtGui.QMainWindow):
tableAckdata = self.ui.tableWidgetSent.item(i,3).data(Qt.UserRole).toPyObject() tableAckdata = self.ui.tableWidgetSent.item(i,3).data(Qt.UserRole).toPyObject()
status,addressVersionNumber,streamNumber,ripe = decodeAddress(toAddress) status,addressVersionNumber,streamNumber,ripe = decodeAddress(toAddress)
if ackdata == tableAckdata: if ackdata == tableAckdata:
self.ui.tableWidgetSent.item(i,3).setText(unicode(textToDisplay,'utf-8')) #self.ui.tableWidgetSent.item(i,3).setText(unicode(textToDisplay,'utf-8'))
self.ui.tableWidgetSent.item(i,3).setText(textToDisplay)
def rerenderInboxFromLabels(self): def rerenderInboxFromLabels(self):
for i in range(self.ui.tableWidgetInbox.rowCount()): for i in range(self.ui.tableWidgetInbox.rowCount()):

View File

@ -90,10 +90,10 @@ def takeSentMessagesOutOfTrash():
#takeInboxMessagesOutOfTrash() #takeInboxMessagesOutOfTrash()
#takeSentMessagesOutOfTrash() #takeSentMessagesOutOfTrash()
readInbox() #readInbox()
#readSent() #readSent()
#readPubkeys() #readPubkeys()
#readSubscriptions() #readSubscriptions()
#readInventory() readInventory()