@@ -8,7 +8,9 @@ use std::{
88
99use anyhow:: { Context , Result } ;
1010use futures_lite:: FutureExt ;
11- use iroh:: { Endpoint , NodeAddr , NodeId , PublicKey } ;
11+ use iroh:: {
12+ discovery:: static_provider:: StaticProvider , Endpoint , EndpointAddr , EndpointId , PublicKey ,
13+ } ;
1214use 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 {
6766pub 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
903902impl 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