moved all but shutdown over to new daemon events system
This commit is contained in:
parent
c975d27906
commit
a801960179
11 changed files with 76 additions and 204 deletions
|
@ -52,27 +52,6 @@ class PrivateEndpoints:
|
|||
def get_hit_count():
|
||||
return Response(str(client_api.publicAPI.hitCount))
|
||||
|
||||
@private_endpoints_bp.route('/queueResponseAdd/<name>', methods=['post'])
|
||||
def queueResponseAdd(name):
|
||||
# Responses from the daemon. TODO: change to direct var access instead of http endpoint
|
||||
client_api.queueResponse[name] = request.form['data']
|
||||
return Response('success')
|
||||
|
||||
@private_endpoints_bp.route('/queueResponse/<name>')
|
||||
def queueResponse(name):
|
||||
# Fetch a daemon queue response
|
||||
resp = 'failure'
|
||||
try:
|
||||
resp = client_api.queueResponse[name]
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
del client_api.queueResponse[name]
|
||||
if resp == 'failure':
|
||||
return resp, 404
|
||||
else:
|
||||
return resp
|
||||
|
||||
@private_endpoints_bp.route('/ping')
|
||||
def ping():
|
||||
# Used to check if client api is working
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
Accept block uploads to the public API server
|
||||
'''
|
||||
from gevent import spawn
|
||||
from gevent import threading
|
||||
|
||||
import sys
|
||||
|
@ -10,7 +11,6 @@ from flask import Response
|
|||
from flask import abort
|
||||
|
||||
from onionrutils import localcommand
|
||||
from coredb import daemonqueue
|
||||
from onionrblocks import blockimporter
|
||||
import onionrexceptions
|
||||
import logger
|
||||
|
@ -40,7 +40,13 @@ def accept_upload(request):
|
|||
try:
|
||||
b_hash = blockimporter.import_block_from_data(data)
|
||||
if b_hash:
|
||||
daemonqueue.daemon_queue_add('uploadEvent', b_hash)
|
||||
spawn(
|
||||
localcommand.local_command,
|
||||
f'/daemon-event/upload_event',
|
||||
post=True,
|
||||
is_json=True,
|
||||
postData={'block': b_hash}
|
||||
).get(timeout=5)
|
||||
resp = 'success'
|
||||
else:
|
||||
resp = 'failure'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue