progress removing onionr.py
parent
0690e9ca0e
commit
cbe10f914a
|
@ -40,7 +40,6 @@ class PrivateAPI:
|
||||||
This initialization defines all of the API entry points and handlers for the endpoints and errors
|
This initialization defines all of the API entry points and handlers for the endpoints and errors
|
||||||
This also saves the used host (random localhost IP address) to the data folder in host.txt
|
This also saves the used host (random localhost IP address) to the data folder in host.txt
|
||||||
'''
|
'''
|
||||||
time.sleep(0.3)
|
|
||||||
self.config = config
|
self.config = config
|
||||||
self.serializer = serializeddata.SerializedData()
|
self.serializer = serializeddata.SerializedData()
|
||||||
self.startTime = epoch.get_epoch()
|
self.startTime = epoch.get_epoch()
|
||||||
|
|
|
@ -38,7 +38,6 @@ class PublicAPI:
|
||||||
The new client api server, isolated from the public api
|
The new client api server, isolated from the public api
|
||||||
'''
|
'''
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
time.sleep(1)
|
|
||||||
app = flask.Flask('PublicAPI')
|
app = flask.Flask('PublicAPI')
|
||||||
app.config['MAX_CONTENT_LENGTH'] = 5 * 1024 * 1024
|
app.config['MAX_CONTENT_LENGTH'] = 5 * 1024 * 1024
|
||||||
self.i2pEnabled = config.get('i2p.host', False)
|
self.i2pEnabled = config.get('i2p.host', False)
|
||||||
|
|
|
@ -144,7 +144,7 @@ class OnionrCommunicatorDaemon:
|
||||||
if config.get('general.security_level', 1) == 0 and config.get('general.announce_node', True):
|
if config.get('general.security_level', 1) == 0 and config.get('general.announce_node', True):
|
||||||
# Default to high security level incase config breaks
|
# Default to high security level incase config breaks
|
||||||
announceTimer = OnionrCommunicatorTimers(self, announcenode.announce_node, 3600, myArgs=[self], requiresPeer=True, maxThreads=1)
|
announceTimer = OnionrCommunicatorTimers(self, announcenode.announce_node, 3600, myArgs=[self], requiresPeer=True, maxThreads=1)
|
||||||
announceTimer.count = (announceTimer.frequency - 60)
|
announceTimer.count = (announceTimer.frequency - 120)
|
||||||
else:
|
else:
|
||||||
logger.debug('Will not announce node.')
|
logger.debug('Will not announce node.')
|
||||||
|
|
||||||
|
|
|
@ -7,13 +7,13 @@ class FDSafeHandler(WSGIHandler):
|
||||||
self.timeout.start()
|
self.timeout.start()
|
||||||
try:
|
try:
|
||||||
WSGIHandler.handle(self)
|
WSGIHandler.handle(self)
|
||||||
except Exception:
|
except Exception as e:
|
||||||
self.handle_error()
|
self.handle_error(e)
|
||||||
finally:
|
finally:
|
||||||
self.timeout.close()
|
self.timeout.close()
|
||||||
|
|
||||||
def handle_error(self):
|
def handle_error(self, two, three, four):
|
||||||
if v is self.timeout:
|
if two is self.timeout:
|
||||||
self.result = [b"Timeout"]
|
self.result = [b"Timeout"]
|
||||||
self.start_response("200 OK", [])
|
self.start_response("200 OK", [])
|
||||||
self.process_result()
|
self.process_result()
|
||||||
|
|
|
@ -100,7 +100,6 @@ class PrivateEndpoints:
|
||||||
try:
|
try:
|
||||||
return Response(client_api._too_many.get(SerializedData).getStats())
|
return Response(client_api._too_many.get(SerializedData).getStats())
|
||||||
except AttributeError as e:
|
except AttributeError as e:
|
||||||
print("damn", e)
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@private_endpoints_bp.route('/getuptime')
|
@private_endpoints_bp.route('/getuptime')
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import json
|
import json, time
|
||||||
from coredb import blockmetadb
|
from coredb import blockmetadb
|
||||||
import communicator
|
import communicator
|
||||||
class SerializedData:
|
class SerializedData:
|
||||||
|
@ -35,7 +35,11 @@ class SerializedData:
|
||||||
def getStats(self):
|
def getStats(self):
|
||||||
'''Return statistics about our node'''
|
'''Return statistics about our node'''
|
||||||
stats = {}
|
stats = {}
|
||||||
comm_inst = self._too_many.get(communicator.OnionrCommunicatorDaemon)
|
try:
|
||||||
|
self._too_many
|
||||||
|
except AttributeError:
|
||||||
|
time.sleep(1)
|
||||||
|
comm_inst = self._too_many.get(communicator.OnionrCommunicatorDaemon, args=(self._too_many,))
|
||||||
stats['uptime'] = comm_inst.getUptime()
|
stats['uptime'] = comm_inst.getUptime()
|
||||||
stats['connectedNodes'] = '\n'.join(comm_inst.onlinePeers)
|
stats['connectedNodes'] = '\n'.join(comm_inst.onlinePeers)
|
||||||
stats['blockCount'] = len(blockmetadb.get_block_list())
|
stats['blockCount'] = len(blockmetadb.get_block_list())
|
||||||
|
|
Loading…
Reference in New Issue