forked from LBRYCommunity/lbry-sdk
simplify generate_keys
This commit is contained in:
parent
e1c0caa357
commit
19e326c140
1 changed files with 3 additions and 10 deletions
|
@ -134,16 +134,9 @@ class HierarchicalDeterministic(AddressManager):
|
||||||
async def _generate_keys(self, start: int, end: int) -> List[str]:
|
async def _generate_keys(self, start: int, end: int) -> List[str]:
|
||||||
if not self.address_generator_lock.locked():
|
if not self.address_generator_lock.locked():
|
||||||
raise RuntimeError('Should not be called outside of address_generator_lock.')
|
raise RuntimeError('Should not be called outside of address_generator_lock.')
|
||||||
keys_batch, final_keys = [], []
|
keys = [(index, self.public_key.child(index)) for index in range(start, end+1)]
|
||||||
for index in range(start, end+1):
|
await self.account.ledger.db.add_keys(self.account, self.chain_number, keys)
|
||||||
keys_batch.append((index, self.public_key.child(index)))
|
return [key[1].address for key in keys]
|
||||||
if index % 180 == 0 or index == end:
|
|
||||||
await self.account.ledger.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]
|
|
||||||
|
|
||||||
def get_address_records(self, only_usable: bool = False, **constraints):
|
def get_address_records(self, only_usable: bool = False, **constraints):
|
||||||
if only_usable:
|
if only_usable:
|
||||||
|
|
Loading…
Reference in a new issue