Skip to content

Commit 68408d1

Browse files
committed
Some fixes and hardening
Signed-off-by: jamshale <jamiehalebc@gmail.com>
1 parent 1b60517 commit 68408d1

2 files changed

Lines changed: 29 additions & 26 deletions

File tree

acapy_agent/anoncreds/default/legacy_indy/recover.py

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,12 @@ async def fix_and_publish_from_invalid_accum_err(profile: Profile, err_msg: str)
183183
async def check_retry(accum):
184184
"""Used to manage retries for fixing revocation registry entries."""
185185
if cache is None:
186-
if cache is None:
187-
LOGGER.warning(
188-
"No cache backend configured; skipping retry tracking for %s",
189-
accum,
190-
)
191-
return
186+
LOGGER.warning(
187+
"No cache backend configured; skipping retry tracking for %s",
188+
accum,
189+
)
190+
return
191+
192192
retry_value = await cache.get(accum)
193193
if not retry_value:
194194
await cache.set(accum, 5)
@@ -276,7 +276,6 @@ async def create_and_send_endorser_txn():
276276

277277
# If the accum from the ledger matches the error message, fix it
278278
if accum and accum in err_msg:
279-
# If the accum from the ledger matches the error message, fix it
280279
# if accum and accum in err_msg:
281280
await check_retry(accum)
282281

@@ -391,19 +390,24 @@ async def fix_ledger_entry(
391390
endorser_did=endorser_did,
392391
)
393392

394-
applied_txn = ledger_response["result"]
395-
396-
# Update the local wallets rev reg entry with the new accumulator value
397-
rev_list_value_json = rev_list.value_json
398-
rev_list_value_json["rev_list"]["currentAccumulator"] = applied_txn["txn"][
399-
"data"
400-
]["value"]["accum"]
401-
rev_list.current_accumulator = applied_txn["txn"]["data"]["value"]["accum"]
402-
await session.handle.replace(
403-
CATEGORY_REV_LIST,
404-
rev_list.rev_reg_def_id,
405-
rev_list_value_json,
406-
rev_list.tags,
407-
)
408-
409-
return (rev_reg_delta, recovery_txn, applied_txn)
393+
if isinstance(ledger_response, dict) and "result" in ledger_response:
394+
applied_txn = ledger_response["result"]
395+
396+
# Update the local wallets rev reg entry with the new accumulator value
397+
rev_list_value_json = rev_list.value_json
398+
rev_list_value_json["rev_list"]["currentAccumulator"] = applied_txn[
399+
"txn"
400+
]["data"]["value"]["accum"]
401+
rev_list.current_accumulator = applied_txn["txn"]["data"]["value"][
402+
"accum"
403+
]
404+
await session.handle.replace(
405+
CATEGORY_REV_LIST,
406+
rev_list.rev_reg_def_id,
407+
rev_list_value_json,
408+
rev_list.tags,
409+
)
410+
return (rev_reg_delta, recovery_txn, applied_txn)
411+
412+
# Ledger update not applied, return without applied_txn
413+
return (rev_reg_delta, recovery_txn, {})

acapy_agent/anoncreds/revocation/recover.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
"""Recover a revocation registry."""
1+
"""Recover a revocation registry.
22
3-
"""
4-
This module contains general exceptions or helper functions related to revocation
3+
This module contains general exceptions or helper functions related to revocation
54
registry recovery that are not specific to any one implementation.
65
"""
76

0 commit comments

Comments
 (0)