Skip to content

Commit

Permalink
Disable ledger response caching, add logs
Browse files Browse the repository at this point in the history
Signed-off-by: Patrik Stas <[email protected]>
  • Loading branch information
Patrik-Stas committed Jul 28, 2023
1 parent c788d2e commit a1b1e9a
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions aries_vcx_core/src/ledger/indy_vdr_ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ where
V: ResponseCacher + Send + Sync,
{
async fn get_attr(&self, target_did: &str, attr_name: &str) -> VcxCoreResult<String> {
trace!("get_attr >> target_did: {target_did}, attr_name: {attr_name}");
let dest = DidValue::from_str(target_did)?;
let request =
self.request_builder()?
Expand All @@ -189,12 +190,14 @@ where
}

async fn get_nym(&self, did: &str) -> VcxCoreResult<String> {
trace!("get_nym >> did: {did}");
let dest = DidValue::from_str(did)?;
let request = self.request_builder()?.build_get_nym_request(None, &dest)?;
self.submit_request(None, request).await
}

async fn get_txn_author_agreement(&self) -> VcxCoreResult<Option<String>> {
trace!("get_txn_author_agreement >>");
let request = self
.request_builder()?
.build_get_txn_author_agreement_request(None, None)?;
Expand All @@ -205,11 +208,12 @@ where
}

async fn get_ledger_txn(&self, seq_no: i32, submitter_did: Option<&str>) -> VcxCoreResult<String> {
trace!("get_ledger_txn >> seq_no: {seq_no}");
let identifier = submitter_did.map(DidValue::from_str).transpose()?;
let request =
self.request_builder()?
.build_get_txn_request(identifier.as_ref(), LedgerType::DOMAIN.to_id(), seq_no)?;
self.submit_request(Some(&seq_no.to_string()), request).await
self.submit_request(None, request).await
}
}

Expand Down Expand Up @@ -302,29 +306,38 @@ where
V: ResponseCacher + Send + Sync,
{
async fn get_schema(&self, schema_id: &str, _submitter_did: Option<&str>) -> VcxCoreResult<String> {
trace!("get_schema >> schema_id: {schema_id}");
let request = self
.request_builder()?
.build_get_schema_request(None, &SchemaId::from_str(schema_id)?)?;
let response = self.submit_request(Some(schema_id), request).await?;
let response = self.submit_request(None, request).await?;
let schema = self.response_parser.parse_get_schema_response(&response, None)?;
Ok(serde_json::to_string(&schema)?)
}

async fn get_cred_def(&self, cred_def_id: &str, submitter_did: Option<&str>) -> VcxCoreResult<String> {
trace!("get_cred_def >> cred_def_id: {cred_def_id}");
let identifier = submitter_did.map(DidValue::from_str).transpose()?;
let id = CredentialDefinitionId::from_str(cred_def_id)?;
let request = self
.request_builder()?
.build_get_cred_def_request(identifier.as_ref(), &id)?;
let response = self.submit_request(Some(id.as_ref()), request).await?;
// note: Before we try to create credential definition, we are checking if it already
// doesn't exist on the ledger to prevent invalidating the old one.
// When we make the first request, it typically doesn't exist, but we don't want to
// cache such as result. So caching strategy should perhaps only store data in cache
// if ledger response was found / the response is success.
// Therefore parsing should happen prior to caching.
let response = self.submit_request(None, request).await?;
let cred_def = self.response_parser.parse_get_cred_def_response(&response, None)?;
Ok(serde_json::to_string(&cred_def)?)
}

async fn get_rev_reg_def_json(&self, rev_reg_id: &str) -> VcxCoreResult<String> {
trace!("get_rev_reg_def_json >> rev_reg_id: {rev_reg_id}");
let id = RevocationRegistryId::from_str(rev_reg_id)?;
let request = self.request_builder()?.build_get_revoc_reg_def_request(None, &id)?;
let res = self.submit_request(Some(rev_reg_id), request).await?;
let res = self.submit_request(None, request).await?;
let rev_reg_def = self.response_parser.parse_get_revoc_reg_def_response(&res)?;
Ok(serde_json::to_string(&rev_reg_def)?)
}
Expand All @@ -335,6 +348,7 @@ where
from: Option<u64>,
to: Option<u64>,
) -> VcxCoreResult<(String, String, u64)> {
trace!("get_rev_reg_delta_json >> rev_reg_id: {rev_reg_id}, from: {from:?}, to: {to:?}");
let revoc_reg_def_id = RevocationRegistryId::from_str(rev_reg_id)?;

let from = from.map(|x| x as i64);
Expand All @@ -360,6 +374,7 @@ where
}

async fn get_rev_reg(&self, rev_reg_id: &str, timestamp: u64) -> VcxCoreResult<(String, String, u64)> {
trace!("get_rev_reg >> rev_reg_id: {rev_reg_id}, timestamp: {timestamp}");
let revoc_reg_def_id = RevocationRegistryId::from_str(rev_reg_id)?;

let request = self.request_builder()?.build_get_revoc_reg_request(
Expand Down

0 comments on commit a1b1e9a

Please sign in to comment.