@@ -17,18 +17,21 @@ pub struct NostrContactProcessor {
1717 transport : Arc < dyn TransportClientApi > ,
1818 nostr_contact_store : Arc < dyn NostrContactStoreApi > ,
1919 bitcoin_network : bitcoin:: Network ,
20+ nostr_client : Option < Arc < crate :: nostr:: NostrClient > > ,
2021}
2122
2223impl NostrContactProcessor {
2324 pub fn new (
2425 transport : Arc < dyn TransportClientApi > ,
2526 nostr_contact_store : Arc < dyn NostrContactStoreApi > ,
2627 bitcoin_network : bitcoin:: Network ,
28+ nostr_client : Option < Arc < crate :: nostr:: NostrClient > > ,
2729 ) -> Self {
2830 Self {
2931 transport,
3032 nostr_contact_store,
3133 bitcoin_network,
34+ nostr_client,
3235 }
3336 }
3437}
@@ -73,8 +76,17 @@ impl NostrContactProcessor {
7376 async fn upsert_contact ( & self , node_id : & NodeId , contact : & NostrContact ) {
7477 if let Err ( e) = self . nostr_contact_store . upsert ( contact) . await {
7578 error ! ( "Failed to save nostr contact information for node_id {node_id}: {e}" ) ;
76- } else if let Err ( e) = self . transport . add_contact_subscription ( node_id) . await {
77- error ! ( "Failed to add nostr contact subscription for contact node_id {node_id}: {e}" ) ;
79+ } else {
80+ if let Err ( e) = self . transport . add_contact_subscription ( node_id) . await {
81+ error ! ( "Failed to add nostr contact subscription for contact node_id {node_id}: {e}" ) ;
82+ }
83+
84+ // Trigger relay refresh to include new contact's relays
85+ if let Some ( ref client) = self . nostr_client {
86+ if let Err ( e) = client. refresh_relays ( ) . await {
87+ warn ! ( "Failed to refresh relays after contact update for {node_id}: {e}" ) ;
88+ }
89+ }
7890 }
7991 }
8092}
0 commit comments