aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adenosine-pds/src/repo.rs17
-rw-r--r--adenosine-pds/templates/at_repo.html2
2 files changed, 18 insertions, 1 deletions
diff --git a/adenosine-pds/src/repo.rs b/adenosine-pds/src/repo.rs
index 9f5fca0..fd75432 100644
--- a/adenosine-pds/src/repo.rs
+++ b/adenosine-pds/src/repo.rs
@@ -11,6 +11,7 @@ use libipld::multihash::Code;
use libipld::prelude::Codec;
use libipld::store::DefaultParams;
use libipld::{Block, Cid, Ipld};
+use serde_json::{json, Value};
use std::borrow::Cow;
use std::collections::BTreeMap;
use std::collections::HashSet;
@@ -28,6 +29,22 @@ pub struct RepoCommit {
pub mst_cid: Cid,
}
+impl RepoCommit {
+ /// Returns a JSON object version of this struct, with CIDs and signatures in expected format
+ /// (aka, CID as a string, not an array of bytes).
+ pub fn to_pretty_json(&self) -> Value {
+ json!({
+ "sig": data_encoding::HEXUPPER.encode(&self.sig),
+ "commit_cid": self.commit_cid.to_string(),
+ "root_cid": self.root_cid.to_string(),
+ "did": self.did.to_string(),
+ "prev": self.prev.map(|v| v.to_string()),
+ "meta_cid": self.meta_cid.to_string(),
+ "mst_cid": self.mst_cid.to_string(),
+ })
+ }
+}
+
pub struct RepoStore {
db: BlockStore<libipld::DefaultParams>,
}
diff --git a/adenosine-pds/templates/at_repo.html b/adenosine-pds/templates/at_repo.html
index 31296db..cc45930 100644
--- a/adenosine-pds/templates/at_repo.html
+++ b/adenosine-pds/templates/at_repo.html
@@ -15,6 +15,6 @@
<pre><code>{{ describe|json }}</code></pre>
<h4>commit node</h4>
-<pre><code>{{ commit|json }}</code></pre>
+<pre><code>{{ commit.to_pretty_json()|json }}</code></pre>
{% endblock %}