* now use communicator2 by default
* fixed shutdown command crash * now handle shutdown of api in communicator * work on new POW system (block hash being the POW hash)master
parent
bd819a3ba6
commit
06986d2703
|
@ -89,9 +89,12 @@ class OnionrCommunicatorDaemon:
|
||||||
# Main daemon loop, mainly for calling timers, don't do any complex operations here to avoid locking
|
# Main daemon loop, mainly for calling timers, don't do any complex operations here to avoid locking
|
||||||
while not self.shutdown:
|
while not self.shutdown:
|
||||||
for i in self.timers:
|
for i in self.timers:
|
||||||
|
if self.shutdown:
|
||||||
|
break
|
||||||
i.processTimer()
|
i.processTimer()
|
||||||
time.sleep(self.delay)
|
time.sleep(self.delay)
|
||||||
logger.info('Goodbye.')
|
logger.info('Goodbye.')
|
||||||
|
self._core._utils.localCommand('shutdown')
|
||||||
|
|
||||||
def lookupKeys(self):
|
def lookupKeys(self):
|
||||||
'''Lookup new keys'''
|
'''Lookup new keys'''
|
||||||
|
|
|
@ -726,25 +726,14 @@ class Core:
|
||||||
else:
|
else:
|
||||||
raise onionrexceptions.InvalidPubkey(asymPeer + ' is not a valid base32 encoded ed25519 key')
|
raise onionrexceptions.InvalidPubkey(asymPeer + ' is not a valid base32 encoded ed25519 key')
|
||||||
|
|
||||||
powProof = onionrproofs.POW(data)
|
|
||||||
|
|
||||||
# wait for proof to complete
|
|
||||||
powToken = powProof.waitForResult()
|
|
||||||
|
|
||||||
powToken = base64.b64encode(powToken[1])
|
|
||||||
try:
|
|
||||||
powToken = powToken.decode()
|
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# compile metadata
|
# compile metadata
|
||||||
metadata['meta'] = jsonMeta
|
metadata['meta'] = jsonMeta
|
||||||
metadata['sig'] = signature
|
metadata['sig'] = signature
|
||||||
metadata['signer'] = signer
|
metadata['signer'] = signer
|
||||||
metadata['powRandomToken'] = powToken
|
|
||||||
metadata['time'] = str(self._utils.getEpoch())
|
metadata['time'] = str(self._utils.getEpoch())
|
||||||
|
|
||||||
payload = json.dumps(metadata).encode() + b'\n' + data
|
payload = onionrproofs.POW(metadata, data)
|
||||||
|
|
||||||
retData = self.setData(payload)
|
retData = self.setData(payload)
|
||||||
self.addToBlockDB(retData, selfInsert=True, dataSaved=True)
|
self.addToBlockDB(retData, selfInsert=True, dataSaved=True)
|
||||||
self.setBlockType(retData, meta['type'])
|
self.setBlockType(retData, meta['type'])
|
||||||
|
|
|
@ -42,7 +42,7 @@ except ImportError:
|
||||||
ONIONR_TAGLINE = 'Anonymous P2P Platform - GPLv3 - https://Onionr.VoidNet.Tech'
|
ONIONR_TAGLINE = 'Anonymous P2P Platform - GPLv3 - https://Onionr.VoidNet.Tech'
|
||||||
ONIONR_VERSION = '0.1.0' # for debugging and stuff
|
ONIONR_VERSION = '0.1.0' # for debugging and stuff
|
||||||
ONIONR_VERSION_TUPLE = tuple(ONIONR_VERSION.split('.')) # (MAJOR, MINOR, VERSION)
|
ONIONR_VERSION_TUPLE = tuple(ONIONR_VERSION.split('.')) # (MAJOR, MINOR, VERSION)
|
||||||
API_VERSION = '3' # increments of 1; only change when something fundemental about how the API works changes. This way other nodes knows how to communicate without learning too much information about you.
|
API_VERSION = '4' # increments of 1; only change when something fundemental about how the API works changes. This way other nodes knows how to communicate without learning too much information about you.
|
||||||
|
|
||||||
class Onionr:
|
class Onionr:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -604,10 +604,6 @@ class Onionr:
|
||||||
try:
|
try:
|
||||||
events.event('daemon_stop', onionr = self)
|
events.event('daemon_stop', onionr = self)
|
||||||
net = NetController(config.get('client.port', 59496))
|
net = NetController(config.get('client.port', 59496))
|
||||||
try:
|
|
||||||
self.onionrUtils.localCommand('shutdown')
|
|
||||||
except requests.exceptions.ConnectionError:
|
|
||||||
pass
|
|
||||||
self.onionrCore.daemonQueueAdd('shutdown')
|
self.onionrCore.daemonQueueAdd('shutdown')
|
||||||
net.killTor()
|
net.killTor()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
@ -169,7 +169,7 @@ class OnionrUtils:
|
||||||
retData = requests.get(payload).text
|
retData = requests.get(payload).text
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
if not silent:
|
if not silent:
|
||||||
logger.error('Failed to make local request (command: %s).' % command, error=error)
|
logger.debug('Failed to make local request (command: %s).' % command, error=error)
|
||||||
retData = False
|
retData = False
|
||||||
|
|
||||||
return retData
|
return retData
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"dev_mode": true,
|
"dev_mode": true,
|
||||||
"display_header" : true,
|
"display_header" : true,
|
||||||
|
|
||||||
"newCommunicator": false,
|
"newCommunicator": true,
|
||||||
|
|
||||||
"dc_response": true,
|
"dc_response": true,
|
||||||
"dc_execcallbacks" : true
|
"dc_execcallbacks" : true
|
||||||
|
|
Loading…
Reference in New Issue