fixed hide blocks being broken in some cases

master
Kevin Froman 2020-01-30 00:54:43 -06:00
parent 8649231860
commit d0bdeca7c4
4 changed files with 20 additions and 5 deletions

View File

@ -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)

View File

@ -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}')

View File

@ -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
},

View File

@ -1 +1 @@
1580361700
1580367262