forked from LBRYCommunity/lbry-sdk
fixes from review for readability
This commit is contained in:
parent
52b7bb0fce
commit
55f5c7491c
2 changed files with 7 additions and 13 deletions
|
@ -111,18 +111,12 @@ class HierarchicalDeterministic(AddressManager):
|
||||||
keys_batch, final_keys = [], []
|
keys_batch, final_keys = [], []
|
||||||
for index in range(start, end+1):
|
for index in range(start, end+1):
|
||||||
keys_batch.append((index, self.public_key.child(index)))
|
keys_batch.append((index, self.public_key.child(index)))
|
||||||
if len(keys_batch) % 180 == 0:
|
if index % 180 == 0 or index == end:
|
||||||
yield self.db.add_keys(
|
yield self.db.add_keys(
|
||||||
self.account, self.chain_number, keys_batch
|
self.account, self.chain_number, keys_batch
|
||||||
)
|
)
|
||||||
final_keys.extend(keys_batch)
|
final_keys.extend(keys_batch)
|
||||||
keys_batch.clear()
|
keys_batch.clear()
|
||||||
if keys_batch:
|
|
||||||
yield self.db.add_keys(
|
|
||||||
self.account, self.chain_number, keys_batch
|
|
||||||
)
|
|
||||||
final_keys.extend(keys_batch)
|
|
||||||
keys_batch.clear()
|
|
||||||
return [key[1].address for key in final_keys]
|
return [key[1].address for key in final_keys]
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
|
|
@ -169,6 +169,10 @@ class SQLiteMixin:
|
||||||
|
|
||||||
class BaseDatabase(SQLiteMixin):
|
class BaseDatabase(SQLiteMixin):
|
||||||
|
|
||||||
|
PRAGMAS = """
|
||||||
|
pragma journal_mode=WAL;
|
||||||
|
"""
|
||||||
|
|
||||||
CREATE_PUBKEY_ADDRESS_TABLE = """
|
CREATE_PUBKEY_ADDRESS_TABLE = """
|
||||||
create table if not exists pubkey_address (
|
create table if not exists pubkey_address (
|
||||||
address text primary key,
|
address text primary key,
|
||||||
|
@ -221,10 +225,6 @@ class BaseDatabase(SQLiteMixin):
|
||||||
create index if not exists txi_txoid_idx on txi (txoid);
|
create index if not exists txi_txoid_idx on txi (txoid);
|
||||||
"""
|
"""
|
||||||
|
|
||||||
PRAGMAS = """
|
|
||||||
pragma journal_mode=WAL;
|
|
||||||
"""
|
|
||||||
|
|
||||||
CREATE_TABLES_QUERY = (
|
CREATE_TABLES_QUERY = (
|
||||||
PRAGMAS +
|
PRAGMAS +
|
||||||
CREATE_TX_TABLE +
|
CREATE_TX_TABLE +
|
||||||
|
@ -480,10 +480,10 @@ class BaseDatabase(SQLiteMixin):
|
||||||
) + ', '.join(['(?, ?, ?, ?, ?)'] * len(keys))
|
) + ', '.join(['(?, ?, ?, ?, ?)'] * len(keys))
|
||||||
values = []
|
values = []
|
||||||
for position, pubkey in keys:
|
for position, pubkey in keys:
|
||||||
values.extend([
|
values.extend((
|
||||||
pubkey.address, account.public_key.address, chain, position,
|
pubkey.address, account.public_key.address, chain, position,
|
||||||
sqlite3.Binary(pubkey.pubkey_bytes)
|
sqlite3.Binary(pubkey.pubkey_bytes)
|
||||||
])
|
))
|
||||||
return self.run_operation(sql, values)
|
return self.run_operation(sql, values)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
Loading…
Add table
Reference in a new issue