@@ -14,7 +14,7 @@ use nostr::prelude::*;
1414use nostr_database:: prelude:: * ;
1515use nostr_gossip:: { BestRelaySelection , GossipListKind , GossipPublicKeyStatus , NostrGossip } ;
1616use nostr_relay_pool:: prelude:: * ;
17- use tokio:: sync:: { broadcast, Semaphore } ;
17+ use tokio:: sync:: broadcast;
1818
1919pub mod builder;
2020mod error;
@@ -35,8 +35,6 @@ pub struct Client {
3535 pool : RelayPool ,
3636 gossip : Option < GossipWrapper > ,
3737 opts : ClientOptions ,
38- /// Semaphore used to limit the number of gossip checks and syncs
39- gossip_sync : Arc < Semaphore > ,
4038}
4139
4240impl Default for Client {
@@ -104,8 +102,6 @@ impl Client {
104102 pool : pool_builder. build ( ) ,
105103 gossip : builder. gossip . map ( GossipWrapper :: new) ,
106104 opts : builder. opts ,
107- // Allow only one gossip check and sync at a time
108- gossip_sync : Arc :: new ( Semaphore :: new ( 1 ) ) ,
109105 }
110106 }
111107
@@ -1371,37 +1367,19 @@ impl Client {
13711367 {
13721368 let public_keys: HashSet < PublicKey > = public_keys. into_iter ( ) . collect ( ) ;
13731369
1374- // First check: check if there are outdated public keys.
1375- let outdated_public_keys_first_check : HashSet < PublicKey > = self
1370+ // Check if there are outdated public keys.
1371+ let outdated_public_keys : HashSet < PublicKey > = self
13761372 . check_outdated_public_keys ( gossip, public_keys. iter ( ) , gossip_kind)
13771373 . await ?;
13781374
13791375 // No outdated public keys, immediately return.
1380- if outdated_public_keys_first_check . is_empty ( ) {
1376+ if outdated_public_keys . is_empty ( ) {
13811377 tracing:: debug!( kind = ?gossip_kind, "Gossip data is up to date." ) ;
13821378 return Ok ( ( ) ) ;
13831379 }
13841380
13851381 let sync_id: u64 = gossip. next_sync_id ( ) ;
13861382
1387- tracing:: debug!( sync_id, "Acquiring gossip sync permit..." ) ;
1388-
1389- let _permit = self . gossip_sync . acquire ( ) . await ;
1390-
1391- tracing:: debug!( sync_id, kind = ?gossip_kind, "Acquired gossip sync permit. Start syncing..." ) ;
1392-
1393- // Second check: check data is still outdated after acquiring permit
1394- // (another process might have updated it while we were waiting)
1395- let outdated_public_keys: HashSet < PublicKey > = self
1396- . check_outdated_public_keys ( gossip, public_keys. iter ( ) , gossip_kind)
1397- . await ?;
1398-
1399- // Double-check: data might have been updated while waiting for permit
1400- if outdated_public_keys. is_empty ( ) {
1401- tracing:: debug!( sync_id = %sync_id, kind = ?gossip_kind, "Gossip sync skipped: data updated by another process while acquiring permits." ) ;
1402- return Ok ( ( ) ) ;
1403- }
1404-
14051383 // Negentropy sync and database check
14061384 let ( output, stored_events) = self
14071385 . check_and_update_gossip_sync (
0 commit comments