moved processblocks to communicator and fixed bool error in validatehash

This commit is contained in:
Kevin Froman 2018-01-28 15:59:13 -06:00
parent 3c692f1060
commit 63b4c88d06
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
4 changed files with 16 additions and 10 deletions

View File

@ -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)'''

View File

@ -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

View File

@ -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: ')

View File

@ -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: