Skip to content

Commit

Permalink
nip77 nostr-negentropy syncing basics.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Sep 12, 2024
1 parent 775a89a commit 076e8a1
Show file tree
Hide file tree
Showing 5 changed files with 199 additions and 324 deletions.
12 changes: 6 additions & 6 deletions envelopes.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ type Envelope interface {
String() string
}

type EventEnvelope struct {
SubscriptionID *string
Event
}

var (
_ Envelope = (*EventEnvelope)(nil)
_ Envelope = (*ReqEnvelope)(nil)
Expand All @@ -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 {
Expand All @@ -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()
}
Expand Down
Loading

0 comments on commit 076e8a1

Please sign in to comment.