diff --git a/Cargo.lock b/Cargo.lock index 8fb2f0ec7a..d767585b3a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2314,12 +2314,12 @@ dependencies = [ "indicatif", "iroh", "iroh-base", - "iroh-bytes", + "iroh-blobs", + "iroh-docs", "iroh-gossip", "iroh-io", "iroh-metrics", "iroh-net", - "iroh-sync", "iroh-test", "num_cpus", "parking_lot", @@ -2389,7 +2389,7 @@ dependencies = [ ] [[package]] -name = "iroh-bytes" +name = "iroh-blobs" version = "0.15.0" dependencies = [ "anyhow", @@ -2406,7 +2406,7 @@ dependencies = [ "hex", "http-body 0.4.6", "iroh-base", - "iroh-bytes", + "iroh-blobs", "iroh-io", "iroh-metrics", "iroh-net", @@ -2536,6 +2536,44 @@ dependencies = [ "z32", ] +[[package]] +name = "iroh-docs" +version = "0.15.0" +dependencies = [ + "anyhow", + "bytes", + "derive_more", + "ed25519-dalek", + "flume", + "futures-util", + "hex", + "iroh-base", + "iroh-blake3", + "iroh-metrics", + "iroh-net", + "iroh-test", + "lru", + "num_enum", + "postcard", + "proptest", + "quinn", + "rand", + "rand_chacha", + "rand_core", + "redb 1.5.1", + "redb 2.1.0", + "self_cell", + "serde", + "strum 0.25.0", + "tempfile", + "test-strategy", + "thiserror", + "tokio", + "tokio-stream", + "tokio-util", + "tracing", +] + [[package]] name = "iroh-gossip" version = "0.15.0" @@ -2700,44 +2738,6 @@ dependencies = [ "tracing-subscriber", ] -[[package]] -name = "iroh-sync" -version = "0.15.0" -dependencies = [ - "anyhow", - "bytes", - "derive_more", - "ed25519-dalek", - "flume", - "futures-util", - "hex", - "iroh-base", - "iroh-blake3", - "iroh-metrics", - "iroh-net", - "iroh-test", - "lru", - "num_enum", - "postcard", - "proptest", - "quinn", - "rand", - "rand_chacha", - "rand_core", - "redb 1.5.1", - "redb 2.1.0", - "self_cell", - "serde", - "strum 0.25.0", - "tempfile", - "test-strategy", - "thiserror", - "tokio", - "tokio-stream", - "tokio-util", - "tracing", -] - [[package]] name = "iroh-test" version = "0.15.0" diff --git a/Cargo.toml b/Cargo.toml index 27fd38f393..a6099c70fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ members = [ "iroh-gossip", "iroh-metrics", "iroh-net", - "iroh-sync", + "iroh-docs", "iroh-test", "iroh-net/bench", "iroh-cli" diff --git a/iroh-sync/Cargo.toml b/iroh-docs/Cargo.toml similarity index 99% rename from iroh-sync/Cargo.toml rename to iroh-docs/Cargo.toml index 01279cf3e2..aa9b9839f8 100644 --- a/iroh-sync/Cargo.toml +++ b/iroh-docs/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "iroh-sync" +name = "iroh-docs" version = "0.15.0" edition = "2021" readme = "README.md" diff --git a/iroh-sync/LICENSE-APACHE b/iroh-docs/LICENSE-APACHE similarity index 100% rename from iroh-sync/LICENSE-APACHE rename to iroh-docs/LICENSE-APACHE diff --git a/iroh-sync/LICENSE-MIT b/iroh-docs/LICENSE-MIT similarity index 100% rename from iroh-sync/LICENSE-MIT rename to iroh-docs/LICENSE-MIT diff --git a/iroh-sync/README.md b/iroh-docs/README.md similarity index 99% rename from iroh-sync/README.md rename to iroh-docs/README.md index 4e63a49f10..8867860605 100644 --- a/iroh-sync/README.md +++ b/iroh-docs/README.md @@ -1,4 +1,4 @@ -# iroh-sync +# iroh-docs Multi-dimensional key-value documents with an efficient synchronization protocol. diff --git a/iroh-sync/proptest-regressions/ranger.txt b/iroh-docs/proptest-regressions/ranger.txt similarity index 100% rename from iroh-sync/proptest-regressions/ranger.txt rename to iroh-docs/proptest-regressions/ranger.txt diff --git a/iroh-sync/src/actor.rs b/iroh-docs/src/actor.rs similarity index 99% rename from iroh-sync/src/actor.rs rename to iroh-docs/src/actor.rs index 7a4f7c9960..bbe91181cb 100644 --- a/iroh-sync/src/actor.rs +++ b/iroh-docs/src/actor.rs @@ -543,7 +543,7 @@ impl SyncHandle { self.tx .send_async(action) .await - .context("sending to iroh_sync actor failed")?; + .context("sending to iroh_docs actor failed")?; Ok(()) } async fn send_replica(&self, namespace: NamespaceId, action: ReplicaAction) -> Result<()> { diff --git a/iroh-sync/src/heads.rs b/iroh-docs/src/heads.rs similarity index 100% rename from iroh-sync/src/heads.rs rename to iroh-docs/src/heads.rs diff --git a/iroh-sync/src/keys.rs b/iroh-docs/src/keys.rs similarity index 99% rename from iroh-sync/src/keys.rs rename to iroh-docs/src/keys.rs index 622f28ede5..9efbeee560 100644 --- a/iroh-sync/src/keys.rs +++ b/iroh-docs/src/keys.rs @@ -1,4 +1,4 @@ -//! Keys used in iroh-sync +//! Keys used in iroh-docs use std::{cmp::Ordering, fmt, str::FromStr}; diff --git a/iroh-sync/src/lib.rs b/iroh-docs/src/lib.rs similarity index 100% rename from iroh-sync/src/lib.rs rename to iroh-docs/src/lib.rs diff --git a/iroh-sync/src/metrics.rs b/iroh-docs/src/metrics.rs similarity index 95% rename from iroh-sync/src/metrics.rs rename to iroh-docs/src/metrics.rs index f7c6c1b9f8..90d562495c 100644 --- a/iroh-sync/src/metrics.rs +++ b/iroh-docs/src/metrics.rs @@ -1,11 +1,11 @@ -//! Metrics for iroh-sync +//! Metrics for iroh-docs use iroh_metrics::{ core::{Counter, Metric}, struct_iterable::Iterable, }; -/// Metrics for iroh-sync +/// Metrics for iroh-docs #[allow(missing_docs)] #[derive(Debug, Clone, Iterable)] pub struct Metrics { @@ -36,6 +36,6 @@ impl Default for Metrics { impl Metric for Metrics { fn name() -> &'static str { - "iroh_sync" + "iroh_docs" } } diff --git a/iroh-sync/src/net.rs b/iroh-docs/src/net.rs similarity index 97% rename from iroh-sync/src/net.rs rename to iroh-docs/src/net.rs index 30bcfe8c82..aff9046548 100644 --- a/iroh-sync/src/net.rs +++ b/iroh-docs/src/net.rs @@ -1,4 +1,4 @@ -//! Network implementation of the iroh-sync protocol +//! Network implementation of the iroh-docs protocol use std::{ future::Future, @@ -20,8 +20,8 @@ use crate::metrics::Metrics; #[cfg(feature = "metrics")] use iroh_metrics::inc; -/// The ALPN identifier for the iroh-sync protocol -pub const SYNC_ALPN: &[u8] = b"/iroh-sync/1"; +/// The ALPN identifier for the iroh-docs protocol +pub const DOCS_ALPN: &[u8] = b"/iroh-sync/1"; mod codec; @@ -36,7 +36,7 @@ pub async fn connect_and_sync( let peer_id = peer.node_id; trace!("connect"); let connection = endpoint - .connect(peer, SYNC_ALPN) + .connect(peer, DOCS_ALPN) .await .map_err(ConnectError::connect)?; @@ -103,7 +103,7 @@ pub enum AcceptOutcome { Reject(AbortReason), } -/// Handle an iroh-sync connection and sync all shared documents in the replica store. +/// Handle an iroh-docs connection and sync all shared documents in the replica store. pub async fn handle_connection( sync: SyncHandle, connecting: quinn::Connecting, diff --git a/iroh-sync/src/net/codec.rs b/iroh-docs/src/net/codec.rs similarity index 100% rename from iroh-sync/src/net/codec.rs rename to iroh-docs/src/net/codec.rs diff --git a/iroh-sync/src/ranger.rs b/iroh-docs/src/ranger.rs similarity index 100% rename from iroh-sync/src/ranger.rs rename to iroh-docs/src/ranger.rs diff --git a/iroh-sync/src/store.rs b/iroh-docs/src/store.rs similarity index 99% rename from iroh-sync/src/store.rs rename to iroh-docs/src/store.rs index 488d45657e..3f137be371 100644 --- a/iroh-sync/src/store.rs +++ b/iroh-docs/src/store.rs @@ -1,4 +1,4 @@ -//! Storage trait and implementation for iroh-sync documents +//! Storage trait and implementation for iroh-docs documents use std::num::NonZeroUsize; use anyhow::Result; diff --git a/iroh-sync/src/store/fs.rs b/iroh-docs/src/store/fs.rs similarity index 100% rename from iroh-sync/src/store/fs.rs rename to iroh-docs/src/store/fs.rs diff --git a/iroh-sync/src/store/fs/bounds.rs b/iroh-docs/src/store/fs/bounds.rs similarity index 100% rename from iroh-sync/src/store/fs/bounds.rs rename to iroh-docs/src/store/fs/bounds.rs diff --git a/iroh-sync/src/store/fs/migrate_v1_v2.rs b/iroh-docs/src/store/fs/migrate_v1_v2.rs similarity index 100% rename from iroh-sync/src/store/fs/migrate_v1_v2.rs rename to iroh-docs/src/store/fs/migrate_v1_v2.rs diff --git a/iroh-sync/src/store/fs/migrations.rs b/iroh-docs/src/store/fs/migrations.rs similarity index 100% rename from iroh-sync/src/store/fs/migrations.rs rename to iroh-docs/src/store/fs/migrations.rs diff --git a/iroh-sync/src/store/fs/query.rs b/iroh-docs/src/store/fs/query.rs similarity index 100% rename from iroh-sync/src/store/fs/query.rs rename to iroh-docs/src/store/fs/query.rs diff --git a/iroh-sync/src/store/fs/ranges.rs b/iroh-docs/src/store/fs/ranges.rs similarity index 100% rename from iroh-sync/src/store/fs/ranges.rs rename to iroh-docs/src/store/fs/ranges.rs diff --git a/iroh-sync/src/store/fs/tables.rs b/iroh-docs/src/store/fs/tables.rs similarity index 100% rename from iroh-sync/src/store/fs/tables.rs rename to iroh-docs/src/store/fs/tables.rs diff --git a/iroh-sync/src/store/pubkeys.rs b/iroh-docs/src/store/pubkeys.rs similarity index 100% rename from iroh-sync/src/store/pubkeys.rs rename to iroh-docs/src/store/pubkeys.rs diff --git a/iroh-sync/src/store/util.rs b/iroh-docs/src/store/util.rs similarity index 100% rename from iroh-sync/src/store/util.rs rename to iroh-docs/src/store/util.rs diff --git a/iroh-sync/src/sync.rs b/iroh-docs/src/sync.rs similarity index 99% rename from iroh-sync/src/sync.rs rename to iroh-docs/src/sync.rs index c2cd2e0ed6..5d3896f4bc 100644 --- a/iroh-sync/src/sync.rs +++ b/iroh-docs/src/sync.rs @@ -1,4 +1,4 @@ -//! API for iroh-sync replicas +//! API for iroh-docs replicas // Names and concepts are roughly based on Willows design at the moment: // @@ -37,7 +37,7 @@ use crate::{ pub type ProtocolMessage = crate::ranger::Message; /// Byte representation of a `PeerId` from `iroh-net`. -// TODO: PeerId is in iroh-net which iroh-sync doesn't depend on. Add iroh-base crate with `PeerId`. +// TODO: PeerId is in iroh-net which iroh-docs doesn't depend on. Add iroh-base crate with `PeerId`. pub type PeerIdBytes = [u8; 32]; /// Max time in the future from our wall clock time that we accept entries for. diff --git a/iroh-sync/src/ticket.rs b/iroh-docs/src/ticket.rs similarity index 98% rename from iroh-sync/src/ticket.rs rename to iroh-docs/src/ticket.rs index b9cdad2c7c..b54c2e4592 100644 --- a/iroh-sync/src/ticket.rs +++ b/iroh-docs/src/ticket.rs @@ -1,4 +1,4 @@ -//! Tickets for [`iroh-sync`] documents. +//! Tickets for [`iroh-docs`] documents. use iroh_base::ticket; use iroh_net::NodeAddr; diff --git a/iroh-gossip/Cargo.toml b/iroh-gossip/Cargo.toml index 8cb0ef47f3..97d55de4a8 100644 --- a/iroh-gossip/Cargo.toml +++ b/iroh-gossip/Cargo.toml @@ -6,7 +6,7 @@ readme = "README.md" description = "gossip messages over broadcast trees" license = "MIT/Apache-2.0" authors = ["n0 team"] -repository = "https://github.com/n0-computer/iroh-sync" +repository = "https://github.com/n0-computer/iroh" # Sadly this also needs to be updated in .github/workflows/ci.yml rust-version = "1.75" diff --git a/iroh/Cargo.toml b/iroh/Cargo.toml index 4298a6b3d3..22120e707f 100644 --- a/iroh/Cargo.toml +++ b/iroh/Cargo.toml @@ -33,7 +33,7 @@ iroh-metrics = { version = "0.15.0", path = "../iroh-metrics", optional = true } iroh-net = { version = "0.15.0", path = "../iroh-net" } num_cpus = { version = "1.15.0" } portable-atomic = "1" -iroh-sync = { version = "0.15.0", path = "../iroh-sync" } +iroh-docs = { version = "0.15.0", path = "../iroh-docs" } iroh-gossip = { version = "0.15.0", path = "../iroh-gossip" } parking_lot = "0.12.1" postcard = { version = "1", default-features = false, features = ["alloc", "use-std", "experimental-derive"] } diff --git a/iroh/src/client/authors.rs b/iroh/src/client/authors.rs index 8d0b5b69a2..690ae228da 100644 --- a/iroh/src/client/authors.rs +++ b/iroh/src/client/authors.rs @@ -2,7 +2,7 @@ use anyhow::Result; use futures_lite::{stream::StreamExt, Stream}; -use iroh_sync::{Author, AuthorId}; +use iroh_docs::{Author, AuthorId}; use quic_rpc::{RpcClient, ServiceConnection}; use crate::rpc_protocol::{ diff --git a/iroh/src/client/docs.rs b/iroh/src/client/docs.rs index 077cb9bb23..63d5dfd1d1 100644 --- a/iroh/src/client/docs.rs +++ b/iroh/src/client/docs.rs @@ -13,12 +13,12 @@ use derive_more::{Display, FromStr}; use futures_lite::{Stream, StreamExt}; use iroh_base::{key::PublicKey, node_addr::AddrInfoOptions}; use iroh_blobs::{export::ExportProgress, store::ExportMode, Hash}; -use iroh_net::NodeAddr; -use iroh_sync::{ +use iroh_docs::{ actor::OpenState, store::{DownloadPolicy, Query}, AuthorId, CapabilityKind, ContentStatus, DocTicket, NamespaceId, PeerIdBytes, RecordIdentifier, }; +use iroh_net::NodeAddr; use portable_atomic::{AtomicBool, Ordering}; use quic_rpc::{message::RpcMsg, RpcClient, ServiceConnection}; use serde::{Deserialize, Serialize}; @@ -395,16 +395,16 @@ impl<'a, C: ServiceConnection> From<&'a Doc> for &'a RpcClient for Entry { - fn from(value: iroh_sync::Entry) -> Self { +impl From for Entry { + fn from(value: iroh_docs::Entry) -> Self { Self(value) } } -impl From for Entry { - fn from(value: iroh_sync::SignedEntry) -> Self { +impl From for Entry { + fn from(value: iroh_docs::SignedEntry) -> Self { Self(value.into()) } } diff --git a/iroh/src/lib.rs b/iroh/src/lib.rs index 5cc186c755..f423d3c562 100644 --- a/iroh/src/lib.rs +++ b/iroh/src/lib.rs @@ -14,9 +14,9 @@ pub use iroh_base as base; #[doc(inline)] pub use iroh_blobs as bytes; #[doc(inline)] -pub use iroh_net as net; +pub use iroh_docs as sync; #[doc(inline)] -pub use iroh_sync as sync; +pub use iroh_net as net; pub mod client; pub mod node; diff --git a/iroh/src/metrics.rs b/iroh/src/metrics.rs index 0fba864ef3..25e94b8cb1 100644 --- a/iroh/src/metrics.rs +++ b/iroh/src/metrics.rs @@ -38,7 +38,7 @@ impl Metric for Metrics { pub fn try_init_metrics_collection() -> std::io::Result<()> { iroh_metrics::core::Core::try_init(|reg, metrics| { metrics.insert(crate::metrics::Metrics::new(reg)); - metrics.insert(iroh_sync::metrics::Metrics::new(reg)); + metrics.insert(iroh_docs::metrics::Metrics::new(reg)); metrics.insert(iroh_net::metrics::MagicsockMetrics::new(reg)); metrics.insert(iroh_net::metrics::NetcheckMetrics::new(reg)); metrics.insert(iroh_net::metrics::PortmapMetrics::new(reg)); @@ -54,7 +54,7 @@ pub fn get_metrics() -> anyhow::Result> { let core = iroh_metrics::core::Core::get().ok_or_else(|| anyhow::anyhow!("metrics are disabled"))?; collect( - core.get_collector::(), + core.get_collector::(), &mut map, ); collect( diff --git a/iroh/src/node/builder.rs b/iroh/src/node/builder.rs index 4807b20143..2d59a5353b 100644 --- a/iroh/src/node/builder.rs +++ b/iroh/src/node/builder.rs @@ -14,6 +14,7 @@ use iroh_blobs::{ protocol::Closed, store::{GcMarkEvent, GcSweepEvent, Map, Store as BaoStore}, }; +use iroh_docs::net::SYNC_ALPN; use iroh_gossip::net::{Gossip, GOSSIP_ALPN}; use iroh_net::{ discovery::{dns::DnsDiscovery, pkarr_publish::PkarrPublisher, ConcurrentDiscovery, Discovery}, @@ -22,7 +23,6 @@ use iroh_net::{ relay::RelayMode, MagicEndpoint, }; -use iroh_sync::net::SYNC_ALPN; use quic_rpc::{ transport::{misc::DummyServerEndpoint, quinn::QuinnServerEndpoint}, RpcServer, ServiceEndpoint, @@ -62,7 +62,7 @@ const MAX_STREAMS: u64 = 10; /// You must supply a blob store and a document store. /// /// Blob store implementations are available in [`iroh_blobs::store`]. -/// Document store implementations are available in [`iroh_sync::store`]. +/// Document store implementations are available in [`iroh_docs::store`]. /// /// Everything else is optional. /// @@ -86,7 +86,7 @@ where gc_policy: GcPolicy, dns_resolver: Option, node_discovery: DiscoveryConfig, - docs_store: iroh_sync::store::fs::Store, + docs_store: iroh_docs::store::fs::Store, #[cfg(any(test, feature = "test-utils"))] insecure_skip_relay_cert_verify: bool, } @@ -132,7 +132,7 @@ impl Default for Builder { dns_resolver: None, rpc_endpoint: Default::default(), gc_policy: GcPolicy::Disabled, - docs_store: iroh_sync::store::Store::memory(), + docs_store: iroh_docs::store::Store::memory(), node_discovery: Default::default(), #[cfg(any(test, feature = "test-utils"))] insecure_skip_relay_cert_verify: false, @@ -144,7 +144,7 @@ impl Builder { /// Creates a new builder for [`Node`] using the given databases. pub fn with_db_and_store( blobs_store: D, - docs_store: iroh_sync::store::Store, + docs_store: iroh_docs::store::Store, storage: StorageConfig, ) -> Self { Self { @@ -183,7 +183,7 @@ where .await .with_context(|| format!("Failed to load iroh database from {}", blob_dir.display()))?; let docs_store = - iroh_sync::store::fs::Store::persistent(IrohPaths::DocsDatabase.with_root(root))?; + iroh_docs::store::fs::Store::persistent(IrohPaths::DocsDatabase.with_root(root))?; let v0 = blobs_store .import_flat_store(iroh_blobs::store::fs::FlatStorePaths { @@ -608,7 +608,7 @@ where async fn gc_loop( db: D, - ds: iroh_sync::actor::SyncHandle, + ds: iroh_docs::actor::SyncHandle, gc_period: Duration, callbacks: Callbacks, ) { diff --git a/iroh/src/rpc_protocol.rs b/iroh/src/rpc_protocol.rs index 1bd04d9ec3..e035b7d3f0 100644 --- a/iroh/src/rpc_protocol.rs +++ b/iroh/src/rpc_protocol.rs @@ -24,7 +24,7 @@ use iroh_net::{ NodeId, }; -use iroh_sync::{ +use iroh_docs::{ actor::OpenState, store::{DownloadPolicy, Query}, Author, AuthorId, CapabilityKind, DocTicket, Entry, NamespaceId, PeerIdBytes, SignedEntry, diff --git a/iroh/src/sync_engine.rs b/iroh/src/sync_engine.rs index 12192054f7..13e5a222ad 100644 --- a/iroh/src/sync_engine.rs +++ b/iroh/src/sync_engine.rs @@ -1,6 +1,6 @@ -//! Handlers and actors to for live syncing [`iroh_sync`] replicas. +//! Handlers and actors to for live syncing [`iroh_docs`] replicas. //! -//! [`iroh_sync::Replica`] is also called documents here. +//! [`iroh_docs::Replica`] is also called documents here. use std::{io, sync::Arc}; @@ -8,10 +8,10 @@ use anyhow::Result; use futures_lite::{Stream, StreamExt}; use iroh_blobs::downloader::Downloader; use iroh_blobs::{store::EntryStatus, Hash}; +use iroh_docs::{actor::SyncHandle, ContentStatus, ContentStatusCallback, Entry, NamespaceId}; use iroh_gossip::net::Gossip; use iroh_net::util::SharedAbortingJoinHandle; use iroh_net::{key::PublicKey, MagicEndpoint, NodeAddr}; -use iroh_sync::{actor::SyncHandle, ContentStatus, ContentStatusCallback, Entry, NamespaceId}; use serde::{Deserialize, Serialize}; use tokio::sync::{mpsc, oneshot}; use tracing::{error, error_span, Instrument}; @@ -52,11 +52,11 @@ impl SyncEngine { /// Start the sync engine. /// /// This will spawn two tokio tasks for the live sync coordination and gossip actors, and a - /// thread for the [`iroh_sync::actor::SyncHandle`]. + /// thread for the [`iroh_docs::actor::SyncHandle`]. pub(crate) fn spawn( endpoint: MagicEndpoint, gossip: Gossip, - replica_store: iroh_sync::store::Store, + replica_store: iroh_docs::store::Store, bao_store: B, downloader: Downloader, ) -> Self { @@ -175,7 +175,7 @@ impl SyncEngine { Ok(a.or(b)) } - /// Handle an incoming iroh-sync connection. + /// Handle an incoming iroh-docs connection. pub(super) async fn handle_connection(&self, conn: quinn::Connecting) -> anyhow::Result<()> { self.to_live_actor .send(ToLiveActor::HandleConnection { conn }) @@ -244,14 +244,14 @@ impl From for LiveEvent { impl LiveEvent { fn from_replica_event( - ev: iroh_sync::Event, + ev: iroh_docs::Event, content_status_cb: &ContentStatusCallback, ) -> Result { Ok(match ev { - iroh_sync::Event::LocalInsert { entry, .. } => Self::InsertLocal { + iroh_docs::Event::LocalInsert { entry, .. } => Self::InsertLocal { entry: entry.into(), }, - iroh_sync::Event::RemoteInsert { entry, from, .. } => Self::InsertRemote { + iroh_docs::Event::RemoteInsert { entry, from, .. } => Self::InsertRemote { content_status: content_status_cb(entry.content_hash()), entry: entry.into(), from: PublicKey::from_bytes(&from)?, diff --git a/iroh/src/sync_engine/gossip.rs b/iroh/src/sync_engine/gossip.rs index 4771353151..9c9050d856 100644 --- a/iroh/src/sync_engine/gossip.rs +++ b/iroh/src/sync_engine/gossip.rs @@ -2,12 +2,12 @@ use std::collections::HashSet; use anyhow::{anyhow, Context, Result}; use futures_lite::StreamExt; +use iroh_docs::{actor::SyncHandle, ContentStatus, NamespaceId}; use iroh_gossip::{ net::{Event, Gossip}, proto::TopicId, }; use iroh_net::key::PublicKey; -use iroh_sync::{actor::SyncHandle, ContentStatus, NamespaceId}; use tokio::{ sync::{broadcast::error::RecvError, mpsc}, task::JoinSet, diff --git a/iroh/src/sync_engine/live.rs b/iroh/src/sync_engine/live.rs index d54993b8d4..0299ec03a5 100644 --- a/iroh/src/sync_engine/live.rs +++ b/iroh/src/sync_engine/live.rs @@ -9,10 +9,7 @@ use iroh_blobs::downloader::{DownloadError, DownloadRequest, Downloader}; use iroh_blobs::get::Stats; use iroh_blobs::HashAndFormat; use iroh_blobs::{store::EntryStatus, Hash}; -use iroh_gossip::{net::Gossip, proto::TopicId}; -use iroh_net::NodeId; -use iroh_net::{key::PublicKey, MagicEndpoint, NodeAddr}; -use iroh_sync::{ +use iroh_docs::{ actor::{OpenOpts, SyncHandle}, net::{ connect_and_sync, handle_connection, AbortReason, AcceptError, AcceptOutcome, ConnectError, @@ -20,6 +17,9 @@ use iroh_sync::{ }, AuthorHeads, ContentStatus, NamespaceId, SignedEntry, }; +use iroh_gossip::{net::Gossip, proto::TopicId}; +use iroh_net::NodeId; +use iroh_net::{key::PublicKey, MagicEndpoint, NodeAddr}; use serde::{Deserialize, Serialize}; use tokio::{ sync::{self, mpsc, oneshot}, @@ -30,7 +30,7 @@ use tracing::{debug, error, error_span, info, instrument, trace, warn, Instrumen use super::gossip::{GossipActor, ToGossipActor}; use super::state::{NamespaceStates, Origin, SyncReason}; -/// An iroh-sync operation +/// An iroh-docs operation /// /// This is the message that is broadcast over iroh-gossip. #[derive(Debug, Clone, Serialize, Deserialize, strum::Display)] @@ -137,8 +137,8 @@ pub struct LiveActor { gossip: Gossip, bao_store: B, downloader: Downloader, - replica_events_tx: flume::Sender, - replica_events_rx: flume::Receiver, + replica_events_tx: flume::Sender, + replica_events_rx: flume::Receiver, /// Send messages to self. /// Note: Must not be used in methods called from `Self::run` directly to prevent deadlocks. @@ -654,9 +654,9 @@ impl LiveActor { } } - async fn on_replica_event(&mut self, event: iroh_sync::Event) -> Result<()> { + async fn on_replica_event(&mut self, event: iroh_docs::Event) -> Result<()> { match event { - iroh_sync::Event::LocalInsert { namespace, entry } => { + iroh_docs::Event::LocalInsert { namespace, entry } => { let topic = TopicId::from_bytes(*namespace.as_bytes()); // A new entry was inserted locally. Broadcast a gossip message. if self.state.is_syncing(&namespace) { @@ -665,7 +665,7 @@ impl LiveActor { self.gossip.broadcast(topic, message).await?; } } - iroh_sync::Event::RemoteInsert { + iroh_docs::Event::RemoteInsert { namespace, entry, from, diff --git a/iroh/src/sync_engine/rpc.rs b/iroh/src/sync_engine/rpc.rs index 280029e4c9..845c55442c 100644 --- a/iroh/src/sync_engine/rpc.rs +++ b/iroh/src/sync_engine/rpc.rs @@ -3,7 +3,7 @@ use anyhow::anyhow; use futures_lite::Stream; use iroh_blobs::{store::Store as BaoStore, BlobFormat}; -use iroh_sync::{Author, DocTicket, NamespaceSecret}; +use iroh_docs::{Author, DocTicket, NamespaceSecret}; use tokio_stream::StreamExt; use crate::client::docs::ShareMode; @@ -137,10 +137,10 @@ impl SyncEngine { me.apply_options(addr_options); let capability = match mode { - ShareMode::Read => iroh_sync::Capability::Read(doc_id), + ShareMode::Read => iroh_docs::Capability::Read(doc_id), ShareMode::Write => { let secret = self.sync.export_secret_key(doc_id).await?; - iroh_sync::Capability::Write(secret) + iroh_docs::Capability::Write(secret) } }; self.start_sync(doc_id, vec![]).await?; diff --git a/iroh/src/sync_engine/state.rs b/iroh/src/sync_engine/state.rs index eac00026df..7bab017e05 100644 --- a/iroh/src/sync_engine/state.rs +++ b/iroh/src/sync_engine/state.rs @@ -1,9 +1,9 @@ use anyhow::Result; -use iroh_net::NodeId; -use iroh_sync::{ +use iroh_docs::{ net::{AbortReason, AcceptOutcome, SyncFinished}, NamespaceId, }; +use iroh_net::NodeId; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; use std::time::{Instant, SystemTime}; diff --git a/iroh/src/util/path.rs b/iroh/src/util/path.rs index 9da1821091..0240e11de5 100644 --- a/iroh/src/util/path.rs +++ b/iroh/src/util/path.rs @@ -12,7 +12,7 @@ pub enum IrohPaths { /// Path to the node's [file based blob store](iroh_blobs::store::fs::Store). #[strum(serialize = "blobs")] BaoStoreDir, - /// Path to the [iroh-sync document database](iroh_sync::store::fs::Store) + /// Path to the [iroh-docs document database](iroh_docs::store::fs::Store) #[strum(serialize = "docs.redb")] DocsDatabase, /// Path to the console state diff --git a/iroh/tests/gc.rs b/iroh/tests/gc.rs index dd9602c019..e0899fb2fb 100644 --- a/iroh/tests/gc.rs +++ b/iroh/tests/gc.rs @@ -42,7 +42,7 @@ async fn wrap_in_node(bao_store: S, gc_period: Duration) -> Node where S: iroh_blobs::store::Store, { - let doc_store = iroh_sync::store::Store::memory(); + let doc_store = iroh_docs::store::Store::memory(); node::Builder::with_db_and_store(bao_store, doc_store, iroh::node::StorageConfig::Mem) .gc_policy(iroh::node::GcPolicy::Interval(gc_period)) .spawn() diff --git a/iroh/tests/provide.rs b/iroh/tests/provide.rs index c9a0b12bee..dbeebfc789 100644 --- a/iroh/tests/provide.rs +++ b/iroh/tests/provide.rs @@ -41,7 +41,7 @@ async fn dial(secret_key: SecretKey, peer: NodeAddr) -> anyhow::Result(db: D) -> Builder { - let store = iroh_sync::store::Store::memory(); + let store = iroh_docs::store::Store::memory(); iroh::node::Builder::with_db_and_store(db, store, iroh::node::StorageConfig::Mem).bind_port(0) } diff --git a/iroh/tests/sync.rs b/iroh/tests/sync.rs index 1ab139e2e3..74f3a8880a 100644 --- a/iroh/tests/sync.rs +++ b/iroh/tests/sync.rs @@ -24,11 +24,11 @@ use tracing::{debug, error_span, info, Instrument}; use tracing_subscriber::{prelude::*, EnvFilter}; use iroh_blobs::Hash; -use iroh_net::relay::RelayMode; -use iroh_sync::{ +use iroh_docs::{ store::{DownloadPolicy, FilterKind, Query}, AuthorId, ContentStatus, }; +use iroh_net::relay::RelayMode; const TIMEOUT: Duration = Duration::from_secs(60);