diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2022-11-02 21:10:57 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2022-11-02 21:10:57 -0700 |
commit | 9b4a5c6bfd2b816fc9b281bdd12e67a0e0245f4c (patch) | |
tree | 9aabb43924f610fcf7946fa4a29f4315d3f25ded /adenosine-pds/src/car.rs | |
parent | 8319500ed7bb1bfba15b74132f19dc2b960ea7c1 (diff) | |
download | adenosine-9b4a5c6bfd2b816fc9b281bdd12e67a0e0245f4c.tar.gz adenosine-9b4a5c6bfd2b816fc9b281bdd12e67a0e0245f4c.zip |
pds: progress on repo mst wrapper
Diffstat (limited to 'adenosine-pds/src/car.rs')
-rw-r--r-- | adenosine-pds/src/car.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/adenosine-pds/src/car.rs b/adenosine-pds/src/car.rs index 5731848..35cc3fd 100644 --- a/adenosine-pds/src/car.rs +++ b/adenosine-pds/src/car.rs @@ -3,7 +3,7 @@ use anyhow::Result; use futures::TryStreamExt; use ipfs_sqlite_block_store::BlockStore; use iroh_car::CarReader; -use libipld::block::Block; +use libipld::{Block, Cid}; use std::path::PathBuf; use tokio::fs::File; use tokio::io::BufReader; @@ -12,13 +12,14 @@ pub fn load_car_to_sqlite(db_path: &PathBuf, car_path: &PathBuf) -> Result<()> { let mut db: BlockStore<libipld::DefaultParams> = { BlockStore::open(db_path, Default::default())? }; - load_car_to_blockstore(&mut db, car_path) + load_car_to_blockstore(&mut db, car_path)?; + Ok(()) } pub fn load_car_to_blockstore( db: &mut BlockStore<libipld::DefaultParams>, car_path: &PathBuf, -) -> Result<()> { +) -> Result<Cid> { let rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build()?; @@ -29,7 +30,7 @@ pub fn load_car_to_blockstore( async fn inner_car_loader( db: &mut BlockStore<libipld::DefaultParams>, car_path: &PathBuf, -) -> Result<()> { +) -> Result<Cid> { println!( "{} - {}", std::env::current_dir()?.display(), @@ -52,10 +53,10 @@ async fn inner_car_loader( }) .await?; - // pin the header + // pin the header (?) if car_header.roots().len() >= 1 { db.alias(b"import".to_vec(), Some(&car_header.roots()[0]))?; } - Ok(()) + Ok(car_header.roots()[0]) } |