fixed broken getepoch

master
Kevin Froman 2018-05-18 16:49:05 -05:00
parent 16282d79d3
commit 78265990ab
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
2 changed files with 6 additions and 3 deletions

View File

@ -73,7 +73,7 @@ class Core:
except Exception as error: except Exception as error:
logger.error('Failed to initialize core Onionr library.', error=error) logger.error('Failed to initialize core Onionr library.', error=error)
logger.fatal('Cannot recover from error.') logger.fatal('Cannot recover from error.')
exit(1) sys.exit(1)
return return
def addPeer(self, peerID, powID, name=''): def addPeer(self, peerID, powID, name=''):
@ -83,6 +83,9 @@ class Core:
# This function simply adds a peer to the DB # This function simply adds a peer to the DB
if not self._utils.validatePubKey(peerID): if not self._utils.validatePubKey(peerID):
return False 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) conn = sqlite3.connect(self.peerDB)
hashID = self._crypto.pubKeyHashID(peerID) hashID = self._crypto.pubKeyHashID(peerID)

View File

@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
''' '''
# Misc functions that do not fit in the main api, but are useful # 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 import nacl.signing, nacl.encoding
if sys.version_info < (3, 6): 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.write("\r{0}{1}%".format(arrow + spaces, int(round(percent * 100))))
sys.stdout.flush() sys.stdout.flush()
def getEpoch(): def getEpoch(self):
'''returns epoch''' '''returns epoch'''
return math.floor(time.time()) return math.floor(time.time())