diff --git a/app/services/definitions/credential_definitions.py b/app/services/definitions/credential_definitions.py index 6944bdaa7..a54420f0a 100644 --- a/app/services/definitions/credential_definitions.py +++ b/app/services/definitions/credential_definitions.py @@ -13,6 +13,7 @@ from app.util.definitions import credential_definition_from_acapy from app.util.transaction_acked import wait_for_transaction_ack from shared import REGISTRY_SIZE +from shared.constants import CRED_DEF_ACK_TIMEOUT from shared.log_config import get_logger logger = get_logger(__name__) @@ -58,7 +59,10 @@ async def create_credential_definition( if result.txn and result.txn.transaction_id: await wait_for_transaction_ack( - aries_controller=aries_controller, transaction_id=result.txn.transaction_id + aries_controller=aries_controller, + transaction_id=result.txn.transaction_id, + max_attempts=CRED_DEF_ACK_TIMEOUT, + retry_delay=1, ) if support_revocation: diff --git a/app/util/transaction_acked.py b/app/util/transaction_acked.py index 823fbe69d..c5721f31c 100644 --- a/app/util/transaction_acked.py +++ b/app/util/transaction_acked.py @@ -10,7 +10,10 @@ async def wait_for_transaction_ack( - aries_controller: AcaPyClient, transaction_id: str + aries_controller: AcaPyClient, + transaction_id: str, + max_attempts: int = 15, + retry_delay: int = 1, ) -> None: """ Wait for the transaction to be acknowledged by the endorser. @@ -25,8 +28,8 @@ async def wait_for_transaction_ack( field_name="state", expected_value="transaction_acked", logger=bound_logger, - max_attempts=10, - retry_delay=2, + max_attempts=max_attempts, + retry_delay=retry_delay, ) except asyncio.TimeoutError as e: raise CloudApiException( diff --git a/shared/constants.py b/shared/constants.py index 6977ab1e4..e36fff6d0 100644 --- a/shared/constants.py +++ b/shared/constants.py @@ -62,6 +62,7 @@ MAX_NUM_RETRIES = int(os.getenv("MAX_NUM_RETRIES", "3")) # timeout for waiting for registries to be created +CRED_DEF_ACK_TIMEOUT = int(os.getenv("CRED_DEF_ACK_TIMEOUT", "60")) REGISTRY_CREATION_TIMEOUT = int(os.getenv("REGISTRY_CREATION_TIMEOUT", "60")) REGISTRY_SIZE = int(os.getenv("REGISTRY_SIZE", "32767"))