Batch onion update
This commit is contained in:
parent
37ef2802de
commit
32a0f96ecd
1 changed files with 11 additions and 3 deletions
|
@ -46,16 +46,24 @@ class FileRequestPlugin(object):
|
||||||
|
|
||||||
s = time.time()
|
s = time.time()
|
||||||
# Separatley add onions to sites or at once if no onions present
|
# Separatley add onions to sites or at once if no onions present
|
||||||
hashes_changed = 0
|
|
||||||
i = 0
|
i = 0
|
||||||
|
onion_to_hash = {}
|
||||||
for onion in params.get("onions", []):
|
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(
|
hashes_changed += db.peerAnnounce(
|
||||||
onion=onion,
|
onion=onion,
|
||||||
port=params["port"],
|
port=params["port"],
|
||||||
hashes=[hashes[i]],
|
hashes=onion_hashes,
|
||||||
onion_signed=all_onions_signed
|
onion_signed=all_onions_signed
|
||||||
)
|
)
|
||||||
i += 1
|
db.execute("END")
|
||||||
time_db_onion = time.time() - s
|
time_db_onion = time.time() - s
|
||||||
|
|
||||||
s = time.time()
|
s = time.time()
|
||||||
|
|
Loading…
Reference in a new issue