Add run check to node introduction function
parent
c144bc40b3
commit
cfb1986ad0
|
@ -611,12 +611,15 @@ class Core:
|
||||||
'''
|
'''
|
||||||
Inserts a block into the network
|
Inserts a block into the network
|
||||||
'''
|
'''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data.decode()
|
data.decode()
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
data = data.encode()
|
data = data.encode()
|
||||||
|
|
||||||
retData = ''
|
retData = ''
|
||||||
metadata = {'type': header}
|
metadata = {'type': header}
|
||||||
|
|
||||||
if sign:
|
if sign:
|
||||||
signature = self._crypto.edSign(data, self._crypto.privKey, encodeResult=True)
|
signature = self._crypto.edSign(data, self._crypto.privKey, encodeResult=True)
|
||||||
ourID = self._crypto.pubKeyHashID()
|
ourID = self._crypto.pubKeyHashID()
|
||||||
|
@ -627,8 +630,10 @@ class Core:
|
||||||
pass
|
pass
|
||||||
metadata['id'] = ourID
|
metadata['id'] = ourID
|
||||||
metadata['sig'] = signature
|
metadata['sig'] = signature
|
||||||
|
|
||||||
metadata = json.dumps(metadata)
|
metadata = json.dumps(metadata)
|
||||||
metadata = metadata.encode()
|
metadata = metadata.encode()
|
||||||
|
|
||||||
if len(data) == 0:
|
if len(data) == 0:
|
||||||
logger.error('Will not insert empty block')
|
logger.error('Will not insert empty block')
|
||||||
else:
|
else:
|
||||||
|
@ -642,16 +647,28 @@ class Core:
|
||||||
'''
|
'''
|
||||||
Introduces our node into the network by telling X many nodes our HS address
|
Introduces our node into the network by telling X many nodes our HS address
|
||||||
'''
|
'''
|
||||||
announceAmount = 2
|
|
||||||
nodeList = self.listAdders()
|
if(self._utils.isCommunicatorRunning()):
|
||||||
if len(nodeList) == 0:
|
announceAmount = 2
|
||||||
for i in self.bootstrapList:
|
nodeList = self.listAdders()
|
||||||
if self._utils.validateID(i):
|
|
||||||
self.addAddress(i)
|
if len(nodeList) == 0:
|
||||||
nodeList.append(i)
|
for i in self.bootstrapList:
|
||||||
if announceAmount > len(nodeList):
|
if self._utils.validateID(i):
|
||||||
announceAmount = len(nodeList)
|
self.addAddress(i)
|
||||||
for i in range(announceAmount):
|
nodeList.append(i)
|
||||||
self.daemonQueueAdd('announceNode', nodeList[i])
|
|
||||||
events.event('introduction', onionr = None)
|
if announceAmount > len(nodeList):
|
||||||
|
announceAmount = len(nodeList)
|
||||||
|
|
||||||
|
for i in range(announceAmount):
|
||||||
|
self.daemonQueueAdd('announceNode', nodeList[i])
|
||||||
|
|
||||||
|
events.event('introduction', onionr = None)
|
||||||
|
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
logger.error('Onionr daemon is not running.')
|
||||||
|
return False
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
|
@ -203,13 +203,13 @@ class Onionr:
|
||||||
'disable-plugin': 'Disables and stops a plugin',
|
'disable-plugin': 'Disables and stops a plugin',
|
||||||
'reload-plugin': 'Reloads a plugin',
|
'reload-plugin': 'Reloads a plugin',
|
||||||
'create-plugin': 'Creates directory structure for a plugin',
|
'create-plugin': 'Creates directory structure for a plugin',
|
||||||
'add-peer': 'Adds a peer (?)',
|
'add-peer': 'Adds a peer to database',
|
||||||
'list-peers': 'Displays a list of peers',
|
'list-peers': 'Displays a list of peers',
|
||||||
'add-msg': 'Broadcasts a message to the Onionr network',
|
'add-msg': 'Broadcasts a message to the Onionr network',
|
||||||
'pm': 'Adds a private message to block',
|
'pm': 'Adds a private message to block',
|
||||||
'get-pms': 'Shows private messages sent to you',
|
'get-pms': 'Shows private messages sent to you',
|
||||||
'addfile': 'Create an Onionr block from a file',
|
'addfile': 'Create an Onionr block from a file',
|
||||||
'introduce': 'Introduce your node to the public Onionr network (DAEMON MUST BE RUNNING)',
|
'introduce': 'Introduce your node to the public Onionr network',
|
||||||
}
|
}
|
||||||
|
|
||||||
# initialize plugins
|
# initialize plugins
|
||||||
|
|
Loading…
Reference in New Issue