From 0b9bb42927fbf31d4929365dc80d33128d312d14 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Tue, 2 Oct 2018 00:02:05 -0500 Subject: [PATCH] bug fixes and work on fs --- onionr/communicator2.py | 2 +- onionr/onionrblockapi.py | 11 ++++++++++- onionr/onionrutils.py | 7 ++++++- onionr/static-data/default-plugins/flow/main.py | 4 ++-- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/onionr/communicator2.py b/onionr/communicator2.py index fc62fe44..5a293c0f 100755 --- a/onionr/communicator2.py +++ b/onionr/communicator2.py @@ -94,7 +94,7 @@ class OnionrCommunicatorDaemon: OnionrCommunicatorTimers(self, self.getBlocks, self._core.config.get('timers.getBlocks'), requiresPeer=True) OnionrCommunicatorTimers(self, self.clearOfflinePeer, 58) OnionrCommunicatorTimers(self, self.daemonTools.cleanOldBlocks, 65) - OnionrCommunicatorTimers(self, self.lookupKeys, 60, requiresPeer=True) + #OnionrCommunicatorTimers(self, self.lookupKeys, 60, requiresPeer=True) OnionrCommunicatorTimers(self, self.lookupAdders, 60, requiresPeer=True) OnionrCommunicatorTimers(self, self.daemonTools.cooldownPeer, 30, requiresPeer=True) netCheckTimer = OnionrCommunicatorTimers(self, self.daemonTools.netCheck, 600) diff --git a/onionr/onionrblockapi.py b/onionr/onionrblockapi.py index fea9df1e..c14afc46 100644 --- a/onionr/onionrblockapi.py +++ b/onionr/onionrblockapi.py @@ -228,7 +228,7 @@ class Block: blockFile.write(self.getRaw().encode()) self.update() else: - self.hash = self.getCore().insertBlock(self.getContent(), header = self.getType(), sign = sign) + self.hash = self.getCore().insertBlock(self.getContent(), header = self.getType(), sign = sign, expire=self.getExpire()) self.update() return self.getHash() @@ -241,6 +241,15 @@ class Block: # getters + def getExpire(self): + ''' + Returns the expire time for a block + + Outputs: + - (int): the expire time for a block, or None + ''' + return self.expire + def getHash(self): ''' Returns the hash of the block if saved to file diff --git a/onionr/onionrutils.py b/onionr/onionrutils.py index 59b8829b..c9eea940 100644 --- a/onionr/onionrutils.py +++ b/onionr/onionrutils.py @@ -372,7 +372,12 @@ class OnionrUtils: logger.warn('Block has invalid metadata key ' + i) break else: - if self._core.requirements.blockMetadataLengths[i] < len(metadata[i]): + testData = metadata[i] + try: + testData = len(testData) + except (TypeError, AttributeError) as e: + testData = len(str(testData)) + if self._core.requirements.blockMetadataLengths[i] < testData: logger.warn('Block metadata key ' + i + ' exceeded maximum size') break if i == 'time': diff --git a/onionr/static-data/default-plugins/flow/main.py b/onionr/static-data/default-plugins/flow/main.py index b2fb1dfa..a7f8842b 100644 --- a/onionr/static-data/default-plugins/flow/main.py +++ b/onionr/static-data/default-plugins/flow/main.py @@ -45,9 +45,9 @@ class OnionrFlow: self.flowRunning = False if message == "q": self.flowRunning = False - + expireTime = self.myCore._utils.getEpoch() + 43200 if len(message) > 0: - Block(content = message, type = 'txt', core = self.myCore).save() + Block(content = message, type = 'txt', expire=expireTime, core = self.myCore).save() logger.info("Flow is exiting, goodbye") return