-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
40 lines (33 loc) · 1.21 KB
/
main.go
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 main
import (
"encoding/json"
"log"
"github.com/fiatjaf/relayer"
"github.com/nbd-wtf/go-nostr"
)
type DoNothingStore struct{}
// Implement relayer's Storage interface
func (d *DoNothingStore) Init() error { return nil }
func (d *DoNothingStore) DeleteEvent(id string, pubkey string) error { return nil }
func (d *DoNothingStore) SaveEvent(event *nostr.Event) error { return nil }
func (d *DoNothingStore) QueryEvents(filter *nostr.Filter) ([]nostr.Event, error) {
return []nostr.Event{}, nil
}
type Relay struct{}
// Implement relays's Relay interface
func (r *Relay) Name() string { return "ForwardOnlyRelay" }
func (r *Relay) Storage() relayer.Storage { return &DoNothingStore{} }
func (r *Relay) OnInitialized(*relayer.Server) {}
func (r *Relay) Init() error { return nil }
func (r *Relay) BeforeSave(evt *nostr.Event) {}
func (r *Relay) AfterSave(evt *nostr.Event) {}
func (r *Relay) AcceptEvent(evt *nostr.Event) bool {
// block events that are too large
jsonb, _ := json.Marshal(evt)
return len(jsonb) <= 10000
}
func main() {
if err := relayer.Start(&Relay{}); err != nil {
log.Fatalf("server terminated: %v", err)
}
}