diff options
Diffstat (limited to 'adenosine-pds/src')
-rw-r--r-- | adenosine-pds/src/repo.rs | 17 |
1 files changed, 17 insertions, 0 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>, } |