fix maybe_migrate_certificates blocking the api while populating channel signing keys

This commit is contained in:
Jack Robison 2020-03-16 14:40:26 -04:00
parent ec20d9a2a8
commit af7a7b4dc6
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -532,6 +532,9 @@ class Account:
return ecdsa.SigningKey.from_pem(private_key_pem, hashfunc=sha256) return ecdsa.SigningKey.from_pem(private_key_pem, hashfunc=sha256)
async def maybe_migrate_certificates(self): async def maybe_migrate_certificates(self):
def to_der(private_key_pem):
return ecdsa.SigningKey.from_pem(private_key_pem, hashfunc=sha256).get_verifying_key().to_der()
if not self.channel_keys: if not self.channel_keys:
return return
channel_keys = {} channel_keys = {}
@ -540,8 +543,7 @@ class Account:
continue continue
if "-----BEGIN EC PRIVATE KEY-----" not in private_key_pem: if "-----BEGIN EC PRIVATE KEY-----" not in private_key_pem:
continue continue
private_key = ecdsa.SigningKey.from_pem(private_key_pem, hashfunc=sha256) public_key_der = await asyncio.get_event_loop().run_in_executor(None, to_der, private_key_pem)
public_key_der = private_key.get_verifying_key().to_der()
channel_keys[self.ledger.public_key_to_address(public_key_der)] = private_key_pem channel_keys[self.ledger.public_key_to_address(public_key_der)] = private_key_pem
if self.channel_keys != channel_keys: if self.channel_keys != channel_keys:
self.channel_keys = channel_keys self.channel_keys = channel_keys