aboutsummaryrefslogtreecommitdiffstats
path: root/adenosine-pds/src/car.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2022-11-04 00:49:49 -0700
committerBryan Newbold <bnewbold@robocracy.org>2022-11-04 00:49:49 -0700
commit6c5c1e84b3540e3a4da81334f34b4e53cc818f4d (patch)
tree140cd3963067c2e529dbee0fc3d2869adb9204e4 /adenosine-pds/src/car.rs
parented47a0bc0d1d6692c7c365bf33a69d8017129f96 (diff)
downloadadenosine-6c5c1e84b3540e3a4da81334f34b4e53cc818f4d.tar.gz
adenosine-6c5c1e84b3540e3a4da81334f34b4e53cc818f4d.zip
pds: more progress
Diffstat (limited to 'adenosine-pds/src/car.rs')
-rw-r--r--adenosine-pds/src/car.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/adenosine-pds/src/car.rs b/adenosine-pds/src/car.rs
index 35cc3fd..63911e5 100644
--- a/adenosine-pds/src/car.rs
+++ b/adenosine-pds/src/car.rs
@@ -8,28 +8,30 @@ use std::path::PathBuf;
use tokio::fs::File;
use tokio::io::BufReader;
-pub fn load_car_to_sqlite(db_path: &PathBuf, car_path: &PathBuf) -> Result<()> {
+pub fn load_car_to_sqlite(db_path: &PathBuf, car_path: &PathBuf, alias: &str) -> 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, alias)?;
Ok(())
}
pub fn load_car_to_blockstore(
db: &mut BlockStore<libipld::DefaultParams>,
car_path: &PathBuf,
+ alias: &str,
) -> Result<Cid> {
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()?;
- rt.block_on(inner_car_loader(db, car_path))
+ rt.block_on(inner_car_loader(db, car_path, alias))
}
// this async function is wrapped in the sync version above
async fn inner_car_loader(
db: &mut BlockStore<libipld::DefaultParams>,
car_path: &PathBuf,
+ alias: &str,
) -> Result<Cid> {
println!(
"{} - {}",
@@ -55,7 +57,7 @@ async fn inner_car_loader(
// pin the header (?)
if car_header.roots().len() >= 1 {
- db.alias(b"import".to_vec(), Some(&car_header.roots()[0]))?;
+ db.alias(alias.as_bytes(), Some(&car_header.roots()[0]))?;
}
Ok(car_header.roots()[0])