Skip to content

Commit

Permalink
Fix askar transaction issue when updating revocation status
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Costanzo <[email protected]>
  • Loading branch information
ianco committed Oct 21, 2021
1 parent da61da9 commit b25ae4f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
12 changes: 9 additions & 3 deletions aries_cloudagent/indy/credx/issuer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
)

from ...askar.profile import AskarProfile
from ...core.profile import ProfileSession

from ..issuer import (
IndyIssuer,
Expand Down Expand Up @@ -375,7 +376,11 @@ async def create_credential(
return credential.to_json(), credential_revocation_id

async def revoke_credentials(
self, revoc_reg_id: str, tails_file_path: str, cred_revoc_ids: Sequence[str]
self,
revoc_reg_id: str,
tails_file_path: str,
cred_revoc_ids: Sequence[str],
transaction: ProfileSession = None,
) -> Tuple[str, Sequence[str]]:
"""
Revoke a set of credentials in a revocation registry.
Expand All @@ -390,7 +395,7 @@ async def revoke_credentials(
"""

txn = await self._profile.transaction()
txn = transaction if transaction else await self._profile.transaction()
try:
rev_reg_def = await txn.handle.fetch(CATEGORY_REV_REG_DEF, revoc_reg_id)
rev_reg = await txn.handle.fetch(
Expand Down Expand Up @@ -471,7 +476,8 @@ async def revoke_credentials(
await txn.handle.replace(
CATEGORY_REV_REG_INFO, revoc_reg_id, value_json=rev_info
)
await txn.commit()
if not transaction:
await txn.commit()
except AskarError as err:
raise IndyIssuerError("Error saving revocation registry") from err
else:
Expand Down
7 changes: 6 additions & 1 deletion aries_cloudagent/indy/issuer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Sequence, Tuple

from ..core.error import BaseError
from ..core.profile import ProfileSession


DEFAULT_CRED_DEF_TAG = "default"
Expand Down Expand Up @@ -145,7 +146,11 @@ async def create_credential(

@abstractmethod
async def revoke_credentials(
self, revoc_reg_id: str, tails_file_path: str, cred_rev_ids: Sequence[str]
self,
revoc_reg_id: str,
tails_file_path: str,
cred_rev_ids: Sequence[str],
transaction: ProfileSession = None,
) -> Tuple[str, Sequence[str]]:
"""
Revoke a set of credentials in a revocation registry.
Expand Down
7 changes: 6 additions & 1 deletion aries_cloudagent/indy/sdk/issuer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import indy.blob_storage
from indy.error import AnoncredsRevocationRegistryFullError, IndyError, ErrorCode

from ...core.profile import ProfileSession
from ...indy.sdk.profile import IndySdkProfile
from ...messaging.util import encode
from ...revocation.models.issuer_cred_rev_record import IssuerCredRevRecord
Expand Down Expand Up @@ -262,7 +263,11 @@ async def create_credential(
return (credential_json, cred_rev_id)

async def revoke_credentials(
self, rev_reg_id: str, tails_file_path: str, cred_rev_ids: Sequence[str]
self,
rev_reg_id: str,
tails_file_path: str,
cred_rev_ids: Sequence[str],
transaction: ProfileSession = None,
) -> Tuple[str, Sequence[str]]:
"""
Revoke a set of credentials in a revocation registry.
Expand Down
1 change: 1 addition & 0 deletions aries_cloudagent/revocation/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ async def publish_pending_revocations(
issuer_rr_rec.revoc_reg_id,
issuer_rr_rec.tails_local_path,
crids,
transaction=txn,
)
issuer_rr_rec.revoc_reg_entry = json.loads(delta_json)
await issuer_rr_rec.send_entry(self._profile)
Expand Down

0 comments on commit b25ae4f

Please sign in to comment.