Skip to content

Commit

Permalink
refactor: rename packages and format code
Browse files Browse the repository at this point in the history
Renamed and reorganized several packages:
- Renamed monoutils-store to ipldstore
- Renamed monoutils-cryptdag to cryptdag
- Renamed monoutils-did to did-wk
- Removed unused monoutils-ucan package
- Updated all imports to use new package names

The main changes involve:
- Moving monoutils-store functionality to ipldstore
- Formatting the entire codebase
- Updating all references and imports across the codebase
- Removing unused package monoutils-ucan
- Simplifying package naming convention
  • Loading branch information
appcypher committed Feb 13, 2025
1 parent 3155bba commit 289ca4d
Show file tree
Hide file tree
Showing 76 changed files with 306 additions and 315 deletions.
70 changes: 33 additions & 37 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ members = [
"monofs",
"monopacks",
"monoutils",
"monoutils-did",
"monoutils-store",
"monoutils-ucan",
"monoutils-cryptdag",
"ipldstore",
"cryptdag",
"did-wk",
]
resolver = "2"

Expand Down Expand Up @@ -49,7 +48,7 @@ rand = "0.9"
reqwest = { version = "0.12", features = ["stream", "json"] }
reqwest-middleware = "0.3" # Cannot upgrade to 0.4 due to https://github.com/TrueLayer/reqwest-middleware/issues/204
reqwest-retry = "0.6" # Cannot upgrade to 0.7 due to https://github.com/TrueLayer/reqwest-middleware/issues/204
monoutils-store = { version = "0.2", path = "./monoutils-store" }
ipldstore = { version = "0.2", path = "./ipldstore" }
monoutils = { version = "0.2", path = "./monoutils" }
monofs = { version = "0.2", path = "./monofs" }
multihash = "0.19"
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion monoutils-cryptdag/lib/lib.rs → cryptdag/lib/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `monoutils-cryptdag` is a key generation library for data structures that can be represented as trees or DAGs.
//! `cryptdag` is a key generation library for data structures that can be represented as trees or DAGs.
#![warn(missing_docs)]
#![allow(clippy::module_inception)]
Expand Down
4 changes: 2 additions & 2 deletions monoutils-did/Cargo.toml → did-wk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "monoutils-did"
name = "did-wk"
version = "0.1.0"
description = "`monoutils-did` is a library for working with DID-Web-Key and DID-Key decentralized identifiers (DIDs) methods."
description = "`did-wk` is a library for working with DID-Web-Key and DID-Key decentralized identifiers (DIDs) methods."
license.workspace = true
repository.workspace = true
authors.workspace = true
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion monoutils-did/lib/lib.rs → did-wk/lib/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `monoutils-did` is a library for working with DID-Web-Key and DID-Key decentralized identifiers (DIDs) methods.
//! `did-wk` is a library for working with DID-Web-Key and DID-Key decentralized identifiers (DIDs) methods.
#![warn(missing_docs)]
#![allow(clippy::module_inception)]
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions monoutils-store/Cargo.toml → ipldstore/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[package]
name = "monoutils-store"
name = "ipldstore"
version = "0.2.1"
description = "`monoutils-store` is a library for working with IPLD content-addressed stores (CAS)."
description = "`ipldstore` is a library for working with IPLD content-addressed stores (CAS)."
license.workspace = true
repository.workspace = true
authors.workspace = true
edition.workspace = true
readme = "README.md"

[lib]
name = "monoutils_store"
name = "ipldstore"
path = "lib/lib.rs"

[dependencies]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -581,8 +581,7 @@ mod tests {

#[tokio::test]
async fn test_fastcdc_chunk_distribution() -> anyhow::Result<()> {
use rand::rngs::StdRng;
use rand::{Rng, SeedableRng};
use rand::{rngs::StdRng, Rng, SeedableRng};

// Test both random and repeating data to verify our normalization works
let test_cases = vec![
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ impl Chunker for FixedSizeChunker {
Ok(Box::pin(s))
}


async fn chunk_max_size(&self) -> StoreResult<Option<u64>> {
Ok(Some(self.chunk_size))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,7 @@ mod tests {

#[tokio::test]
async fn test_gearcdc_chunk_distribution() -> anyhow::Result<()> {
use rand::rngs::StdRng;
use rand::{Rng, SeedableRng};
use rand::{rngs::StdRng, Rng, SeedableRng};

// Test both random and repeating data to verify our high-bit feedback mechanism
let test_cases = vec![
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
mod fixed;
mod fastcdc;
mod fixed;
mod gearcdc;

//--------------------------------------------------------------------------------------------------
// Exports
//--------------------------------------------------------------------------------------------------

pub use fixed::*;
pub use fastcdc::*;
pub use fixed::*;
pub use gearcdc::*;
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::{Codec, IpldReferences, IpldStore, RawStore, StoreError, StoreResult}
/// ## Examples
///
/// ```
/// use monoutils_store::{MemoryStore, DualStore, DualStoreConfig, Choice};
/// use ipldstore::{MemoryStore, DualStore, DualStoreConfig, Choice};
///
/// // Create two stores
/// let store_a = MemoryStore::default();
Expand Down Expand Up @@ -64,7 +64,7 @@ where
/// ## Examples
///
/// ```
/// use monoutils_store::{DualStoreConfig, Choice};
/// use ipldstore::{StoreConfig, DualStoreConfig, Choice};
///
/// // Configure to read from store A and write to store B
/// let config = DualStoreConfig {
Expand Down Expand Up @@ -102,7 +102,7 @@ pub enum Choice {
/// ## Examples
///
/// ```
/// use monoutils_store::{DualStoreConfig, Choice};
/// use ipldstore::{StoreConfig, DualStoreConfig, Choice};
///
/// // Default configuration - use store A for both reads and writes
/// let default_config = DualStoreConfig::default();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,7 @@ where
mod tests {
use crate::DEFAULT_MAX_CHUNK_SIZE;

use super::helper::TestNode;
use super::*;
use super::{helper::TestNode, *};
use multihash_codetable::{Code, MultihashDigest};
use tokio::io::AsyncReadExt;

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion monoutils-store/lib/lib.rs → ipldstore/lib/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `monoutils-store` is a library for working with IPLD content-addressed stores (CAS).
//! `ipldstore` is a library for working with IPLD content-addressed stores (CAS).
#![warn(missing_docs)]
#![allow(clippy::module_inception)]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion monocore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ ipnetwork = { version = "0.21.0", features = ["serde"] }
sqlx.workspace = true
monoutils.workspace = true
regex.workspace = true
monoutils-store.workspace = true
ipldstore.workspace = true
monofs.workspace = true
async-recursion.workspace = true

Expand Down
2 changes: 1 addition & 1 deletion monocore/lib/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use monofs::FsError;
use monoutils::MonoutilsError;
use monoutils_store::{ipld, StoreError};
use ipldstore::{ipld, StoreError};
use nix::errno::Errno;
use sqlx::migrate::MigrateError;
use std::{
Expand Down
2 changes: 1 addition & 1 deletion monocore/lib/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ mod error;
pub mod cli;
pub mod config;
pub mod management;
pub mod monoimage;
pub mod oci;
pub mod runtime;
pub mod utils;
pub mod vm;
pub mod monoimage;

pub use error::*;
15 changes: 7 additions & 8 deletions monocore/lib/management/image.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use crate::management::db::{self, OCI_DB_MIGRATOR};
use crate::management::rootfs;
use crate::utils::BLOCKS_SUBDIR;
use crate::utils::{env::get_monocore_home_path, path::OCI_DB_FILENAME};
use crate::{
management::{
db::{self, OCI_DB_MIGRATOR},
rootfs,
},
oci::{DockerRegistry, OciRegistryPull, Reference},
utils::{env::get_monocore_home_path, path::OCI_DB_FILENAME, BLOCKS_SUBDIR},
MonocoreError, MonocoreResult,
};
use futures::future;
use monofs::filesystem::Dir;
use monofs::store::FlatFsStore;
use monoutils_store::ipld::cid::Cid;
use monoutils_store::{IpldStore, Storable};
use ipldstore::{ipld::cid::Cid, IpldStore, Storable};
use monofs::{filesystem::Dir, store::FlatFsStore};
use sqlx::SqlitePool;
use std::path::{Path, PathBuf};
use tempfile::tempdir;
Expand Down
10 changes: 5 additions & 5 deletions monocore/lib/management/rootfs.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use async_recursion::async_recursion;
use chrono::{TimeZone, Utc};
use ipldstore::ipld::ipld::Ipld;
use ipldstore::{ipld::cid::Cid, IpldStore};
use monofs::filesystem::{
Dir, Entity, File, Metadata, SymPathLink, UNIX_ATIME_KEY, UNIX_GID_KEY, UNIX_MODE_KEY,
UNIX_MTIME_KEY, UNIX_UID_KEY,
};
use monoutils_store::ipld::ipld::Ipld;
use monoutils_store::{ipld::cid::Cid, IpldStore};
use std::fs;
use std::os::unix::fs::{MetadataExt, PermissionsExt};
use std::path::Path;
Expand Down Expand Up @@ -132,7 +132,7 @@ where
///
/// ```ignore
/// use monofs::filesystem::Dir;
/// use monoutils_store::MemoryStore;
/// use ipldstore::MemoryStore;
///
/// # async fn example() -> Result<(), Box<dyn std::error::Error>> {
/// let store = MemoryStore::default();
Expand Down Expand Up @@ -363,7 +363,7 @@ where
#[cfg(test)]
mod tests {
use super::*;
use monoutils_store::MemoryStore;
use ipldstore::MemoryStore;

use helper::*;

Expand Down Expand Up @@ -526,7 +526,7 @@ mod tests {

#[cfg(test)]
mod helper {
use monoutils_store::IpldStoreSeekable;
use ipldstore::IpldStoreSeekable;
use std::{ops::Deref, os::unix::fs::PermissionsExt};
use tokio::io::AsyncReadExt;

Expand Down
5 changes: 1 addition & 4 deletions monocore/lib/monoimage/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ pub struct SandboxesRegistry {

impl SandboxesRegistry {
/// Creates a new Sandboxes Registry client with the specified store directory and database.
pub fn new(
store_dir: PathBuf,
monoimage_db: Pool<Sqlite>,
) -> Self {
pub fn new(store_dir: PathBuf, monoimage_db: Pool<Sqlite>) -> Self {
let retry_policy = ExponentialBackoff::builder().build_with_max_retries(3);
let client_builder = ClientBuilder::new(Client::new());
let client = client_builder
Expand Down
7 changes: 5 additions & 2 deletions monocore/lib/oci/implementations/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ impl OciRegistryPull for DockerRegistry {
}
};

let image_id = management::save_or_update_image(&self.oci_db, &reference, total_size).await?;
let image_id =
management::save_or_update_image(&self.oci_db, &reference, total_size).await?;

// Save index
let platform = Platform::default();
Expand Down Expand Up @@ -335,7 +336,9 @@ impl OciRegistryPull for DockerRegistry {
.zip(config.rootfs().diff_ids())
.map(|(layer_desc, diff_id)| async {
// Check if layer already exists and is complete in database
if management::layer_complete(&self.oci_db, &layer_desc.digest().to_string()).await? {
if management::layer_complete(&self.oci_db, &layer_desc.digest().to_string())
.await?
{
tracing::info!(
"Layer {} already exists and is complete, skipping download",
layer_desc.digest()
Expand Down
Loading

0 comments on commit 289ca4d

Please sign in to comment.