moved processblocks to communicator and fixed bool error in validatehash
This commit is contained in:
parent
3c692f1060
commit
63b4c88d06
@ -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)'''
|
||||
|
@ -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
|
||||
|
@ -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: ')
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user