Skip to content

Commit

Permalink
🎨 Clean up constants
Browse files Browse the repository at this point in the history
  • Loading branch information
ff137 committed Dec 11, 2024
1 parent 6567a2e commit 96af13b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
7 changes: 2 additions & 5 deletions app/routes/revocation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import asyncio
import os
from typing import Optional

from aries_cloudcontroller import IssuerCredRevRecord, RevRegWalletUpdatedResult
Expand All @@ -18,15 +17,13 @@
)
from app.services import revocation_registry
from app.util.retry_method import coroutine_with_retry_until_value
from shared import PUBLISH_REVOCATIONS_TIMEOUT
from shared.log_config import get_logger

logger = get_logger(__name__)

router = APIRouter(prefix="/v1/issuer/credentials", tags=["revocation"])

# Config for /publish-revocations
publish_revocations_timeout = int(os.getenv("PUBLISH_REVOCATIONS_TIMEOUT", "60"))


@router.post("/revoke", summary="Revoke a Credential (if revocable)")
async def revoke_credential(
Expand Down Expand Up @@ -213,7 +210,7 @@ async def publish_revocations(
field_name="state",
expected_value="transaction_acked",
logger=bound_logger,
max_attempts=publish_revocations_timeout,
max_attempts=PUBLISH_REVOCATIONS_TIMEOUT,
retry_delay=1,
)
except asyncio.TimeoutError as e:
Expand Down
3 changes: 1 addition & 2 deletions app/services/definitions/credential_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
from app.util.assert_public_did import assert_public_did
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 import CRED_DEF_ACK_TIMEOUT, REGISTRY_SIZE
from shared.log_config import get_logger

logger = get_logger(__name__)
Expand Down
7 changes: 2 additions & 5 deletions app/services/onboarding/util/register_issuer_did.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import asyncio
import os
from logging import Logger

from aries_cloudcontroller import (
Expand All @@ -17,9 +16,7 @@
set_endorser_info,
set_endorser_role,
)
from shared import ACAPY_ENDORSER_ALIAS

MAX_ATTEMPTS = int(os.getenv("WAIT_ISSUER_DID_MAX_ATTEMPTS", "30"))
from shared import ACAPY_ENDORSER_ALIAS, ISSUER_DID_ENDORSE_TIMEOUT


async def create_connection_with_endorser(
Expand Down Expand Up @@ -258,7 +255,7 @@ async def wait_transactions_endorsed(
issuer_controller: AcaPyClient,
issuer_connection_id: str,
logger: Logger,
max_attempts: int = MAX_ATTEMPTS,
max_attempts: int = ISSUER_DID_ENDORSE_TIMEOUT,
retry_delay: float = 1.0,
) -> None:
attempt = 0
Expand Down
5 changes: 3 additions & 2 deletions shared/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@

# client.py
TEST_CLIENT_TIMEOUT = int(os.getenv("TEST_CLIENT_TIMEOUT", "300"))
MAX_NUM_RETRIES = int(os.getenv("MAX_NUM_RETRIES", "3"))

# timeout for waiting for registries to be created
# timeout for endorsement events and registry creation
CRED_DEF_ACK_TIMEOUT = int(os.getenv("CRED_DEF_ACK_TIMEOUT", "60"))
PUBLISH_REVOCATIONS_TIMEOUT = int(os.getenv("PUBLISH_REVOCATIONS_TIMEOUT", "60"))
REGISTRY_CREATION_TIMEOUT = int(os.getenv("REGISTRY_CREATION_TIMEOUT", "60"))
REGISTRY_SIZE = int(os.getenv("REGISTRY_SIZE", "32767"))
ISSUER_DID_ENDORSE_TIMEOUT = int(os.getenv("ISSUER_DID_ENDORSE_TIMEOUT", "30"))

# NATS
NATS_SERVER = os.getenv("NATS_SERVER", "nats://nats:4222")
Expand Down

0 comments on commit 96af13b

Please sign in to comment.