Skip to content
This repository has been archived by the owner on Sep 21, 2024. It is now read-only.

Commit

Permalink
chore: Resolve PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
cdata committed Sep 12, 2023
1 parent b4b803e commit 21dab6d
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 102 deletions.
9 changes: 4 additions & 5 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ wasm-bindgen-test = { version = "^0.3" }
wasm-bindgen-futures = { version = "^0.4" }
wasm-streams = { version = "0.3.0" }
web-sys = { version = "0.3" }
wnfs-namefilter = { version = "0.1.21" }
# TODO(#626): Migrate off of this crate
wnfs-namefilter = { version = "0.1.23" }

[profile.release]
opt-level = 'z'
Expand Down
2 changes: 1 addition & 1 deletion rust/noosphere-core/src/authority/authorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub enum Authorization {

impl Authorization {
/// Attempt to resolve the [Authorization] as a fully deserialized [Ucan]
/// (if it is not one already.
/// (if it is not one already).
pub async fn as_ucan<S: UcanJwtStore>(&self, store: &S) -> Result<Ucan> {
match self {
Authorization::Ucan(ucan) => Ok(ucan.clone()),
Expand Down
23 changes: 5 additions & 18 deletions rust/noosphere-core/src/context/has.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::{
};
use anyhow::{anyhow, Result};
use async_trait::async_trait;
use noosphere_common::ConditionalSync;
use noosphere_storage::{SphereDb, Storage};
use std::{
ops::{Deref, DerefMut},
Expand All @@ -16,20 +17,6 @@ use crate::context::SphereContextKey;

use super::SphereContext;

#[allow(missing_docs)]
#[cfg(not(target_arch = "wasm32"))]
pub trait HasConditionalSendSync: Send + Sync {}

#[cfg(not(target_arch = "wasm32"))]
impl<S> HasConditionalSendSync for S where S: Send + Sync {}

#[allow(missing_docs)]
#[cfg(target_arch = "wasm32")]
pub trait HasConditionalSendSync {}

#[cfg(target_arch = "wasm32")]
impl<S> HasConditionalSendSync for S {}

/// Any container that can provide non-mutable access to a [SphereContext]
/// should implement [HasSphereContext]. The most common example of something
/// that may implement this trait is an `Arc<SphereContext<_, _>>`. Implementors
Expand All @@ -38,12 +25,12 @@ impl<S> HasConditionalSendSync for S {}
/// content and petnames.
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
pub trait HasSphereContext<S>: Clone + HasConditionalSendSync
pub trait HasSphereContext<S>: Clone + ConditionalSync
where
S: Storage + 'static,
{
/// The type of the internal read-only [SphereContext]
type SphereContext: Deref<Target = SphereContext<S>> + HasConditionalSendSync;
type SphereContext: Deref<Target = SphereContext<S>> + ConditionalSync;

/// Get the [SphereContext] that is made available by this container.
async fn sphere_context(&self) -> Result<Self::SphereContext>;
Expand Down Expand Up @@ -85,14 +72,14 @@ where
/// aspects of a sphere.
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
pub trait HasMutableSphereContext<S>: HasSphereContext<S> + HasConditionalSendSync
pub trait HasMutableSphereContext<S>: HasSphereContext<S> + ConditionalSync
where
S: Storage + 'static,
{
/// The type of the internal mutable [SphereContext]
type MutableSphereContext: Deref<Target = SphereContext<S>>
+ DerefMut<Target = SphereContext<S>>
+ HasConditionalSendSync;
+ ConditionalSync;

/// Get a mutable reference to the [SphereContext] that is wrapped by this
/// container.
Expand Down
2 changes: 1 addition & 1 deletion rust/noosphere-core/src/context/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! These constants represent the metadata keys used when a [SphereContext] is
//! is initialized. Since these represent somewhat free-form key/values in the
//! storage layer, we are make a best effort to document them here.
//! storage layer, we make a best effort to document them here.
#[cfg(doc)]
use crate::context::SphereContext;
Expand Down
2 changes: 1 addition & 1 deletion rust/noosphere-core/src/data/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use super::{Did, IdentitiesIpld, Jwt, Link, MemoIpld};
use crate::data::SphereIpld;

/// The name of the fact (as defined for a [Ucan]) that contains the link for a
/// [LinkRecord]
/// [LinkRecord].
pub const LINK_RECORD_FACT_NAME: &str = "link";

/// A subdomain of a [SphereIpld] that pertains to the management and recording of
Expand Down
11 changes: 5 additions & 6 deletions rust/noosphere-gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,24 @@ readme = "README.md"
tracing = { workspace = true }

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
reqwest = { version = "~0.11", default-features = false, features = ["json", "rustls-tls", "stream"] }
reqwest = { workspace = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
anyhow = { workspace = true }
axum = { workspace = true, features = ["headers", "macros"] }
iroh-car = { workspace = true }
thiserror = { workspace = true }
strum = "0.25"
strum_macros = "0.25"
bytes = "^1"
strum = { workspace = true }
strum_macros = { workspace = true }
bytes = { workspace = true }

tokio = { workspace = true, features = ["full"] }
tokio-stream = { workspace = true }
tower = { workspace = true }
tower-http = { workspace = true, features = ["cors", "trace"] }
async-trait = "~0.1"
async-stream = { workspace = true }
wnfs-namefilter = { version = "0.1.21" }
wnfs-common = "=0.1.23"
wnfs-namefilter = { workspace = true }

url = { workspace = true, features = ["serde"] }
mime_guess = "^2"
Expand Down
1 change: 0 additions & 1 deletion rust/noosphere-gateway/src/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use tower_http::trace::TraceLayer;
use url::Url;

use noosphere_core::api::{v0alpha1, v0alpha2};
// use noosphere_core::api::route::Route as GatewayRoute;

use crate::{
handlers,
Expand Down
12 changes: 0 additions & 12 deletions rust/noosphere-ipfs/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,6 @@ where
}
}

// #[cfg(not(target_arch = "wasm32"))]
// pub trait IpfsStorageConditionalSendSync: Send + Sync {}

// #[cfg(not(target_arch = "wasm32"))]
// impl<S> IpfsStorageConditionalSendSync for S where S: Send + Sync {}

// #[cfg(target_arch = "wasm32")]
// pub trait IpfsStorageConditionalSendSync {}

// #[cfg(target_arch = "wasm32")]
// impl<S> IpfsStorageConditionalSendSync for S {}

#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
impl<S, C> Storage for IpfsStorage<S, C>
Expand Down
3 changes: 2 additions & 1 deletion rust/noosphere-sphere/src/petname/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! Sphere petnames are shorthand names that are associated with DIDs. A petname
//! can be any string, and always refers to a DID. The DID, in turn, may be
//! resolved to a CID that represents the tip of history for the sphere that is
//! implicitly identified by the provided DID.
//! implicitly identified by the provided DID. Note though that a petname may refer
//! to no CID (`None`) when first added (as no peer may have been resolved yet).
mod read;
mod write;
Expand Down
2 changes: 1 addition & 1 deletion rust/noosphere/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ noosphere-cli = { version = "0.14.1", path = "../noosphere-cli", features = ["he
noosphere-core = { version = "0.15.1", path = "../noosphere-core", features = ["helpers"] }
noosphere-common = { version = "0.1.0", path = "../noosphere-common", features = ["helpers"] }
noosphere-gateway = { version = "0.8.1", path = "../noosphere-gateway" }
noosphere-ns = { version = "0.10.1", path = "../noosphere-ns" }

[target.'cfg(target_arch = "wasm32")'.dependencies]
# TODO: We should eventually support gateway storage as a specialty target only,
Expand All @@ -78,6 +77,7 @@ tokio = { workspace = true, features = ["full"] }
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
tempfile = { workspace = true }
reqwest = { workspace = true }
noosphere-ns = { version = "0.10.1", path = "../noosphere-ns" }

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test = { workspace = true }
Expand Down
54 changes: 0 additions & 54 deletions rust/noosphere/tests/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,60 +390,6 @@ async fn gateway_receives_sphere_revisions_from_a_client() -> Result<()> {
Ok(())
}

// #[tokio::test]
// async fn all_of_client_history_is_made_manifest_on_the_gateway_after_sync() -> Result<()> {
// initialize_tracing(None);

// let mut sphere_pair = SpherePair::new(
// "one",
// &Url::parse("http://127.0.0.1:5001")?,
// &Url::parse("http://127.0.0.1:6667")?,
// )
// .await?;

// sphere_pair.start_gateway().await?;

// let final_client_version = sphere_pair
// .spawn(move |mut client_sphere_context| async move {
// for value in ["one", "two", "three"] {
// client_sphere_context
// .write(value, &ContentType::Text, value.as_bytes(), None)
// .await?;
// client_sphere_context.save(None).await?;
// }

// client_sphere_context.sync(SyncRecovery::None).await?;

// for value in ["one", "two", "three"] {
// client_sphere_context
// .set_petname(value, Some(Did(format!("did:key:{}", value))))
// .await?;
// client_sphere_context.save(None).await?;
// }

// client_sphere_context.sync(SyncRecovery::None).await?;

// wait(1).await;

// Ok(client_sphere_context.sync(SyncRecovery::None).await?)
// })
// .await?;

// // Stream all of the blocks of client history as represented in gateway's storage
// let block_stream = memo_history_stream(
// sphere_pair.gateway.workspace.db().await?,
// &final_client_version,
// None,
// true,
// );

// tokio::pin!(block_stream);

// while let Some(_) = block_stream.try_next().await? {}

// Ok(())
// }

#[tokio::test]
async fn gateway_can_sync_an_authorized_sphere_across_multiple_replicas() -> Result<()> {
initialize_tracing(None);
Expand Down

0 comments on commit 21dab6d

Please sign in to comment.