From 0ca44c7e206868c22cc344138fc3edcab89af6bd Mon Sep 17 00:00:00 2001 From: Jay Date: Fri, 22 May 2026 11:32:55 -0400 Subject: [PATCH] Drop WithCreatedAtTime, WithSinceTime, WithUntilTime; nil Tags on NewEvent --- AGENTS.md | 4 ++++ events/event.go | 12 ++---------- events/event_test.go | 2 +- filters/filter.go | 15 --------------- 4 files changed, 7 insertions(+), 26 deletions(-) create mode 100644 AGENTS.md diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..434487a --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,4 @@ +# go-roots + +## Testing +- `go test ./...` diff --git a/events/event.go b/events/event.go index be9bd3b..a32115c 100644 --- a/events/event.go +++ b/events/event.go @@ -3,9 +3,7 @@ // serialization, cryptographic signatures, and subscription filters. package events -import ( - "time" -) + // Tag represents a single tag within an event as an array of strings. // The first element identifies the tag name, the second contains the value, @@ -26,7 +24,7 @@ type Event struct { } func NewEvent(opts ...EventOption) Event { - e := Event{Tags: make([]Tag, 0)} + e := Event{} for _, opt := range opts { opt(&e) } @@ -53,12 +51,6 @@ func WithCreatedAt(t int64) EventOption { } } -func WithCreatedAtTime(t time.Time) EventOption { - return func(e *Event) { - e.CreatedAt = t.Unix() - } -} - func WithKind(k int) EventOption { return func(e *Event) { e.Kind = k diff --git a/events/event_test.go b/events/event_test.go index 71a77df..2225c56 100644 --- a/events/event_test.go +++ b/events/event_test.go @@ -17,7 +17,7 @@ var testEvent = NewEvent( WithSig("83b71e15649c9e9da362c175f988c36404cabf357a976d869102a74451cfb8af486f6088b5631033b4927bd46cad7a0d90d7f624aefc0ac260364aa65c36071a"), ) -var testEventJSON = `{"id":"c7a702e6158744ca03508bbb4c90f9dbb0d6e88fefbfaa511d5ab24b4e3c48ad","pubkey":"cfa87f35acbde29ba1ab3ee42de527b2cad33ac487e80cf2d6405ea0042c8fef","created_at":1760740551,"kind":1,"tags":[],"content":"hello world","sig":"83b71e15649c9e9da362c175f988c36404cabf357a976d869102a74451cfb8af486f6088b5631033b4927bd46cad7a0d90d7f624aefc0ac260364aa65c36071a"}` +var testEventJSON = `{"id":"c7a702e6158744ca03508bbb4c90f9dbb0d6e88fefbfaa511d5ab24b4e3c48ad","pubkey":"cfa87f35acbde29ba1ab3ee42de527b2cad33ac487e80cf2d6405ea0042c8fef","created_at":1760740551,"kind":1,"tags":null,"content":"hello world","sig":"83b71e15649c9e9da362c175f988c36404cabf357a976d869102a74451cfb8af486f6088b5631033b4927bd46cad7a0d90d7f624aefc0ac260364aa65c36071a"}` var testEventJSONBytes = []byte(testEventJSON) func expectEqualEvents(t *testing.T, got, want Event) { diff --git a/filters/filter.go b/filters/filter.go index f41b482..1cfe4dd 100644 --- a/filters/filter.go +++ b/filters/filter.go @@ -4,7 +4,6 @@ import ( "encoding/json" "git.wisehodl.dev/jay/go-roots/events" "strings" - "time" ) // TagFilters maps tag names to arrays of values for tag-based filtering @@ -70,20 +69,6 @@ func WithUntil(until int64) FilterOption { } } -func WithUntilTime(until time.Time) FilterOption { - return func(f *Filter) { - untilInt := until.Unix() - f.Until = &untilInt - } -} - -func WithSinceTime(since time.Time) FilterOption { - return func(f *Filter) { - sinceInt := since.Unix() - f.Since = &sinceInt - } -} - func WithLimit(limit int) FilterOption { return func(f *Filter) { ptr := limit