@@ -4,14 +4,14 @@ use std::{
44} ;
55
66use anyhow:: { Context , Result } ;
7- pub use iroh:: NodeId ;
8- use iroh:: { PublicKey , SecretKey , protocol:: Router } ;
9- use iroh_base:: { Signature , ticket:: Ticket } ;
7+ pub use iroh:: EndpointId ;
8+ use iroh:: { PublicKey , SecretKey , Signature , protocol:: Router } ;
109pub use iroh_gossip:: proto:: TopicId ;
1110use iroh_gossip:: {
1211 api:: { Event as GossipEvent , GossipSender } ,
1312 net:: { GOSSIP_ALPN , Gossip } ,
1413} ;
14+ use iroh_tickets:: Ticket ;
1515use n0_future:: {
1616 StreamExt ,
1717 boxed:: BoxStream ,
@@ -28,7 +28,7 @@ pub const PRESENCE_INTERVAL: Duration = Duration::from_secs(5);
2828#[ derive( Serialize , Deserialize , Clone , Debug ) ]
2929pub struct ChatTicket {
3030 pub topic_id : TopicId ,
31- pub bootstrap : BTreeSet < NodeId > ,
31+ pub bootstrap : BTreeSet < EndpointId > ,
3232}
3333
3434impl ChatTicket {
@@ -58,7 +58,7 @@ impl Ticket for ChatTicket {
5858 postcard:: to_stdvec ( & self ) . unwrap ( )
5959 }
6060
61- fn from_bytes ( bytes : & [ u8 ] ) -> Result < Self , iroh_base :: ticket :: ParseError > {
61+ fn from_bytes ( bytes : & [ u8 ] ) -> Result < Self , iroh_tickets :: ParseError > {
6262 let ticket = postcard:: from_bytes ( bytes) ?;
6363 Ok ( ticket)
6464 }
@@ -76,14 +76,13 @@ impl ChatNode {
7676 let secret_key = secret_key. unwrap_or_else ( || SecretKey :: generate ( & mut rand:: rng ( ) ) ) ;
7777 let endpoint = iroh:: Endpoint :: builder ( )
7878 . secret_key ( secret_key. clone ( ) )
79- . discovery_n0 ( )
8079 . alpns ( vec ! [ GOSSIP_ALPN . to_vec( ) ] )
8180 . bind ( )
8281 . await ?;
8382
84- let node_id = endpoint. node_id ( ) ;
83+ let endpoint_id = endpoint. id ( ) ;
8584 info ! ( "endpoint bound" ) ;
86- info ! ( "node id: {node_id :#?}" ) ;
85+ info ! ( "endpoint id: {endpoint_id :#?}" ) ;
8786
8887 let gossip = Gossip :: builder ( ) . spawn ( endpoint. clone ( ) ) ;
8988 info ! ( "gossip spawned" ) ;
@@ -98,9 +97,9 @@ impl ChatNode {
9897 } )
9998 }
10099
101- /// Returns the node id of this node .
102- pub fn node_id ( & self ) -> NodeId {
103- self . router . endpoint ( ) . node_id ( )
100+ /// Returns the endpoint id of this endpoint .
101+ pub fn endpoint_id ( & self ) -> EndpointId {
102+ self . router . endpoint ( ) . id ( )
104103 }
105104
106105 /// Joins a chat channel from a ticket.
@@ -239,28 +238,28 @@ impl ChatSender {
239238pub enum Event {
240239 #[ serde( rename_all = "camelCase" ) ]
241240 Joined {
242- neighbors : Vec < NodeId > ,
241+ neighbors : Vec < EndpointId > ,
243242 } ,
244243 #[ serde( rename_all = "camelCase" ) ]
245244 MessageReceived {
246- from : NodeId ,
245+ from : EndpointId ,
247246 text : String ,
248247 nickname : String ,
249248 sent_timestamp : u64 ,
250249 } ,
251250 #[ serde( rename_all = "camelCase" ) ]
252251 Presence {
253- from : NodeId ,
252+ from : EndpointId ,
254253 nickname : String ,
255254 sent_timestamp : u64 ,
256255 } ,
257256 #[ serde( rename_all = "camelCase" ) ]
258257 NeighborUp {
259- node_id : NodeId ,
258+ endpoint_id : EndpointId ,
260259 } ,
261260 #[ serde( rename_all = "camelCase" ) ]
262261 NeighborDown {
263- node_id : NodeId ,
262+ endpoint_id : EndpointId ,
264263 } ,
265264 Lagged ,
266265}
@@ -269,8 +268,8 @@ impl TryFrom<GossipEvent> for Event {
269268 type Error = anyhow:: Error ;
270269 fn try_from ( event : GossipEvent ) -> Result < Self , Self :: Error > {
271270 let converted = match event {
272- GossipEvent :: NeighborUp ( node_id ) => Self :: NeighborUp { node_id } ,
273- GossipEvent :: NeighborDown ( node_id ) => Self :: NeighborDown { node_id } ,
271+ GossipEvent :: NeighborUp ( endpoint_id ) => Self :: NeighborUp { endpoint_id } ,
272+ GossipEvent :: NeighborDown ( endpoint_id ) => Self :: NeighborDown { endpoint_id } ,
274273 GossipEvent :: Received ( message) => {
275274 let message = SignedMessage :: verify_and_decode ( & message. content )
276275 . context ( "failed to parse and verify signed message" ) ?;
@@ -348,6 +347,6 @@ pub enum Message {
348347#[ derive( Debug , Serialize , Deserialize ) ]
349348pub struct ReceivedMessage {
350349 timestamp : u64 ,
351- from : NodeId ,
350+ from : EndpointId ,
352351 message : Message ,
353352}
0 commit comments