@@ -21,7 +21,7 @@ use handler::{
2121 IdentityChainEventHandler , IdentityChainEventProcessor , LoggingEventHandler ,
2222 NostrContactProcessor , NotificationHandlerApi ,
2323} ;
24- use log:: { debug, error} ;
24+ use log:: { debug, error, warn } ;
2525pub use nostr_transport:: NostrTransportService ;
2626
2727mod block_transport;
@@ -54,6 +54,7 @@ pub async fn create_nostr_clients(
5454 config : & Config ,
5555 identity_store : Arc < dyn IdentityStoreApi > ,
5656 company_store : Arc < dyn CompanyStoreApi > ,
57+ nostr_contact_store : Arc < dyn bcr_ebill_persistence:: nostr:: NostrContactStoreApi > ,
5758) -> Result < Arc < NostrClient > > {
5859 // primary identity is required to launch
5960 let keys = identity_store. get_or_create_key_pair ( ) . await . map_err ( |e| {
@@ -101,9 +102,17 @@ pub async fn create_nostr_clients(
101102 identities,
102103 config. nostr_config . relays . clone ( ) ,
103104 std:: time:: Duration :: from_secs ( 20 ) ,
105+ config. nostr_config . max_relays ,
106+ Some ( nostr_contact_store) ,
104107 )
105108 . await ?;
106109
110+ // Initial relay refresh to include contact relays
111+ if let Err ( e) = client. refresh_relays ( ) . await {
112+ warn ! ( "Failed initial relay refresh: {}" , e) ;
113+ // Continue anyway - we have user relays at minimum
114+ }
115+
107116 Ok ( Arc :: new ( client) )
108117}
109118
@@ -121,6 +130,7 @@ pub async fn create_transport_service(
121130 transport. clone ( ) ,
122131 db_context. nostr_contact_store . clone ( ) ,
123132 get_config ( ) . bitcoin_network ( ) ,
133+ Some ( client. clone ( ) ) ,
124134 ) ) ;
125135 let bill_processor = Arc :: new ( BillChainEventProcessor :: new (
126136 db_context. bill_blockchain_store . clone ( ) ,
@@ -214,6 +224,7 @@ pub async fn create_nostr_consumer(
214224 transport. clone ( ) ,
215225 db_context. nostr_contact_store . clone ( ) ,
216226 get_config ( ) . bitcoin_network ( ) ,
227+ Some ( client. clone ( ) ) ,
217228 ) ) ;
218229
219230 let bill_processor = Arc :: new ( BillChainEventProcessor :: new (
@@ -329,6 +340,7 @@ pub async fn create_restore_account_service(
329340 nostr_client. clone ( ) ,
330341 db_context. nostr_contact_store . clone ( ) ,
331342 config. bitcoin_network ( ) ,
343+ Some ( nostr_client. clone ( ) ) ,
332344 ) ) ;
333345
334346 let bill_processor = Arc :: new ( BillChainEventProcessor :: new (
0 commit comments