upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/sync/relay_connection.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-01-21 13:46:55 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-01-21 13:46:55 +0000
commit6c3c93752e9ee8da7f16fbeda70f9eb7a0ca8eb0 (patch)
tree2fc223a12691c62954316542fc29ee4df466d1fe /src/sync/relay_connection.rs
parent5913c5aab4d22fcb2984e9a34b439190639b346d (diff)
parent214fa5cbb7dacedfb3227e623e0542351c7d7956 (diff)
Fix negentropy fallback to REQ+EOSE when retry fails
Diffstat (limited to 'src/sync/relay_connection.rs')
-rw-r--r--src/sync/relay_connection.rs21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/sync/relay_connection.rs b/src/sync/relay_connection.rs
index 99fc4ea..5bc0fa3 100644
--- a/src/sync/relay_connection.rs
+++ b/src/sync/relay_connection.rs
@@ -282,9 +282,7 @@ impl RelayConnection {
282 || msg.contains("negentropy"); 282 || msg.contains("negentropy");
283 283
284 if is_negentropy_notice { 284 if is_negentropy_notice {
285 // Mark relay as not supporting NIP-77 285 self.mark_negentropy_unsupported();
286 self.nip77_supported
287 .store(2, std::sync::atomic::Ordering::Relaxed);
288 286
289 tracing::info!( 287 tracing::info!(
290 relay = %url, 288 relay = %url,
@@ -478,6 +476,19 @@ impl RelayConnection {
478 true 476 true
479 } 477 }
480 478
479 /// Mark this relay as not supporting NIP-77 negentropy
480 ///
481 /// Called when we detect negentropy isn't working for this relay:
482 /// - NOTICE message contains negentropy-related error
483 /// - negentropy_sync_diff() fails
484 /// - Negentropy retry returns zero events
485 ///
486 /// Future batches will skip negentropy and use REQ+EOSE directly.
487 pub fn mark_negentropy_unsupported(&self) {
488 self.nip77_supported
489 .store(2, std::sync::atomic::Ordering::Relaxed);
490 }
491
481 /// Perform a negentropy sync diff (dry run) to identify missing events 492 /// Perform a negentropy sync diff (dry run) to identify missing events
482 /// 493 ///
483 /// This method performs NIP-77 negentropy reconciliation without downloading events. 494 /// This method performs NIP-77 negentropy reconciliation without downloading events.
@@ -564,9 +575,7 @@ impl RelayConnection {
564 Ok(reconciliation) 575 Ok(reconciliation)
565 } 576 }
566 Err(e) => { 577 Err(e) => {
567 // Mark relay as not supporting NIP-77 578 self.mark_negentropy_unsupported();
568 self.nip77_supported
569 .store(2, std::sync::atomic::Ordering::Relaxed);
570 579
571 // Log warning only once per relay to avoid spam 580 // Log warning only once per relay to avoid spam
572 if !self 581 if !self