fixes from review for readability

This commit is contained in:
Victor Shyba 2018-10-11 00:51:00 -03:00 committed by Lex Berezhny
parent 52b7bb0fce
commit 55f5c7491c
2 changed files with 7 additions and 13 deletions

View file

@ -111,13 +111,7 @@ class HierarchicalDeterministic(AddressManager):
keys_batch, final_keys = [], []
for index in range(start, end+1):
keys_batch.append((index, self.public_key.child(index)))
if len(keys_batch) % 180 == 0:
yield self.db.add_keys(
self.account, self.chain_number, keys_batch
)
final_keys.extend(keys_batch)
keys_batch.clear()
if keys_batch:
if index % 180 == 0 or index == end:
yield self.db.add_keys(
self.account, self.chain_number, keys_batch
)

View file

@ -169,6 +169,10 @@ class SQLiteMixin:
class BaseDatabase(SQLiteMixin):
PRAGMAS = """
pragma journal_mode=WAL;
"""
CREATE_PUBKEY_ADDRESS_TABLE = """
create table if not exists pubkey_address (
address text primary key,
@ -221,10 +225,6 @@ class BaseDatabase(SQLiteMixin):
create index if not exists txi_txoid_idx on txi (txoid);
"""
PRAGMAS = """
pragma journal_mode=WAL;
"""
CREATE_TABLES_QUERY = (
PRAGMAS +
CREATE_TX_TABLE +
@ -480,10 +480,10 @@ class BaseDatabase(SQLiteMixin):
) + ', '.join(['(?, ?, ?, ?, ?)'] * len(keys))
values = []
for position, pubkey in keys:
values.extend([
values.extend((
pubkey.address, account.public_key.address, chain, position,
sqlite3.Binary(pubkey.pubkey_bytes)
])
))
return self.run_operation(sql, values)
@classmethod