Repository navigation
Add NIP-77 (Negentropy) sync support - #144
Merged
Merged
Conversation
Implement server-side handling for NEG-OPEN, NEG-MSG and NEG-CLOSE so clients can reconcile event sets with the relay without redownloading events they already have. Each session keeps per-subscription negentropy state on the WebSocket, snapshots events matching the filter into a sealed vector storage, and drives Reconcile per incoming frame. Access is gated by the same validateFilterAccess and ReqAccepter checks as REQ, so NIP-42 and NIP-59 restrictions still apply. NEG-* frames are dispatched in receive order rather than on worker goroutines. Negentropy is lock-step and Reconcile carries state between frames, so a worker could apply a NEG-CLOSE before the NEG-OPEN it followed; the close then found no session to remove and the one the open went on to create was never freed. The error envelope is written by hand as NEG-ERR. go-nostr's nip77.ErrorEnvelope marshals the label as NEG-ERROR, which the spec does not define; its parser matches on the NEG-ERR prefix, so clients built on go-nostr still decode ours. Reasons use the NIP-01 "word: message" form. A NEG-OPEN for a subscription id that is already open closes the existing session first, on the error paths too. Advertise NIP-77 in the default NIP-11 document.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements server-side handling for
NEG-OPEN,NEG-MSG, andNEG-CLOSEso clients can reconcile event sets with the relay without redownloading events they already have. Each session keeps per-subscription negentropy state on theWebSocket, snapshots events matching the filter into a sealed vector storage, and drivesReconcileper incoming frame. Access is gated by the samevalidateFilterAccessandReqAccepterchecks asREQ, so NIP-42 and NIP-59 restrictions still apply. NIP-77 is also advertised in the default NIP-11 document.