1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
package grpc
import (
pb "northwest.io/muxstr/api/nostr/v1"
"northwest.io/muxstr/internal/nostr"
)
func NostrToPB(n *nostr.Event) *pb.Event {
tags := make([]*pb.Tag, len(n.Tags))
for i, tag := range n.Tags {
tags[i] = &pb.Tag{Values: tag}
}
return &pb.Event{
Id: n.ID,
Pubkey: n.PubKey,
CreatedAt: n.CreatedAt,
Kind: int32(n.Kind),
Tags: tags,
Content: n.Content,
Sig: n.Sig,
}
}
func PBToNostr(e *pb.Event) *nostr.Event {
tags := make(nostr.Tags, len(e.Tags))
for i, tag := range e.Tags {
tags[i] = tag.Values
}
return &nostr.Event{
ID: e.Id,
PubKey: e.Pubkey,
CreatedAt: e.CreatedAt,
Kind: int(e.Kind),
Tags: tags,
Content: e.Content,
Sig: e.Sig,
}
}
|