Skip to content

Commit

Permalink
Merge pull request #355 from dbluhm/preserve-exchange-records
Browse files Browse the repository at this point in the history
Add CLI arg for preserving exchange records
  • Loading branch information
andrewwhitehead authored Feb 26, 2020
2 parents 317b09f + 499d36f commit 2f6164f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 7 additions & 0 deletions aries_cloudagent/config/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,11 @@ def add_arguments(self, parser: ArgumentParser):
metavar="<log-path>",
help="Write timing information to a given log file.",
)
parser.add_argument(
"--preserve-exchange-records",
action="store_true",
help="Keep credential exchange records after exchange has completed."
)

def get_settings(self, args: Namespace) -> dict:
"""Get protocol settings."""
Expand All @@ -577,6 +582,8 @@ def get_settings(self, args: Namespace) -> dict:
settings["timing.enabled"] = True
if args.timing_log:
settings["timing.log_file"] = args.timing_log
if args.preserve_exchange_records:
settings["preserve_exchange_records"] = True
return settings


Expand Down
10 changes: 6 additions & 4 deletions aries_cloudagent/protocols/issue_credential/v1_0/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,9 @@ async def store_credential(
credential_exchange_record.parent_thread_id,
)

# Delete the exchange record since we're done with it
await credential_exchange_record.delete_record(self.context)
if not self.context.settings.get("preserve_exchange_records"):
# Delete the exchange record since we're done with it
await credential_exchange_record.delete_record(self.context)
return (credential_exchange_record, credential_ack_message)

async def receive_credential_ack(self) -> V10CredentialExchange:
Expand All @@ -595,7 +596,8 @@ async def receive_credential_ack(self) -> V10CredentialExchange:
credential_exchange_record.state = V10CredentialExchange.STATE_ACKED
await credential_exchange_record.save(self.context, reason="credential acked")

# We're done with the exchange so delete
await credential_exchange_record.delete_record(self.context)
if not self.context.settings.get("preserve_exchange_records"):
# We're done with the exchange so delete
await credential_exchange_record.delete_record(self.context)

return credential_exchange_record

0 comments on commit 2f6164f

Please sign in to comment.