await missing on resolve.py

This commit is contained in:
Victor Shyba 2018-11-07 12:05:49 -03:00 committed by Lex Berezhny
parent 3d8b9e2b66
commit 1e13fbee8d

View file

@ -57,13 +57,13 @@ class Resolver:
height, depth, height, depth,
transaction_class=self.transaction_class, transaction_class=self.transaction_class,
hash160_to_address=self.hash160_to_address) hash160_to_address=self.hash160_to_address)
result['certificate'] = self.parse_and_validate_claim_result(certificate_result, result['certificate'] = await self.parse_and_validate_claim_result(certificate_result,
raw=raw) raw=raw)
elif certificate_resolution_type == "claim_id": elif certificate_resolution_type == "claim_id":
result['certificate'] = self.parse_and_validate_claim_result(certificate_response, result['certificate'] = await self.parse_and_validate_claim_result(certificate_response,
raw=raw) raw=raw)
elif certificate_resolution_type == "sequence": elif certificate_resolution_type == "sequence":
result['certificate'] = self.parse_and_validate_claim_result(certificate_response, result['certificate'] = await self.parse_and_validate_claim_result(certificate_response,
raw=raw) raw=raw)
else: else:
log.error("unknown response type: %s", certificate_resolution_type) log.error("unknown response type: %s", certificate_resolution_type)
@ -97,15 +97,15 @@ class Resolver:
height, depth, height, depth,
transaction_class=self.transaction_class, transaction_class=self.transaction_class,
hash160_to_address=self.hash160_to_address) hash160_to_address=self.hash160_to_address)
result['claim'] = self.parse_and_validate_claim_result(claim_result, result['claim'] = await self.parse_and_validate_claim_result(claim_result,
certificate, certificate,
raw) raw)
elif claim_resolution_type == "claim_id": elif claim_resolution_type == "claim_id":
result['claim'] = self.parse_and_validate_claim_result(claim_response, result['claim'] = await self.parse_and_validate_claim_result(claim_response,
certificate, certificate,
raw) raw)
elif claim_resolution_type == "sequence": elif claim_resolution_type == "sequence":
result['claim'] = self.parse_and_validate_claim_result(claim_response, result['claim'] = await self.parse_and_validate_claim_result(claim_response,
certificate, certificate,
raw) raw)
else: else:
@ -151,9 +151,9 @@ class Resolver:
if certificate_id: if certificate_id:
certificate = await self.network.get_claims_by_ids(certificate_id.decode()) certificate = await self.network.get_claims_by_ids(certificate_id.decode())
certificate = certificate.pop(certificate_id.decode()) if certificate else None certificate = certificate.pop(certificate_id.decode()) if certificate else None
return self.parse_and_validate_claim_result(claim_result, certificate=certificate) return await self.parse_and_validate_claim_result(claim_result, certificate=certificate)
def parse_and_validate_claim_result(self, claim_result, certificate=None, raw=False): async def parse_and_validate_claim_result(self, claim_result, certificate=None, raw=False):
if not claim_result or 'value' not in claim_result: if not claim_result or 'value' not in claim_result:
return claim_result return claim_result
@ -174,7 +174,7 @@ class Resolver:
if decoded.has_signature: if decoded.has_signature:
if certificate is None: if certificate is None:
log.info("fetching certificate to check claim signature") log.info("fetching certificate to check claim signature")
certificate = self.network.get_claims_by_ids(decoded.certificate_id) certificate = await self.network.get_claims_by_ids(decoded.certificate_id.decode())
if not certificate: if not certificate:
log.warning('Certificate %s not found', decoded.certificate_id) log.warning('Certificate %s not found', decoded.certificate_id)
claim_result['has_signature'] = True claim_result['has_signature'] = True
@ -244,7 +244,7 @@ class Resolver:
for claim_id in claim_ids: for claim_id in claim_ids:
claim = batch_result[claim_id] claim = batch_result[claim_id]
if claim['name'] == claim_names[claim_id]: if claim['name'] == claim_names[claim_id]:
formatted_claim = self.parse_and_validate_claim_result(claim, certificate) formatted_claim = await self.parse_and_validate_claim_result(claim, certificate)
formatted_claim['absolute_channel_position'] = claim_positions[ formatted_claim['absolute_channel_position'] = claim_positions[
claim['claim_id']] claim['claim_id']]
formatted_claims.append(formatted_claim) formatted_claims.append(formatted_claim)