From 78265990abf312121cba9baa67b6086b27e719f2 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Fri, 18 May 2018 16:49:05 -0500 Subject: [PATCH] fixed broken getepoch --- onionr/core.py | 5 ++++- onionr/onionrutils.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/onionr/core.py b/onionr/core.py index 57c1d53f..cf0f9690 100644 --- a/onionr/core.py +++ b/onionr/core.py @@ -73,7 +73,7 @@ class Core: except Exception as error: logger.error('Failed to initialize core Onionr library.', error=error) logger.fatal('Cannot recover from error.') - exit(1) + sys.exit(1) return def addPeer(self, peerID, powID, name=''): @@ -83,6 +83,9 @@ class Core: # This function simply adds a peer to the DB if not self._utils.validatePubKey(peerID): return False + if sys.getsizeof(powID) > 60: + logger.warn("POW token for pubkey base64 representation exceeded 60 bytes") + return False conn = sqlite3.connect(self.peerDB) hashID = self._crypto.pubKeyHashID(peerID) diff --git a/onionr/onionrutils.py b/onionr/onionrutils.py index 317ff8c5..457960e0 100644 --- a/onionr/onionrutils.py +++ b/onionr/onionrutils.py @@ -18,7 +18,7 @@ along with this program. If not, see . ''' # Misc functions that do not fit in the main api, but are useful -import getpass, sys, requests, os, socket, hashlib, logger, sqlite3, config, binascii, time, base64, json, glob, shutil +import getpass, sys, requests, os, socket, hashlib, logger, sqlite3, config, binascii, time, base64, json, glob, shutil, math import nacl.signing, nacl.encoding if sys.version_info < (3, 6): @@ -473,7 +473,7 @@ class OnionrUtils: sys.stdout.write("\r┣{0}┫ {1}%".format(arrow + spaces, int(round(percent * 100)))) sys.stdout.flush() - def getEpoch(): + def getEpoch(self): '''returns epoch''' return math.floor(time.time())