Fix bug introduced in last commit by tpltnt: exception when updating status #92

Merged
Atheros1 merged 1 commits from master into master 2013-04-01 18:40:21 +02:00
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
def recgetdata(self, data):
value, lengthOfVarint = decodeVarint(data[:10])
#print 'Number of items in getdata request:', value
try:
for i in xrange(value):
numberOfRequestedInventoryItems, lengthOfVarint = decodeVarint(data[:10])
if len(data) < lengthOfVarint + (32 * numberOfRequestedInventoryItems):
print 'getdata message does not contain enough data. Ignoring.'
return
for i in xrange(numberOfRequestedInventoryItems):
hash = data[lengthOfVarint+(i*32):32+lengthOfVarint+(i*32)]
printLock.acquire()
print 'received getdata request for item:', hash.encode('hex')
@ -1278,9 +1279,6 @@ class receiveDataThread(QThread):
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.'
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.
def sendData(self,objectType,payload):
if objectType == 'pubkey':
@ -1343,7 +1341,7 @@ class receiveDataThread(QThread):
if numberOfAddressesIncluded > 1000 or numberOfAddressesIncluded == 0:
return
if self.payloadLength < lengthOfNumberOfAddresses + (34 * numberOfAddressesIncluded):
if len(data) < lengthOfNumberOfAddresses + (34 * numberOfAddressesIncluded):
print 'addr message does not contain enough data. Ignoring.'
return
@ -2298,7 +2296,7 @@ class singleWorker(QThread):
print 'sending inv (within sendBroadcast function)'
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
sqlLock.acquire()
@ -3903,7 +3901,8 @@ class MyForm(QtGui.QMainWindow):
tableAckdata = self.ui.tableWidgetSent.item(i,3).data(Qt.UserRole).toPyObject()
status,addressVersionNumber,streamNumber,ripe = decodeAddress(toAddress)
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):
for i in range(self.ui.tableWidgetInbox.rowCount()):

View File

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