* 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)
This commit is contained in:
Kevin Froman 2018-07-05 02:31:47 -05:00
parent bd819a3ba6
commit 06986d2703
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
5 changed files with 8 additions and 20 deletions

View File

@ -89,9 +89,12 @@ class OnionrCommunicatorDaemon:
# Main daemon loop, mainly for calling timers, don't do any complex operations here to avoid locking
while not self.shutdown:
for i in self.timers:
if self.shutdown:
break
i.processTimer()
time.sleep(self.delay)
logger.info('Goodbye.')
self._core._utils.localCommand('shutdown')
def lookupKeys(self):
'''Lookup new keys'''

View File

@ -725,26 +725,15 @@ class Core:
signature = self._crypto.pubKeyEncrypt(signature, asymPeer, encodedData=True)
else:
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
metadata['meta'] = jsonMeta
metadata['sig'] = signature
metadata['signer'] = signer
metadata['powRandomToken'] = powToken
metadata['time'] = str(self._utils.getEpoch())
payload = json.dumps(metadata).encode() + b'\n' + data
payload = onionrproofs.POW(metadata, data)
retData = self.setData(payload)
self.addToBlockDB(retData, selfInsert=True, dataSaved=True)
self.setBlockType(retData, meta['type'])

View File

@ -42,7 +42,7 @@ except ImportError:
ONIONR_TAGLINE = 'Anonymous P2P Platform - GPLv3 - https://Onionr.VoidNet.Tech'
ONIONR_VERSION = '0.1.0' # for debugging and stuff
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:
def __init__(self):
@ -604,10 +604,6 @@ class Onionr:
try:
events.event('daemon_stop', onionr = self)
net = NetController(config.get('client.port', 59496))
try:
self.onionrUtils.localCommand('shutdown')
except requests.exceptions.ConnectionError:
pass
self.onionrCore.daemonQueueAdd('shutdown')
net.killTor()
except Exception as e:

View File

@ -169,7 +169,7 @@ class OnionrUtils:
retData = requests.get(payload).text
except Exception as error:
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
return retData

View File

@ -3,7 +3,7 @@
"dev_mode": true,
"display_header" : true,
"newCommunicator": false,
"newCommunicator": true,
"dc_response": true,
"dc_execcallbacks" : true