diff --git a/src/communicatorutils/announcenode.py b/src/communicatorutils/announcenode.py
index 1d92a3fa..a068b88c 100755
--- a/src/communicatorutils/announcenode.py
+++ b/src/communicatorutils/announcenode.py
@@ -52,56 +52,26 @@ def announce_node(daemon):
except onionrexceptions.OnlinePeerNeeded:
peer = ""
- for _ in range(1):
- try:
- ourID = gettransports.get()[0]
- if not peer:
- raise onionrexceptions.OnlinePeerNeeded
- except (IndexError, onionrexceptions.OnlinePeerNeeded):
- break
-
+ try:
+ ourID = gettransports.get()[0]
+ if not peer:
+ raise onionrexceptions.OnlinePeerNeeded
+ except (IndexError, onionrexceptions.OnlinePeerNeeded):
+ pass
+ else:
url = 'http://' + peer + '/announce'
data = {'node': ourID}
- combinedNodes = ourID + peer
- if ourID != 1:
- existingRand = bytesconverter.bytes_to_str(
- keydb.transportinfo.get_address_info(peer, 'powValue'))
- # Reset existingRand if it no longer meets the minimum POW
- if isinstance(existingRand, type(None)) or \
- not existingRand.endswith(
- '0' * onionrvalues.ANNOUNCE_POW):
- existingRand = ''
+ logger.info('Announcing node to ' + url)
+ if basicrequests.do_post_request(
+ url,
+ data,
+ port=daemon.shared_state.get(NetController).socksPort)\
+ == 'Success':
+ logger.info('Successfully introduced node to ' + peer,
+ terminal=True)
+ ret_data = True
+ keydb.transportinfo.set_address_info(peer, 'introduced', 1)
- if peer in daemon.announceCache:
- data['random'] = daemon.announceCache[peer]
- elif len(existingRand) > 0:
- data['random'] = existingRand
- else:
- daemon.announceProgress[peer] = True
- proof = onionrproofs.DataPOW(
- combinedNodes, minDifficulty=onionrvalues.ANNOUNCE_POW)
- del daemon.announceProgress[peer]
- try:
- data['random'] = base64.b64encode(proof.waitForResult()[1])
- except TypeError:
- # Happens when we failed to produce a proof
- logger.error(f"Failed to produce a pow for {peer} annce")
- announce_fail = True
- else:
- daemon.announceCache[peer] = data['random']
- if not announce_fail:
- logger.info('Announcing node to ' + url)
- if basicrequests.do_post_request(
- url,
- data,
- port=daemon.shared_state.get(NetController).socksPort)\
- == 'Success':
- logger.info('Successfully introduced node to ' + peer,
- terminal=True)
- ret_data = True
- keydb.transportinfo.set_address_info(peer, 'introduced', 1)
- keydb.transportinfo.set_address_info(peer, 'powValue',
- data['random'])
daemon.decrementThreadCount('announce_node')
return ret_data
diff --git a/src/etc/onionrvalues.py b/src/etc/onionrvalues.py
index c4c30b65..294de91f 100755
--- a/src/etc/onionrvalues.py
+++ b/src/etc/onionrvalues.py
@@ -44,6 +44,10 @@ DATABASE_LOCK_TIMEOUT = 60
# Block creation anonymization requirements
MIN_BLOCK_UPLOAD_PEER_PERCENT = 0.1
+WSGI_SERVER_REQUEST_TIMEOUT_SECS = 120
+
+MAX_NEW_PEER_QUEUE = 1000
+
# Begin OnionrValues migrated values
"""Make announce take a few seconds (on average) to compute to discourage excessive node announcements"""
ANNOUNCE_POW = 6
diff --git a/src/httpapi/miscpublicapi/announce.py b/src/httpapi/miscpublicapi/announce.py
index 7a4fcad7..439aeef0 100755
--- a/src/httpapi/miscpublicapi/announce.py
+++ b/src/httpapi/miscpublicapi/announce.py
@@ -1,9 +1,16 @@
-'''
- Onionr - Private P2P Communication
+"""Onionr - Private P2P Communication.
- Handle announcements to the public API server
-'''
-'''
+Handle announcements to the public API server
+"""
+from flask import Response, g
+import deadsimplekv
+
+import logger
+from etc import onionrvalues
+from onionrutils import stringvalidators, bytesconverter
+import filepaths
+from communicator import OnionrCommunicatorDaemon
+"""
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
@@ -16,60 +23,39 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see