Batch onion update

This commit is contained in:
shortcutme 2017-08-18 14:45:06 +02:00
parent 37ef2802de
commit 32a0f96ecd
No known key found for this signature in database
GPG Key ID: 5B63BAE6CB9613AE
1 changed files with 11 additions and 3 deletions

View File

@ -46,16 +46,24 @@ class FileRequestPlugin(object):
s = time.time()
# Separatley add onions to sites or at once if no onions present
hashes_changed = 0
i = 0
onion_to_hash = {}
for onion in params.get("onions", []):
if onion not in onion_to_hash:
onion_to_hash[onion] = []
onion_to_hash[onion].append(hashes[i])
i += 1
hashes_changed = 0
db.execute("BEGIN")
for onion, onion_hashes in onion_to_hash.iteritems():
hashes_changed += db.peerAnnounce(
onion=onion,
port=params["port"],
hashes=[hashes[i]],
hashes=onion_hashes,
onion_signed=all_onions_signed
)
i += 1
db.execute("END")
time_db_onion = time.time() - s
s = time.time()