hopefully fixed block issues

master
Kevin Froman 2018-02-02 03:15:28 -06:00
parent 38ad6559c3
commit 2769673abd
3 changed files with 7 additions and 5 deletions

View File

@ -147,6 +147,8 @@ class OnionrCommunicate:
digest = digest.decode() digest = digest.decode()
if digest == hash.strip(): if digest == hash.strip():
self._core.setData(data) self._core.setData(data)
if data.startswith('-txt-'):
self._core.setBlockType(hash, 'txt')
logger.info('Successfully obtained data for ' + hash) logger.info('Successfully obtained data for ' + hash)
if len(data) < 120: if len(data) < 120:
logger.debug('Block text:\n' + data) logger.debug('Block text:\n' + data)
@ -165,7 +167,7 @@ class OnionrCommunicate:
if data != None: if data != None:
url = url + '&data=' + data url = url + '&data=' + data
try: try:
r = requests.get(url, headers=headers, proxies=proxies, timeout=(5, 30)) r = requests.get(url, headers=headers, proxies=proxies, timeout=(15, 30))
except requests.exceptions.RequestException as e: except requests.exceptions.RequestException as e:
logger.warn(action + " failed with peer " + peer + ": " + str(e)) logger.warn(action + " failed with peer " + peer + ": " + str(e))
return False return False

View File

@ -366,8 +366,8 @@ class Core:
def setBlockType(self, hash, blockType): def setBlockType(self, hash, blockType):
conn = sqlite3.connect(self.blockDB) conn = sqlite3.connect(self.blockDB)
c = conn.cursor() c = conn.cursor()
if blockType not in ("txt"): #if blockType not in ("txt"):
return # return
c.execute("UPDATE hashes set dataType='" + blockType + "' where hash = '" + hash + "';") c.execute("UPDATE hashes SET dataType='" + blockType + "' WHERE hash = '" + hash + "';")
conn.commit() conn.commit()
conn.close() conn.close()

View File

@ -49,7 +49,7 @@ class OnionrGUI:
self.root.mainloop() self.root.mainloop()
def sendMessage(self): def sendMessage(self):
messageToAdd = self.sendEntry.get() messageToAdd = '-txt-' + self.sendEntry.get()
addedHash = self.myCore.setData(messageToAdd) addedHash = self.myCore.setData(messageToAdd)
self.myCore.addToBlockDB(addedHash, selfInsert=True) self.myCore.addToBlockDB(addedHash, selfInsert=True)
self.myCore.setBlockType(addedHash, 'txt') self.myCore.setBlockType(addedHash, 'txt')