simplify add_keys

This commit is contained in:
Victor Shyba 2019-01-29 14:51:59 -03:00 committed by Lex Berezhny
parent 19e326c140
commit 45669dad33

View file

@ -489,12 +489,12 @@ class BaseDatabase(SQLiteMixin):
return addresses[0] return addresses[0]
async def add_keys(self, account, chain, keys): async def add_keys(self, account, chain, keys):
sql = "insert into pubkey_address (address, account, chain, position, pubkey) values (?, ?, ?, ?, ?)" await self.db.executemany(
values = ( "insert into pubkey_address (address, account, chain, position, pubkey) values (?, ?, ?, ?, ?)",
(pubkey.address, account.public_key.address, chain, position, sqlite3.Binary(pubkey.pubkey_bytes)) ((pubkey.address, account.public_key.address, chain,
for position, pubkey in keys position, sqlite3.Binary(pubkey.pubkey_bytes))
for position, pubkey in keys)
) )
await self.db.executemany(sql, values)
async def _set_address_history(self, address, history): async def _set_address_history(self, address, history):
await self.db.execute( await self.db.execute(