diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2022-11-04 00:49:49 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2022-11-04 00:49:49 -0700 |
commit | 6c5c1e84b3540e3a4da81334f34b4e53cc818f4d (patch) | |
tree | 140cd3963067c2e529dbee0fc3d2869adb9204e4 /adenosine-pds/src/repo.rs | |
parent | ed47a0bc0d1d6692c7c365bf33a69d8017129f96 (diff) | |
download | adenosine-6c5c1e84b3540e3a4da81334f34b4e53cc818f4d.tar.gz adenosine-6c5c1e84b3540e3a4da81334f34b4e53cc818f4d.zip |
pds: more progress
Diffstat (limited to 'adenosine-pds/src/repo.rs')
-rw-r--r-- | adenosine-pds/src/repo.rs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/adenosine-pds/src/repo.rs b/adenosine-pds/src/repo.rs index 5351379..8c14a18 100644 --- a/adenosine-pds/src/repo.rs +++ b/adenosine-pds/src/repo.rs @@ -9,6 +9,7 @@ use libipld::store::DefaultParams; use libipld::{Block, Cid, Ipld}; use std::borrow::Cow; use std::collections::BTreeMap; +use std::collections::HashSet; use std::path::PathBuf; use std::str::FromStr; @@ -141,6 +142,21 @@ impl RepoStore { } } + pub fn collections(&mut self, did: &str) -> Result<Vec<String>> { + let commit = if let Some(c) = self.lookup_commit(did)? { + self.get_commit(&c)? + } else { + return Err(anyhow!("DID not found in repositories: {}", did)); + }; + let map = self.mst_to_map(&commit.mst_cid)?; + let mut collections: HashSet<String> = Default::default(); + for k in map.keys() { + let coll = k.split("/").nth(0).unwrap(); + collections.insert(coll.to_string()); + } + Ok(collections.into_iter().collect()) + } + pub fn get_atp_record( &mut self, did: &str, @@ -217,8 +233,8 @@ impl RepoStore { } /// returns the root commit from CAR file - pub fn load_car(&mut self, car_path: &PathBuf) -> Result<String> { - let cid = load_car_to_blockstore(&mut self.db, car_path)?; + pub fn load_car(&mut self, car_path: &PathBuf, alias: &str) -> Result<String> { + let cid = load_car_to_blockstore(&mut self.db, car_path, alias)?; Ok(cid.to_string()) } |