account for the number of variables on each iteration

This commit is contained in:
Victor Shyba 2020-12-15 13:42:32 -03:00
parent 76d0e31544
commit 350eec35ee

View file

@ -60,7 +60,8 @@ def get_all_addresses(self):
def add_keys(pubkeys):
c = context()
for start in range(0, len(pubkeys), c.variable_limit - 1):
batch = pubkeys[start:(start + c.variable_limit - 1)]
current_limit = c.variable_limit // len(pubkeys[0]) # (overall limit) // (maximum on a query)
for start in range(0, len(pubkeys), current_limit - 1):
batch = pubkeys[start:(start + current_limit - 1)]
c.execute(c.insert_or_ignore(PubkeyAddress).values([{'address': k['address']} for k in batch]))
c.execute(c.insert_or_ignore(AccountAddress).values(batch))