improving new communicator bootstrapping, do not connect to self

This commit is contained in:
Kevin Froman 2018-07-03 16:24:14 -05:00
parent 267220ad72
commit 58110e461e
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
2 changed files with 11 additions and 5 deletions

View File

@ -72,7 +72,9 @@ class OnionrCommunicatorDaemon:
OnionrCommunicatorTimers(self, self.heartbeat, 10) OnionrCommunicatorTimers(self, self.heartbeat, 10)
# Initalize peer online list # Initalize peer online list
logger.warn('Onionr is not yet ready to recieve commands.')
self.getOnlinePeers() self.getOnlinePeers()
logger.info('\033[4mOnionr is ready\033[0m.')
# Set timers, function reference, seconds # Set timers, function reference, seconds
OnionrCommunicatorTimers(self, self.daemonCommands, 5) OnionrCommunicatorTimers(self, self.daemonCommands, 5)
@ -222,7 +224,7 @@ class OnionrCommunicatorDaemon:
def addBootstrapListToPeerList(self, peerList): def addBootstrapListToPeerList(self, peerList):
'''Add the bootstrap list to the peer list (no duplicates)''' '''Add the bootstrap list to the peer list (no duplicates)'''
for i in self._core.bootstrapList: for i in self._core.bootstrapList:
if i not in peerList: if i not in peerList and i not in self.offlinePeers and i != self._core.hsAdder:
peerList.append(i) peerList.append(i)
def connectNewPeer(self, peer='', useBootstrap=False): def connectNewPeer(self, peer='', useBootstrap=False):
@ -261,9 +263,10 @@ class OnionrCommunicatorDaemon:
'''logs online peer list''' '''logs online peer list'''
if len(self.onlinePeers) == 0: if len(self.onlinePeers) == 0:
logger.warn('No online peers') logger.warn('No online peers')
return else:
for i in self.onlinePeers: logger.info('Online peers:')
logger.info(self.onlinePeers[i]) for i in self.onlinePeers:
logger.info(i)
def peerAction(self, peer, action, data=''): def peerAction(self, peer, action, data=''):
'''Perform a get request to a peer''' '''Perform a get request to a peer'''

View File

@ -33,7 +33,7 @@ if sys.version_info < (3, 6):
class OnionrUtils: class OnionrUtils:
''' '''
Various useful function Various useful functions for validating things, etc functions, connectivity
''' '''
def __init__(self, coreInstance): def __init__(self, coreInstance):
self.fingerprintFile = 'data/own-fingerprint.txt' self.fingerprintFile = 'data/own-fingerprint.txt'
@ -41,6 +41,9 @@ class OnionrUtils:
self.timingToken = '' self.timingToken = ''
self.avoidDupe = [] # list used to prevent duplicate requests per peer for certain actions
self.peerProcessing = {} # dict of current peer actions: peer, actionList
return return
def getTimeBypassToken(self): def getTimeBypassToken(self):