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
|
heartBeatTimer = 0
|
||||||
if blockProcessTimer == blockProcessAmount:
|
if blockProcessTimer == blockProcessAmount:
|
||||||
self.lookupBlocks()
|
self.lookupBlocks()
|
||||||
self._core.processBlocks()
|
self.processBlocks()
|
||||||
blockProcessTimer = 0
|
blockProcessTimer = 0
|
||||||
#logger.debug('Communicator daemon heartbeat')
|
#logger.debug('Communicator daemon heartbeat')
|
||||||
if command != False:
|
if command != False:
|
||||||
@ -115,6 +115,15 @@ class OnionrCommunicate:
|
|||||||
logger.debug('Adding ' + i + ' to hash database...')
|
logger.debug('Adding ' + i + ' to hash database...')
|
||||||
self._core.addToBlockDB(i)
|
self._core.addToBlockDB(i)
|
||||||
return
|
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'):
|
def performGet(self, action, peer, data=None, type='tor'):
|
||||||
'''Performs a request to a peer through Tor or i2p (currently only tor)'''
|
'''Performs a request to a peer through Tor or i2p (currently only tor)'''
|
||||||
|
@ -280,15 +280,6 @@ class Core:
|
|||||||
conn.close()
|
conn.close()
|
||||||
return peerList
|
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):
|
def getPeerInfo(self, peer, info):
|
||||||
'''
|
'''
|
||||||
get info about a peer
|
get info about a peer
|
||||||
|
@ -109,6 +109,10 @@ class Onionr:
|
|||||||
os.remove('.onionr-lock')
|
os.remove('.onionr-lock')
|
||||||
elif command == 'stop':
|
elif command == 'stop':
|
||||||
self.killDaemon()
|
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'):
|
elif command in ('addmsg', 'addmessage'):
|
||||||
while True:
|
while True:
|
||||||
messageToAdd = input('Broadcast message to network: ')
|
messageToAdd = input('Broadcast message to network: ')
|
||||||
|
@ -99,6 +99,8 @@ class OnionrUtils:
|
|||||||
def validateHash(self, data, length=64):
|
def validateHash(self, data, length=64):
|
||||||
'''Validate if a string is a valid hex formatted hash'''
|
'''Validate if a string is a valid hex formatted hash'''
|
||||||
retVal = True
|
retVal = True
|
||||||
|
if retVal == False:
|
||||||
|
return False
|
||||||
if len(data) != length:
|
if len(data) != length:
|
||||||
retVal = False
|
retVal = False
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user