Skip to content

Commit 02602ff

Browse files
committed
sdk: remove gossip concurrency limit
Partially reverts a132974 Pull-Request: #1132 Signed-off-by: Yuki Kishimoto <[email protected]>
1 parent 6418672 commit 02602ff

File tree

2 files changed

+8
-26
lines changed

2 files changed

+8
-26
lines changed

crates/nostr-sdk/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929

3030
- Replace `usize` with `u8` for gossip relay limits
3131

32+
### Removed
33+
34+
- Remove gossip concurrency limit (https://github.com/rust-nostr/nostr/pull/1132)
35+
3236
## v0.44.1 - 2025/11/09
3337

3438
### Fixed

crates/nostr-sdk/src/client/mod.rs

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use nostr::prelude::*;
1414
use nostr_database::prelude::*;
1515
use nostr_gossip::{BestRelaySelection, GossipListKind, GossipPublicKeyStatus, NostrGossip};
1616
use nostr_relay_pool::prelude::*;
17-
use tokio::sync::{broadcast, Semaphore};
17+
use tokio::sync::broadcast;
1818

1919
pub mod builder;
2020
mod 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

4240
impl 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

Comments
 (0)