summaryrefslogtreecommitdiffstats
path: root/adenosine-pds/src/mst.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2022-11-07 17:20:28 -0800
committerBryan Newbold <bnewbold@robocracy.org>2022-11-07 17:20:28 -0800
commit9c8aa3d684575b5b5f169b8f6aca75919283d251 (patch)
tree58bc8ca8407b18e5d708d3b68c1f506e29e88be4 /adenosine-pds/src/mst.rs
parent2f414df00e378728701e4061cdb3bebad5df798a (diff)
downloadadenosine-9c8aa3d684575b5b5f169b8f6aca75919283d251.tar.gz
adenosine-9c8aa3d684575b5b5f169b8f6aca75919283d251.zip
pds: implement CAR import/export at repo level
Diffstat (limited to 'adenosine-pds/src/mst.rs')
-rw-r--r--adenosine-pds/src/mst.rs48
1 files changed, 0 insertions, 48 deletions
diff --git a/adenosine-pds/src/mst.rs b/adenosine-pds/src/mst.rs
index 324d139..969f584 100644
--- a/adenosine-pds/src/mst.rs
+++ b/adenosine-pds/src/mst.rs
@@ -1,4 +1,3 @@
-use crate::load_car_to_blockstore;
use anyhow::{anyhow, Context, Result};
use ipfs_sqlite_block_store::BlockStore;
use libipld::cbor::DagCborCodec;
@@ -297,50 +296,3 @@ fn serialize_wip_tree(
db.put_block(block, None)?;
Ok(cid)
}
-
-pub fn repro_mst(car_path: &PathBuf) -> Result<()> {
- // open a temp block store
- let mut db: BlockStore<libipld::DefaultParams> =
- { BlockStore::open_path(ipfs_sqlite_block_store::DbPath::Memory, Default::default())? };
-
- // load CAR contents from file
- load_car_to_blockstore(&mut db, car_path, "repro-import")?;
-
- let all_aliases: Vec<(Vec<u8>, Cid)> = db.aliases()?;
- if all_aliases.is_empty() {
- error!("expected at least one alias in block store");
- std::process::exit(-1);
- }
- let (_alias, commit_cid) = all_aliases[0].clone();
-
- let commit_node: CommitNode = DagCborCodec.decode(
- &db.get_block(&commit_cid)?
- .ok_or(anyhow!("expected commit block in store"))?,
- )?;
- let root_node: RootNode = DagCborCodec.decode(
- &db.get_block(&commit_node.root)?
- .ok_or(anyhow!("expected root block in store"))?,
- )?;
- let _metadata_node: MetadataNode = DagCborCodec.decode(
- &db.get_block(&root_node.meta)?
- .ok_or(anyhow!("expected metadata block in store"))?,
- )?;
-
- // collect key/value sorted map of string/cid, as BTree
- let mut repo_map: BTreeMap<String, Cid> = BTreeMap::new();
- collect_mst_keys(&mut db, &root_node.data, &mut repo_map)?;
-
- // now re-generate nodes
- let updated = generate_mst(&mut db, &repo_map)?;
-
- info!("original root: {}", root_node.data);
- info!("regenerated : {}", updated);
- if root_node.data == updated {
- Ok(())
- } else {
- println!("FAILED");
- let a = get_mst_node(&mut db, &root_node.data)?;
- let b = get_mst_node(&mut db, &updated)?;
- Err(anyhow!("FAILED to reproduce MST: {:?} != {:?}", a, b))
- }
-}