diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2022-11-06 21:49:49 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2022-11-06 21:49:49 -0800 |
commit | 55cad7251ecdda15989842d3b686e46d0b42df0e (patch) | |
tree | 97ca052a4ef26e96a018fa70fe8eecebf1f5273d | |
parent | 6111c481fac3d5c305a379b3be8afb87190db3d5 (diff) | |
download | adenosine-55cad7251ecdda15989842d3b686e46d0b42df0e.tar.gz adenosine-55cad7251ecdda15989842d3b686e46d0b42df0e.zip |
pds: wrangle 'iroh_car' in to PDS code
-rw-r--r-- | Cargo.lock | 18 | ||||
-rw-r--r-- | adenosine-pds/Cargo.toml | 8 | ||||
-rw-r--r-- | adenosine-pds/src/car.rs | 2 | ||||
-rw-r--r-- | adenosine-pds/src/lib.rs | 1 | ||||
-rw-r--r-- | adenosine-pds/src/vendored.rs | 1 | ||||
-rw-r--r-- | adenosine-pds/src/vendored/iroh_car/error.rs | 3 | ||||
-rw-r--r-- | adenosine-pds/src/vendored/iroh_car/header.rs | 15 | ||||
-rw-r--r-- | adenosine-pds/src/vendored/iroh_car/mod.rs | 10 | ||||
-rw-r--r-- | adenosine-pds/src/vendored/iroh_car/reader.rs | 10 | ||||
-rw-r--r-- | adenosine-pds/src/vendored/iroh_car/util.rs | 2 | ||||
-rw-r--r-- | adenosine-pds/src/vendored/iroh_car/writer.rs | 4 |
11 files changed, 41 insertions, 33 deletions
@@ -45,14 +45,15 @@ dependencies = [ "data-encoding", "dotenv", "futures", + "integer-encoding", "ipfs-sqlite-block-store", - "iroh-car", "jsonschema", "k256", "lazy_static", "libipld", "log", "multibase", + "multihash", "p256", "pretty_env_logger", "rouille", @@ -63,6 +64,7 @@ dependencies = [ "serde_json", "sha256", "structopt", + "thiserror", "tokio", "ucan", ] @@ -1520,20 +1522,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" [[package]] -name = "iroh-car" -version = "0.1.0-vendored.0" -dependencies = [ - "cid", - "futures", - "integer-encoding", - "libipld", - "libipld-cbor", - "multihash", - "thiserror", - "tokio", -] - -[[package]] name = "iso8601" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/adenosine-pds/Cargo.toml b/adenosine-pds/Cargo.toml index eb35f2e..64765a4 100644 --- a/adenosine-pds/Cargo.toml +++ b/adenosine-pds/Cargo.toml @@ -26,7 +26,8 @@ rusqlite_migration = "*" jsonschema = "*" schemafy = "*" rouille = "*" -iroh-car = { version = "0.1.0-vendored.0", path = "../iroh-car" } +# NOTE: vendored for now +#iroh-car = "*" adenosine-cli = { version = "0.1.0-dev.0", path = "../adenosine-cli" } tokio = { version = "1", features = ["full"] } futures = "0.3" @@ -43,6 +44,11 @@ bs58 = "*" async-trait = "*" dotenv = "*" +# for vendored iroh-car +thiserror = "1.0" +integer-encoding = { version = "3", features = ["tokio_async"] } +multihash = "0.16" + [package.metadata.deb] maintainer = "Bryan Newbold <bnewbold@robocracy.org>" depends = "$auto" diff --git a/adenosine-pds/src/car.rs b/adenosine-pds/src/car.rs index b14d0b1..43b4e1f 100644 --- a/adenosine-pds/src/car.rs +++ b/adenosine-pds/src/car.rs @@ -1,8 +1,8 @@ use anyhow::Result; +use crate::vendored::iroh_car::CarReader; use futures::TryStreamExt; use ipfs_sqlite_block_store::BlockStore; -use iroh_car::CarReader; use libipld::{Block, Cid}; use std::path::PathBuf; use tokio::fs::File; diff --git a/adenosine-pds/src/lib.rs b/adenosine-pds/src/lib.rs index 4071570..ac3868a 100644 --- a/adenosine-pds/src/lib.rs +++ b/adenosine-pds/src/lib.rs @@ -20,6 +20,7 @@ mod models; pub mod mst; mod repo; mod ucan_p256; +mod vendored; pub use car::{load_car_to_blockstore, load_car_to_sqlite}; pub use crypto::{KeyPair, PubKey}; diff --git a/adenosine-pds/src/vendored.rs b/adenosine-pds/src/vendored.rs new file mode 100644 index 0000000..74584ad --- /dev/null +++ b/adenosine-pds/src/vendored.rs @@ -0,0 +1 @@ +pub mod iroh_car; diff --git a/adenosine-pds/src/vendored/iroh_car/error.rs b/adenosine-pds/src/vendored/iroh_car/error.rs index 3579413..1edcefe 100644 --- a/adenosine-pds/src/vendored/iroh_car/error.rs +++ b/adenosine-pds/src/vendored/iroh_car/error.rs @@ -1,3 +1,4 @@ +use libipld::cid; use thiserror::Error; /// Car utility error @@ -10,7 +11,7 @@ pub enum Error { #[error("Io error: {0}")] Io(#[from] std::io::Error), #[error("Cbor encoding error: {0}")] - Cbor(#[from] ipld::error::Error), + Cbor(#[from] libipld::error::Error), #[error("ld read too large {0}")] LdReadTooLarge(usize), } diff --git a/adenosine-pds/src/vendored/iroh_car/header.rs b/adenosine-pds/src/vendored/iroh_car/header.rs index c004e35..051d2cc 100644 --- a/adenosine-pds/src/vendored/iroh_car/header.rs +++ b/adenosine-pds/src/vendored/iroh_car/header.rs @@ -1,8 +1,9 @@ -use cid::Cid; -use ipld::codec::Codec; -use ipld_cbor::DagCborCodec; +use libipld::cbor::DagCborCodec; +use libipld::codec::Codec; +use libipld::ipld; +use libipld::Cid; -use crate::error::Error; +use super::error::Error; /// A car header. #[derive(Debug, Clone, PartialEq, Eq)] @@ -57,7 +58,7 @@ impl CarHeader { } /// CAR file header version 1. -#[derive(Debug, Clone, Default, ipld::DagCbor, PartialEq, Eq)] +#[derive(Debug, Clone, Default, libipld::DagCbor, PartialEq, Eq)] pub struct CarHeaderV1 { #[ipld] pub roots: Vec<Cid>, @@ -80,8 +81,8 @@ impl From<Vec<Cid>> for CarHeaderV1 { #[cfg(test)] mod tests { - use ipld::codec::{Decode, Encode}; - use ipld_cbor::DagCborCodec; + use libipld::cbor::DagCborCodec; + use libipld::codec::{Decode, Encode}; use multihash::MultihashDigest; use super::*; diff --git a/adenosine-pds/src/vendored/iroh_car/mod.rs b/adenosine-pds/src/vendored/iroh_car/mod.rs new file mode 100644 index 0000000..b40e046 --- /dev/null +++ b/adenosine-pds/src/vendored/iroh_car/mod.rs @@ -0,0 +1,10 @@ +/// Module version of lib.rs +mod error; +mod header; +mod reader; +mod util; +mod writer; + +pub use header::CarHeader; +pub use reader::CarReader; +pub use writer::CarWriter; diff --git a/adenosine-pds/src/vendored/iroh_car/reader.rs b/adenosine-pds/src/vendored/iroh_car/reader.rs index c0209be..916f27e 100644 --- a/adenosine-pds/src/vendored/iroh_car/reader.rs +++ b/adenosine-pds/src/vendored/iroh_car/reader.rs @@ -1,8 +1,8 @@ -use cid::Cid; use futures::Stream; +use libipld::Cid; use tokio::io::AsyncRead; -use crate::{ +use super::{ error::Error, header::CarHeader, util::{ld_read, read_node}, @@ -61,12 +61,12 @@ where mod tests { use std::io::Cursor; - use cid::Cid; use futures::TryStreamExt; - use ipld_cbor::DagCborCodec; + use libipld::cbor::DagCborCodec; + use libipld::Cid; use multihash::MultihashDigest; - use crate::{header::CarHeaderV1, writer::CarWriter}; + use super::super::{header::CarHeaderV1, writer::CarWriter}; use super::*; diff --git a/adenosine-pds/src/vendored/iroh_car/util.rs b/adenosine-pds/src/vendored/iroh_car/util.rs index 25be761..90435b1 100644 --- a/adenosine-pds/src/vendored/iroh_car/util.rs +++ b/adenosine-pds/src/vendored/iroh_car/util.rs @@ -1,5 +1,5 @@ -use cid::Cid; use integer_encoding::VarIntAsyncReader; +use libipld::Cid; use tokio::io::{AsyncRead, AsyncReadExt}; use super::error::Error; diff --git a/adenosine-pds/src/vendored/iroh_car/writer.rs b/adenosine-pds/src/vendored/iroh_car/writer.rs index 9f17eb9..4299b5d 100644 --- a/adenosine-pds/src/vendored/iroh_car/writer.rs +++ b/adenosine-pds/src/vendored/iroh_car/writer.rs @@ -1,8 +1,8 @@ -use cid::Cid; use integer_encoding::VarIntAsyncWriter; +use libipld::Cid; use tokio::io::{AsyncWrite, AsyncWriteExt}; -use crate::{error::Error, header::CarHeader}; +use super::{error::Error, header::CarHeader}; #[derive(Debug)] pub struct CarWriter<W> { |