@@ -12,11 +12,12 @@ use clap::{Parser, Subcommand};
1212use iroh:: {
1313 base:: { hash:: Hash , key:: SecretKey } ,
1414 net:: { discovery:: local_swarm_discovery:: LocalSwarmDiscovery , key:: PublicKey , NodeAddr } ,
15- node:: DiscoveryConfig ,
1615} ;
1716use iroh_blobs:: {
1817 net_protocol:: Blobs , rpc:: client:: blobs:: WrapOption , util:: local_pool:: LocalPool ,
1918} ;
19+ use iroh_net:: { Endpoint , RelayMode } ;
20+ use iroh_router:: Router ;
2021use tracing_subscriber:: { prelude:: * , EnvFilter } ;
2122
2223use self :: progress:: show_download_progress;
@@ -64,19 +65,19 @@ async fn main() -> anyhow::Result<()> {
6465
6566 let key = SecretKey :: generate ( ) ;
6667 let discovery = LocalSwarmDiscovery :: new ( key. public ( ) ) ?;
67- let cfg = DiscoveryConfig :: Custom ( Box :: new ( discovery) ) ;
6868
6969 println ! ( "Starting iroh node with local node discovery..." ) ;
7070 // create a new node
71- let mut builder = iroh :: node :: Node :: memory ( )
71+ let endpoint = Endpoint :: builder ( )
7272 . secret_key ( key)
73- . node_discovery ( cfg )
74- . relay_mode ( iroh_net :: RelayMode :: Disabled )
75- . build ( )
73+ . discovery ( Box :: new ( discovery ) )
74+ . relay_mode ( RelayMode :: Disabled )
75+ . bind ( )
7676 . await ?;
77+ let builder = Router :: builder ( endpoint) ;
7778 let local_pool = LocalPool :: default ( ) ;
7879 let blobs = Blobs :: memory ( ) . build ( local_pool. handle ( ) , builder. endpoint ( ) ) ;
79- builder = builder. accept ( iroh_blobs:: ALPN . to_vec ( ) , blobs. clone ( ) ) ;
80+ let builder = builder. accept ( iroh_blobs:: ALPN , blobs. clone ( ) ) ;
8081 let node = builder. spawn ( ) . await ?;
8182 let blobs_client = blobs. client ( ) ;
8283
@@ -98,13 +99,13 @@ async fn main() -> anyhow::Result<()> {
9899 )
99100 . await ?;
100101 let outcome = stream. finish ( ) . await ?;
101- println ! ( "To fetch the blob:\n \t cargo run --example local_swarm_discovery --features=\" local-swarm-discovery\" -- connect {} {} -o [FILE_PATH]" , node. node_id( ) , outcome. hash) ;
102+ println ! ( "To fetch the blob:\n \t cargo run --example local_swarm_discovery --features=\" local-swarm-discovery\" -- connect {} {} -o [FILE_PATH]" , node. endpoint ( ) . node_id( ) , outcome. hash) ;
102103 tokio:: signal:: ctrl_c ( ) . await ?;
103104 node. shutdown ( ) . await ?;
104105 std:: process:: exit ( 0 ) ;
105106 }
106107 Commands :: Connect { node_id, hash, out } => {
107- println ! ( "NodeID: {}" , node. node_id( ) ) ;
108+ println ! ( "NodeID: {}" , node. endpoint ( ) . node_id( ) ) ;
108109 let mut stream = blobs_client
109110 . download ( * hash, NodeAddr :: new ( * node_id) )
110111 . await ?;
0 commit comments