Skip to content

Commit f1b53df

Browse files
authored
chore: release prep (#73)
## Description upgrade to latest iroh, iroh-ticket, iroh-blobs, `iroh-gossip`, `irpc`, `nested_enum_utils` and `n0-future`
1 parent b257606 commit f1b53df

File tree

15 files changed

+392
-805
lines changed

15 files changed

+392
-805
lines changed

Cargo.lock

Lines changed: 271 additions & 689 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ futures-buffered = "0.2.4"
3131
futures-lite = "2.3.0"
3232
futures-util = { version = "0.3.25" }
3333
hex = "0.4"
34-
iroh = { version = "0.93" }
35-
iroh-base = { version = "0.93", features = ["ticket"] }
36-
iroh-blobs = { version = "0.95" }
37-
iroh-gossip = { version = "0.93", features = ["net"] }
34+
iroh = { version = "0.94" }
35+
iroh-tickets = { version = "0.1"}
36+
iroh-blobs = { version = "0.96" }
37+
iroh-gossip = { version = "0.94", features = ["net"] }
3838
iroh-metrics = { version = "0.36", default-features = false }
39-
irpc = { version = "0.9.0" }
40-
n0-future = "0.1.3"
39+
irpc = { version = "0.10.0" }
40+
n0-future = "0.3"
4141
num_enum = "0.7"
4242
postcard = { version = "1", default-features = false, features = [
4343
"alloc",
@@ -60,8 +60,8 @@ tracing = "0.1"
6060

6161
[dev-dependencies]
6262
data-encoding = "2.6.0"
63-
iroh = { version = "0.93", features = ["test-utils"] }
64-
nested_enum_utils = "0.1.0"
63+
iroh = { version = "0.94", features = ["test-utils"] }
64+
nested_enum_utils = "0.2"
6565
parking_lot = "0.12.3"
6666
proptest = "1.2.0"
6767
rand_chacha = "0.9"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use iroh_gossip::{net::Gossip, ALPN as GOSSIP_ALPN};
5151
async fn main() -> anyhow::Result<()> {
5252
// create an iroh endpoint that includes the standard discovery mechanisms
5353
// we've built at number0
54-
let endpoint = Endpoint::builder().discovery_n0().bind().await?;
54+
let endpoint = Endpoint::builder().bind().await?;
5555

5656
// build the blobs protocol
5757
let blobs = MemStore::default();

examples/setup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use iroh_gossip::{net::Gossip, ALPN as GOSSIP_ALPN};
77
async fn main() -> anyhow::Result<()> {
88
// create an iroh endpoint that includes the standard discovery mechanisms
99
// we've built at number0
10-
let endpoint = Endpoint::builder().discovery_n0().bind().await?;
10+
let endpoint = Endpoint::builder().bind().await?;
1111

1212
// build the blobs protocol
1313
let blobs = MemStore::default();

src/api.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::{
1616

1717
use anyhow::{Context, Result};
1818
use bytes::Bytes;
19-
use iroh::NodeAddr;
19+
use iroh::EndpointAddr;
2020
use iroh_blobs::{
2121
api::blobs::{AddPathOptions, AddProgressItem, ExportMode, ExportOptions, ExportProgress},
2222
Hash,
@@ -433,7 +433,7 @@ impl Doc {
433433
}
434434

435435
/// Starts to sync this document with a list of peers.
436-
pub async fn start_sync(&self, peers: Vec<NodeAddr>) -> Result<()> {
436+
pub async fn start_sync(&self, peers: Vec<EndpointAddr>) -> Result<()> {
437437
self.ensure_open()?;
438438
self.inner
439439
.rpc(StartSyncRequest {

src/api/actor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ impl RpcActor {
389389
mode,
390390
addr_options,
391391
} = req;
392-
let me = self.endpoint.node_addr();
392+
let me = self.endpoint.addr();
393393
let me = addr_options.apply(&me);
394394

395395
let capability = match mode {

src/api/protocol.rs

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::path::PathBuf;
44

55
use bytes::Bytes;
6-
use iroh::NodeAddr;
6+
use iroh::EndpointAddr;
77
use iroh_blobs::{api::blobs::ExportMode, Hash};
88
use irpc::{
99
channel::{mpsc, oneshot},
@@ -179,7 +179,7 @@ pub struct DelResponse {
179179
#[derive(Debug, Serialize, Deserialize, Clone)]
180180
pub struct StartSyncRequest {
181181
pub doc_id: NamespaceId,
182-
pub peers: Vec<NodeAddr>,
182+
pub peers: Vec<EndpointAddr>,
183183
}
184184

185185
#[derive(Debug, Serialize, Deserialize, Clone)]
@@ -365,7 +365,7 @@ pub enum DocsProtocol {
365365
AuthorDelete(AuthorDeleteRequest),
366366
}
367367

368-
/// Options to configure what is included in a [`iroh::NodeAddr`].
368+
/// Options to configure what is included in a [`iroh::EndpointAddr`].
369369
#[derive(
370370
Copy,
371371
Clone,
@@ -396,32 +396,29 @@ impl AddrInfoOptions {
396396
/// Apply the options to the given address.
397397
pub fn apply(
398398
&self,
399-
iroh::NodeAddr {
400-
node_id,
401-
relay_url,
402-
direct_addresses,
403-
}: &iroh::NodeAddr,
404-
) -> iroh::NodeAddr {
399+
iroh::EndpointAddr { id, addrs }: &iroh::EndpointAddr,
400+
) -> iroh::EndpointAddr {
405401
match self {
406-
Self::Id => iroh::NodeAddr {
407-
node_id: *node_id,
408-
relay_url: None,
409-
direct_addresses: Default::default(),
402+
Self::Id => iroh::EndpointAddr::new(*id),
403+
Self::Relay => iroh::EndpointAddr {
404+
id: *id,
405+
addrs: addrs
406+
.iter()
407+
.filter(|addr| matches!(addr, iroh::TransportAddr::Relay(_)))
408+
.cloned()
409+
.collect(),
410410
},
411-
Self::Relay => iroh::NodeAddr {
412-
node_id: *node_id,
413-
relay_url: relay_url.clone(),
414-
direct_addresses: Default::default(),
411+
Self::Addresses => iroh::EndpointAddr {
412+
id: *id,
413+
addrs: addrs
414+
.iter()
415+
.filter(|addr| matches!(addr, iroh::TransportAddr::Ip(_)))
416+
.cloned()
417+
.collect(),
415418
},
416-
Self::Addresses => iroh::NodeAddr {
417-
node_id: *node_id,
418-
relay_url: None,
419-
direct_addresses: direct_addresses.clone(),
420-
},
421-
Self::RelayAndAddresses => iroh::NodeAddr {
422-
node_id: *node_id,
423-
relay_url: relay_url.clone(),
424-
direct_addresses: direct_addresses.clone(),
419+
Self::RelayAndAddresses => iroh::EndpointAddr {
420+
id: *id,
421+
addrs: addrs.clone(),
425422
},
426423
}
427424
}

src/engine.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::{
1010

1111
use anyhow::{bail, Context, Result};
1212
use futures_lite::{Stream, StreamExt};
13-
use iroh::{Endpoint, NodeAddr, PublicKey};
13+
use iroh::{Endpoint, EndpointAddr, PublicKey};
1414
use iroh_blobs::{
1515
api::{blobs::BlobStatus, downloader::Downloader, Store},
1616
store::fs::options::{ProtectCb, ProtectOutcome},
@@ -75,7 +75,7 @@ impl Engine {
7575
protect_cb: Option<ProtectCallbackHandler>,
7676
) -> anyhow::Result<Self> {
7777
let (live_actor_tx, to_live_actor_recv) = mpsc::channel(ACTOR_CHANNEL_CAP);
78-
let me = endpoint.node_id().fmt_short().to_string();
78+
let me = endpoint.id().fmt_short().to_string();
7979

8080
let content_status_cb: ContentStatusCallback = {
8181
let blobs = bao_store.blobs().clone();
@@ -173,7 +173,7 @@ impl Engine {
173173
///
174174
/// If `peers` is non-empty, it will both do an initial set-reconciliation sync with each peer,
175175
/// and join an iroh-gossip swarm with these peers to receive and broadcast document updates.
176-
pub async fn start_sync(&self, namespace: NamespaceId, peers: Vec<NodeAddr>) -> Result<()> {
176+
pub async fn start_sync(&self, namespace: NamespaceId, peers: Vec<EndpointAddr>) -> Result<()> {
177177
let (reply, reply_rx) = oneshot::channel();
178178
self.to_live_actor
179179
.send(ToLiveActor::StartSync {

src/engine/gossip.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use anyhow::{Context, Result};
44
use bytes::Bytes;
55
use futures_lite::StreamExt;
66
use futures_util::FutureExt;
7-
use iroh::NodeId;
7+
use iroh::EndpointId;
88
use iroh_gossip::{
99
api::{Event, GossipReceiver, GossipSender, JoinOptions},
1010
net::Gossip,
@@ -44,7 +44,7 @@ impl GossipState {
4444
}
4545
}
4646

47-
pub async fn join(&mut self, namespace: NamespaceId, bootstrap: Vec<NodeId>) -> Result<()> {
47+
pub async fn join(&mut self, namespace: NamespaceId, bootstrap: Vec<EndpointId>) -> Result<()> {
4848
match self.active.entry(namespace) {
4949
hash_map::Entry::Occupied(mut entry) => {
5050
if !bootstrap.is_empty() {

src/engine/live.rs

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ use std::{
88

99
use anyhow::{Context, Result};
1010
use futures_lite::FutureExt;
11-
use iroh::{Endpoint, NodeAddr, NodeId, PublicKey};
11+
use iroh::{
12+
discovery::static_provider::StaticProvider, Endpoint, EndpointAddr, EndpointId, PublicKey,
13+
};
1214
use iroh_blobs::{
1315
api::{
1416
blobs::BlobStatus,
@@ -38,9 +40,6 @@ use crate::{
3840
AuthorHeads, ContentStatus, NamespaceId, SignedEntry,
3941
};
4042

41-
/// Name used for logging when new node addresses are added from the docs engine.
42-
const SOURCE_NAME: &str = "docs_engine";
43-
4443
/// An iroh-docs operation
4544
///
4645
/// This is the message that is broadcast over iroh-gossip.
@@ -67,7 +66,7 @@ pub struct SyncReport {
6766
pub enum ToLiveActor {
6867
StartSync {
6968
namespace: NamespaceId,
70-
peers: Vec<NodeAddr>,
69+
peers: Vec<EndpointAddr>,
7170
#[debug("onsehot::Sender")]
7271
reply: sync::oneshot::Sender<anyhow::Result<()>>,
7372
},
@@ -157,6 +156,7 @@ pub struct LiveActor {
157156
endpoint: Endpoint,
158157
bao_store: Store,
159158
downloader: Downloader,
159+
static_provider: StaticProvider,
160160
replica_events_tx: async_channel::Sender<crate::Event>,
161161
replica_events_rx: async_channel::Receiver<crate::Event>,
162162

@@ -201,12 +201,15 @@ impl LiveActor {
201201
) -> Self {
202202
let (replica_events_tx, replica_events_rx) = async_channel::bounded(1024);
203203
let gossip_state = GossipState::new(gossip, sync.clone(), sync_actor_tx.clone());
204+
let static_provider = StaticProvider::new();
205+
endpoint.discovery().add(static_provider.clone());
204206
Self {
205207
inbox,
206208
sync,
207209
replica_events_rx,
208210
replica_events_tx,
209211
endpoint,
212+
static_provider,
210213
gossip: gossip_state,
211214
bao_store,
212215
downloader,
@@ -376,7 +379,7 @@ impl LiveActor {
376379
&endpoint,
377380
&sync,
378381
namespace,
379-
NodeAddr::new(peer),
382+
EndpointAddr::new(peer),
380383
Some(&metrics),
381384
)
382385
.await;
@@ -401,7 +404,11 @@ impl LiveActor {
401404
Ok(())
402405
}
403406

404-
async fn start_sync(&mut self, namespace: NamespaceId, mut peers: Vec<NodeAddr>) -> Result<()> {
407+
async fn start_sync(
408+
&mut self,
409+
namespace: NamespaceId,
410+
mut peers: Vec<EndpointAddr>,
411+
) -> Result<()> {
405412
debug!(?namespace, peers = peers.len(), "start sync");
406413
// update state to allow sync
407414
if !self.state.is_syncing(&namespace) {
@@ -421,7 +428,7 @@ impl LiveActor {
421428
// peers are stored as bytes, don't fail the operation if they can't be
422429
// decoded: simply ignore the peer
423430
match PublicKey::from_bytes(&peer_id_bytes) {
424-
Ok(public_key) => Some(NodeAddr::new(public_key)),
431+
Ok(public_key) => Some(EndpointAddr::new(public_key)),
425432
Err(_signing_error) => {
426433
warn!("potential db corruption: peers per doc can't be decoded");
427434
None
@@ -459,26 +466,18 @@ impl LiveActor {
459466
Ok(())
460467
}
461468

462-
async fn join_peers(&mut self, namespace: NamespaceId, peers: Vec<NodeAddr>) -> Result<()> {
469+
async fn join_peers(&mut self, namespace: NamespaceId, peers: Vec<EndpointAddr>) -> Result<()> {
463470
let mut peer_ids = Vec::new();
464471

465472
// add addresses of peers to our endpoint address book
466473
for peer in peers.into_iter() {
467-
let peer_id = peer.node_id;
474+
let peer_id = peer.id;
468475
// adding a node address without any addressing info fails with an error,
469476
// but we still want to include those peers because node discovery might find addresses for them
470-
if peer.is_empty() {
471-
peer_ids.push(peer_id)
472-
} else {
473-
match self.endpoint.add_node_addr_with_source(peer, SOURCE_NAME) {
474-
Ok(()) => {
475-
peer_ids.push(peer_id);
476-
}
477-
Err(err) => {
478-
warn!(peer = %peer_id.fmt_short(), "failed to add known addrs: {err:?}");
479-
}
480-
}
477+
if !peer.is_empty() {
478+
self.static_provider.add_endpoint_info(peer);
481479
}
480+
peer_ids.push(peer_id);
482481
}
483482

484483
// tell gossip to join
@@ -679,7 +678,7 @@ impl LiveActor {
679678
async fn on_neighbor_content_ready(
680679
&mut self,
681680
namespace: NamespaceId,
682-
node: NodeId,
681+
node: EndpointId,
683682
hash: Hash,
684683
) {
685684
self.start_download(namespace, hash, node, true).await;
@@ -826,7 +825,7 @@ impl LiveActor {
826825
peer: PublicKey,
827826
) -> AcceptOutcome {
828827
self.state
829-
.accept_request(&self.endpoint.node_id(), &namespace, peer)
828+
.accept_request(&self.endpoint.id(), &namespace, peer)
830829
}
831830
}
832831

@@ -898,10 +897,10 @@ struct QueuedHashes {
898897
}
899898

900899
#[derive(Debug, Clone, Default)]
901-
struct ProviderNodes(Arc<std::sync::Mutex<HashMap<Hash, HashSet<NodeId>>>>);
900+
struct ProviderNodes(Arc<std::sync::Mutex<HashMap<Hash, HashSet<EndpointId>>>>);
902901

903902
impl ContentDiscovery for ProviderNodes {
904-
fn find_providers(&self, hash: HashAndFormat) -> n0_future::stream::Boxed<NodeId> {
903+
fn find_providers(&self, hash: HashAndFormat) -> n0_future::stream::Boxed<EndpointId> {
905904
let nodes = self
906905
.0
907906
.lock()

0 commit comments

Comments
 (0)