negentropy.

- a way to handle custom messages from Relay (NEG-whatever etc)
- negentropy implementation (adapted from that other one)
- nip77 nostr negentropy extension
- QueryEvents method for RelayStore that returns a channel (makes negentropy syncing work more seamlessly)
This commit is contained in:
fiatjaf
2024-09-14 01:03:19 -03:00
parent b5633b97c3
commit a094f3a9d2
14 changed files with 1358 additions and 59 deletions

View File

@ -58,11 +58,6 @@ type Envelope interface {
String() string
}
type EventEnvelope struct {
SubscriptionID *string
Event
}
var (
_ Envelope = (*EventEnvelope)(nil)
_ Envelope = (*ReqEnvelope)(nil)
@ -74,6 +69,11 @@ var (
_ Envelope = (*AuthEnvelope)(nil)
)
type EventEnvelope struct {
SubscriptionID *string
Event
}
func (_ EventEnvelope) Label() string { return "EVENT" }
func (v *EventEnvelope) UnmarshalJSON(data []byte) error {
@ -96,7 +96,7 @@ func (v EventEnvelope) MarshalJSON() ([]byte, error) {
if v.SubscriptionID != nil {
w.RawString(`"` + *v.SubscriptionID + `",`)
}
v.MarshalEasyJSON(&w)
v.Event.MarshalEasyJSON(&w)
w.RawString(`]`)
return w.BuildBytes()
}