Merge pull request #92 from Atheros1/master
Fix bug introduced in last commit by tpltnt: exception when updating status
This commit is contained in:
commit
872cae5ff1
|
@ -1252,34 +1252,32 @@ 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
|
||||||
hash = data[lengthOfVarint+(i*32):32+lengthOfVarint+(i*32)]
|
for i in xrange(numberOfRequestedInventoryItems):
|
||||||
printLock.acquire()
|
hash = data[lengthOfVarint+(i*32):32+lengthOfVarint+(i*32)]
|
||||||
print 'received getdata request for item:', hash.encode('hex')
|
printLock.acquire()
|
||||||
printLock.release()
|
print 'received getdata request for item:', hash.encode('hex')
|
||||||
#print 'inventory is', inventory
|
printLock.release()
|
||||||
if hash in inventory:
|
#print 'inventory is', inventory
|
||||||
objectType, streamNumber, payload, receivedTime = inventory[hash]
|
if hash in inventory:
|
||||||
|
objectType, streamNumber, payload, receivedTime = inventory[hash]
|
||||||
|
self.sendData(objectType,payload)
|
||||||
|
else:
|
||||||
|
t = (hash,)
|
||||||
|
sqlLock.acquire()
|
||||||
|
sqlSubmitQueue.put('''select objecttype, payload from inventory where hash=?''')
|
||||||
|
sqlSubmitQueue.put(t)
|
||||||
|
queryreturn = sqlReturnQueue.get()
|
||||||
|
sqlLock.release()
|
||||||
|
if queryreturn <> []:
|
||||||
|
for row in queryreturn:
|
||||||
|
objectType, payload = row
|
||||||
self.sendData(objectType,payload)
|
self.sendData(objectType,payload)
|
||||||
else:
|
else:
|
||||||
t = (hash,)
|
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.'
|
||||||
sqlLock.acquire()
|
|
||||||
sqlSubmitQueue.put('''select objecttype, payload from inventory where hash=?''')
|
|
||||||
sqlSubmitQueue.put(t)
|
|
||||||
queryreturn = sqlReturnQueue.get()
|
|
||||||
sqlLock.release()
|
|
||||||
if queryreturn <> []:
|
|
||||||
for row in queryreturn:
|
|
||||||
objectType, payload = row
|
|
||||||
self.sendData(objectType,payload)
|
|
||||||
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.
|
#Our peer has requested (in a getdata message) that we send an object.
|
||||||
def sendData(self,objectType,payload):
|
def sendData(self,objectType,payload):
|
||||||
|
@ -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()):
|
||||||
|
|
|
@ -90,10 +90,10 @@ def takeSentMessagesOutOfTrash():
|
||||||
|
|
||||||
#takeInboxMessagesOutOfTrash()
|
#takeInboxMessagesOutOfTrash()
|
||||||
#takeSentMessagesOutOfTrash()
|
#takeSentMessagesOutOfTrash()
|
||||||
readInbox()
|
#readInbox()
|
||||||
#readSent()
|
#readSent()
|
||||||
#readPubkeys()
|
#readPubkeys()
|
||||||
#readSubscriptions()
|
#readSubscriptions()
|
||||||
#readInventory()
|
readInventory()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user