From d0bdeca7c4e1802caf00ada959c50b96949db65a Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Thu, 30 Jan 2020 00:54:43 -0600 Subject: [PATCH] fixed hide blocks being broken in some cases --- src/communicatorutils/uploadblocks/__init__.py | 17 +++++++++++++++++ .../uploadblocks/sessionmanager.py | 2 -- static-data/default_config.json | 4 ++-- tests/runtime-result.txt | 2 +- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/communicatorutils/uploadblocks/__init__.py b/src/communicatorutils/uploadblocks/__init__.py index 9bbc2509..bf83e301 100755 --- a/src/communicatorutils/uploadblocks/__init__.py +++ b/src/communicatorutils/uploadblocks/__init__.py @@ -3,6 +3,9 @@ Upload blocks in the upload queue to peers from the communicator """ from typing import TYPE_CHECKING +from time import sleep +from threading import Thread + from . import sessionmanager from onionrtypes import UserID @@ -45,6 +48,14 @@ def upload_blocks_from_communicator(comm_inst: 'OnionrCommunicatorDaemon'): comm_inst.blocksToUpload = onionrcrypto.cryptoutils.random_shuffle( comm_inst.blocksToUpload) + def remove_from_hidden(bl): + sleep(60) + try: + comm_inst.shared_state.get_by_string( + 'PublicAPI').hideBlocks.remove(bl) + except ValueError: + pass + if len(comm_inst.blocksToUpload) != 0: for bl in comm_inst.blocksToUpload: if not stringvalidators.validate_hash(bl): @@ -84,6 +95,8 @@ def upload_blocks_from_communicator(comm_inst: 'OnionrCommunicatorDaemon'): content_type='application/octet-stream') if resp is not False: if resp == 'success': + Thread(target=remove_from_hidden, + args=[bl], daemon=True).start() session.success() session.peer_exists[peer] = True elif resp == 'exists': @@ -102,6 +115,10 @@ def upload_blocks_from_communicator(comm_inst: 'OnionrCommunicatorDaemon'): for x in finishedUploads: try: comm_inst.blocksToUpload.remove(x) + + comm_inst.shared_state.get_by_string( + 'PublicAPI').hideBlocks.remove(x) + except ValueError: pass comm_inst.decrementThreadCount(TIMER_NAME) diff --git a/src/communicatorutils/uploadblocks/sessionmanager.py b/src/communicatorutils/uploadblocks/sessionmanager.py index a2be2615..cb46c429 100644 --- a/src/communicatorutils/uploadblocks/sessionmanager.py +++ b/src/communicatorutils/uploadblocks/sessionmanager.py @@ -7,7 +7,6 @@ if TYPE_CHECKING: from session import UploadSession from onionrutils import bytesconverter -from onionrutils import localcommand from etc import onionrvalues from utils import reconstructhash @@ -122,4 +121,3 @@ class BlockUploadSessionManager: comm_inst.blocksToUpload.remove(sess.block_hash) except ValueError: pass - localcommand.local_command(f'waitforshare/{sess.block_hash}') diff --git a/static-data/default_config.json b/static-data/default_config.json index 27e62d47..93298e20 100755 --- a/static-data/default_config.json +++ b/static-data/default_config.json @@ -12,8 +12,8 @@ "insert_deniable_blocks": true, "max_block_age": 2678400, "public_key": "", - "random_bind_ip": true, - "use_bootstrap_list": true, + "random_bind_ip": false, + "use_bootstrap_list": false, "store_plaintext_blocks": true, "show_notifications": true }, diff --git a/tests/runtime-result.txt b/tests/runtime-result.txt index e87679e0..da7f4857 100644 --- a/tests/runtime-result.txt +++ b/tests/runtime-result.txt @@ -1 +1 @@ -1580361700 \ No newline at end of file +1580367262 \ No newline at end of file