aboutsummaryrefslogtreecommitdiffstats
path: root/adenosine-pds/src/mst.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2022-11-02 01:39:19 -0700
committerBryan Newbold <bnewbold@robocracy.org>2022-11-02 01:39:19 -0700
commit5a9333475518c3a7d9396d120e07d813252a0a09 (patch)
treed38b3faa7e334e7674f6819f855b5dbbcb9eb180 /adenosine-pds/src/mst.rs
parentf3fdc7ba600c65fdb05efc2fd5e9a651b4b9956e (diff)
downloadadenosine-5a9333475518c3a7d9396d120e07d813252a0a09.tar.gz
adenosine-5a9333475518c3a7d9396d120e07d813252a0a09.zip
pds: refactoring
Diffstat (limited to 'adenosine-pds/src/mst.rs')
-rw-r--r--adenosine-pds/src/mst.rs19
1 files changed, 12 insertions, 7 deletions
diff --git a/adenosine-pds/src/mst.rs b/adenosine-pds/src/mst.rs
index 3e01a92..db5e457 100644
--- a/adenosine-pds/src/mst.rs
+++ b/adenosine-pds/src/mst.rs
@@ -76,7 +76,7 @@ fn print_mst_keys(db: &mut BlockStore<libipld::DefaultParams>, cid: &Cid) -> Res
let mut key: String = "".to_string();
for entry in node.e.iter() {
key = format!("{}{}", &key[0..entry.p as usize], entry.k);
- println!("{}\t-> {}", key, entry.v);
+ println!("\t{}\t-> {}", key, entry.v);
if let Some(ref right) = entry.t {
print_mst_keys(db, right)?;
}
@@ -92,12 +92,16 @@ pub fn dump_mst_keys(db_path: &PathBuf) -> Result<()> {
error!("expected at least one alias in block store");
std::process::exit(-1);
}
- let (alias, commit_cid) = all_aliases[0].clone();
- info!(
- "starting from {} [{}]",
- commit_cid,
- String::from_utf8_lossy(&alias)
- );
+
+ // print all the aliases
+ for (alias, commit_cid) in all_aliases.iter() {
+ let did = String::from_utf8_lossy(&alias);
+ println!("{} -> {}", did, commit_cid);
+ }
+
+ let (did, commit_cid) = all_aliases[0].clone();
+ let did = String::from_utf8_lossy(&did);
+ info!("starting from {} [{}]", commit_cid, did);
// NOTE: the faster way to develop would have been to decode to libipld::ipld::Ipld first? meh
@@ -128,6 +132,7 @@ pub fn dump_mst_keys(db_path: &PathBuf) -> Result<()> {
debug!("MST root node: {:?}", mst_node);
debug!("============");
+ println!("{}", did);
print_mst_keys(&mut db, &root.data)?;
Ok(())
}