From 63b4c88d064e7d1b966afa0c7d69b4668eb06226 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Sun, 28 Jan 2018 15:59:13 -0600 Subject: [PATCH] moved processblocks to communicator and fixed bool error in validatehash --- onionr/communicator.py | 11 ++++++++++- onionr/core.py | 9 --------- onionr/onionr.py | 4 ++++ onionr/onionrutils.py | 2 ++ 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/onionr/communicator.py b/onionr/communicator.py index a1416e5f..2eb81518 100755 --- a/onionr/communicator.py +++ b/onionr/communicator.py @@ -55,7 +55,7 @@ class OnionrCommunicate: heartBeatTimer = 0 if blockProcessTimer == blockProcessAmount: self.lookupBlocks() - self._core.processBlocks() + self.processBlocks() blockProcessTimer = 0 #logger.debug('Communicator daemon heartbeat') if command != False: @@ -115,6 +115,15 @@ class OnionrCommunicate: logger.debug('Adding ' + i + ' to hash database...') self._core.addToBlockDB(i) return + def processBlocks(self): + ''' + Work with the block database and download any missing blocks + This is meant to be called from the communicator daemon on its timer. + ''' + for i in self.getBlockList(True).split("\n"): + if i != "": + print('UNSAVED BLOCK:', i) + return def performGet(self, action, peer, data=None, type='tor'): '''Performs a request to a peer through Tor or i2p (currently only tor)''' diff --git a/onionr/core.py b/onionr/core.py index e52359c0..2c2ef72e 100644 --- a/onionr/core.py +++ b/onionr/core.py @@ -280,15 +280,6 @@ class Core: conn.close() return peerList - def processBlocks(self): - ''' - Work with the block database and download any missing blocks - This is meant to be called from the communicator daemon on its timer. - ''' - for i in self.getBlockList(True).split("\n"): - if i != "": - print('UNSAVED BLOCK:', i) - return def getPeerInfo(self, peer, info): ''' get info about a peer diff --git a/onionr/onionr.py b/onionr/onionr.py index b84d1633..a3d2bd4e 100755 --- a/onionr/onionr.py +++ b/onionr/onionr.py @@ -109,6 +109,10 @@ class Onionr: os.remove('.onionr-lock') elif command == 'stop': self.killDaemon() + elif command in ('listpeers', 'list-peers'): + logger.info('Peer list:\n') + for i in self.onionrCore.listPeers(): + logger.info(i) elif command in ('addmsg', 'addmessage'): while True: messageToAdd = input('Broadcast message to network: ') diff --git a/onionr/onionrutils.py b/onionr/onionrutils.py index d942d831..14ddca4b 100644 --- a/onionr/onionrutils.py +++ b/onionr/onionrutils.py @@ -99,6 +99,8 @@ class OnionrUtils: def validateHash(self, data, length=64): '''Validate if a string is a valid hex formatted hash''' retVal = True + if retVal == False: + return False if len(data) != length: retVal = False else: