Skip to content

Commit

Permalink
🔧 Add CRED_DEF_ACK_TIMEOUT env var to configure cred def creation t…
Browse files Browse the repository at this point in the history
…imeout
  • Loading branch information
ff137 committed Dec 11, 2024
1 parent 47451bf commit 4162cce
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion app/services/definitions/credential_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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:
Expand Down
9 changes: 6 additions & 3 deletions app/util/transaction_acked.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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(
Expand Down
1 change: 1 addition & 0 deletions shared/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))

Expand Down

0 comments on commit 4162cce

Please sign in to comment.