Skip to content

Commit

Permalink
✨ assert that the tails URI has been updated in the revocation regist…
Browse files Browse the repository at this point in the history
…ry in AcaPyStorage before proceeding to public the rev_reg on ledger
  • Loading branch information
ff137 committed Feb 17, 2024
1 parent 4e8b64c commit 02aa5da
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions app/routes/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import List, Optional

from aries_cloudcontroller import (
AcaPyClient,
ApiException,
CredentialDefinitionSendRequest,
RevRegUpdateTailsFileUri,
Expand Down Expand Up @@ -39,6 +40,7 @@
credential_definition_from_acapy,
credential_schema_from_acapy,
)
from app.util.retry_method import coroutine_with_retry_until_value
from shared import ACAPY_ENDORSER_ALIAS, ACAPY_TAILS_SERVER_BASE_URL
from shared.log_config import get_logger

Expand Down Expand Up @@ -336,8 +338,25 @@ async def create_credential_definition(
# Otherwise onboarding should have created an endorser connection
# for tenants so this fails correctly

# Allow time for record to be updated with new tails file uri
await asyncio.sleep(1)
# We must allow time for record to be updated with new tails file uri
# Therefore, define coroutine that will be retried until expected value is returned
async def get_rev_reg_record_tails_uri(
controller: AcaPyClient, reg_id: str
):
fetched_record = await controller.revocation.get_registry(reg_id)
return fetched_record.result.tails_public_uri

# Wait until the registry record has been updated in AcaPyStorage
if not await coroutine_with_retry_until_value(
coroutine_func=get_rev_reg_record_tails_uri,
args=(aries_controller, rev_reg_id),
logger=logger,
max_attempts=20,
retry_delay=0.5, # maximum 10 seconds duration
):
raise CloudApiException(
"Could not set the Tails public URI for revocation registry. Please try again."
)

bound_logger.debug("Publish revocation registry")
await publish_revocation_registry_on_ledger(
Expand Down

0 comments on commit 02aa5da

Please sign in to comment.