From 32a0f96ecd86142a46ca5f5ae9f1d2fef64d90b7 Mon Sep 17 00:00:00 2001 From: shortcutme Date: Fri, 18 Aug 2017 14:45:06 +0200 Subject: [PATCH] Batch onion update --- .../disabled-Bootstrapper/BootstrapperPlugin.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/plugins/disabled-Bootstrapper/BootstrapperPlugin.py b/plugins/disabled-Bootstrapper/BootstrapperPlugin.py index c9786360..e6d42863 100644 --- a/plugins/disabled-Bootstrapper/BootstrapperPlugin.py +++ b/plugins/disabled-Bootstrapper/BootstrapperPlugin.py @@ -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()