mirror of
https://github.com/fiatjaf/nak.git
synced 2024-11-22 08:19:06 -05:00
use easyjson and envelopes.
This commit is contained in:
parent
f2f9dda33a
commit
d9d36e7619
4
event.go
4
event.go
|
@ -142,7 +142,7 @@ example:
|
||||||
kindWasSupplied := false
|
kindWasSupplied := false
|
||||||
mustRehashAndResign := false
|
mustRehashAndResign := false
|
||||||
if stdinEvent != "" {
|
if stdinEvent != "" {
|
||||||
if err := json.Unmarshal([]byte(stdinEvent), &evt); err != nil {
|
if err := easyjson.Unmarshal([]byte(stdinEvent), &evt); err != nil {
|
||||||
lineProcessingError(c, "invalid event received from stdin: %s", err)
|
lineProcessingError(c, "invalid event received from stdin: %s", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,7 @@ example:
|
||||||
} else {
|
} else {
|
||||||
var result string
|
var result string
|
||||||
if c.Bool("envelope") {
|
if c.Bool("envelope") {
|
||||||
j, _ := json.Marshal([]any{"EVENT", evt})
|
j, _ := json.Marshal(nostr.EventEnvelope{Event: evt})
|
||||||
result = string(j)
|
result = string(j)
|
||||||
} else if c.Bool("nson") {
|
} else if c.Bool("nson") {
|
||||||
result, _ = nson.Marshal(&evt)
|
result, _ = nson.Marshal(&evt)
|
||||||
|
|
5
req.go
5
req.go
|
@ -6,6 +6,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/mailru/easyjson"
|
||||||
"github.com/nbd-wtf/go-nostr"
|
"github.com/nbd-wtf/go-nostr"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
@ -113,7 +114,7 @@ example:
|
||||||
for stdinFilter := range getStdinLinesOrBlank() {
|
for stdinFilter := range getStdinLinesOrBlank() {
|
||||||
filter := nostr.Filter{}
|
filter := nostr.Filter{}
|
||||||
if stdinFilter != "" {
|
if stdinFilter != "" {
|
||||||
if err := json.Unmarshal([]byte(stdinFilter), &filter); err != nil {
|
if err := easyjson.Unmarshal([]byte(stdinFilter), &filter); err != nil {
|
||||||
lineProcessingError(c, "invalid filter '%s' received from stdin: %s", stdinFilter, err)
|
lineProcessingError(c, "invalid filter '%s' received from stdin: %s", stdinFilter, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -184,7 +185,7 @@ example:
|
||||||
if c.Bool("bare") {
|
if c.Bool("bare") {
|
||||||
result = filter.String()
|
result = filter.String()
|
||||||
} else {
|
} else {
|
||||||
j, _ := json.Marshal([]any{"REQ", "nak", filter})
|
j, _ := json.Marshal(nostr.ReqEnvelope{SubscriptionID: "nak", Filters: nostr.Filters{filter}})
|
||||||
result = string(j)
|
result = string(j)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user