Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Root event date #125

Merged
merged 23 commits into from
Oct 13, 2023
Merged

Root event date #125

merged 23 commits into from
Oct 13, 2023

Conversation

thobson88
Copy link
Collaborator

@thobson88 thobson88 commented Sep 26, 2023

Server-side code to support trustchain-mobile #26.

Adds an HTTP endpoint for getting candidate root DIDs (each with a corresponding Bitcoin transaction ID) that were timestamped on a given a calendar date.

Does not address the related #130.

@thobson88 thobson88 marked this pull request as draft October 5, 2023 15:01
@thobson88 thobson88 self-assigned this Oct 5, 2023
@thobson88 thobson88 marked this pull request as ready for review October 11, 2023 15:06
// Can unwrap as already verified above.
.unwrap();
let chain =
TrustchainAPI::verify(issuer, root_event_time.into(), &verifier)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove into() (clippy)

Comment on lines 105 to 109
let mut did = String::from_str("did:").unwrap();
did.push_str(method);
did.push_str(":");
did.push_str(did_suffix);
did
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let mut did = String::from_str("did:").unwrap();
did.push_str(method);
did.push_str(":");
did.push_str(did_suffix);
did
format!("did:{method}:{did_suffix}")

@@ -108,6 +118,7 @@ impl IntoResponse for TrustchainHTTPError {
err @ TrustchainHTTPError::NoCredentialIssuer => {
(StatusCode::BAD_REQUEST, err.to_string())
}
err @ TrustchainHTTPError::RootError(_) => (StatusCode::BAD_REQUEST, err.to_string()),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the HTTP status

debug!("Getting root candidates for {0}", date);

// Return the cached vector of root DID candidates, if available.
if root_candidates.lock().unwrap().contains_key(&date) {
Copy link
Collaborator

@sgreenbury sgreenbury Oct 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps create a single lock to use throughout function?

@@ -134,20 +131,20 @@ where

/// Gets RPC client.
fn rpc_client(&self) -> &bitcoincore_rpc::Client {
self.rpc_client.as_ref().unwrap()
self.rpc_client.as_ref().unwrap() // TODO: handle failure here.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is ok as the API has constrained it to exist here

}

/// Gets IPFS client.
fn ipfs_client(&self) -> &IpfsClient {
self.ipfs_client.as_ref().unwrap()
self.ipfs_client.as_ref().unwrap() // TODO: handle failure here.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above on 134

Copy link
Collaborator

@edchapman88 edchapman88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good!

@thobson88 thobson88 merged commit 5088333 into main Oct 13, 2023
5 checks passed
@thobson88 thobson88 deleted the root-event-date branch October 13, 2023 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants