diff --git a/pkg/pipe/firehose.go b/pkg/pipe/firehose.go index 1b5d995..5e17c1b 100644 --- a/pkg/pipe/firehose.go +++ b/pkg/pipe/firehose.go @@ -203,3 +203,25 @@ func Firehose( } } } + +type buffer struct { + IDs []string + capacity int + write int +} + +func newBuffer(capacity int) *buffer { + return &buffer{ + IDs: make([]string, capacity), + capacity: capacity, + } +} + +func (b *buffer) Add(ID string) { + b.IDs[b.write] = ID + b.write = (b.write + 1) % b.capacity +} + +func (b *buffer) Contains(ID string) bool { + return slices.Contains(b.IDs, ID) +} diff --git a/pkg/pipe/utils.go b/pkg/pipe/utils.go index 386f662..3a2bad3 100644 --- a/pkg/pipe/utils.go +++ b/pkg/pipe/utils.go @@ -7,7 +7,6 @@ import ( "log" "os" "os/signal" - "slices" "syscall" "github.com/nbd-wtf/go-nostr" @@ -73,25 +72,3 @@ func shutdown(pool *nostr.SimplePool) { return true }) } - -type buffer struct { - IDs []string - capacity int - write int -} - -func newBuffer(capacity int) *buffer { - return &buffer{ - IDs: make([]string, capacity), - capacity: capacity, - } -} - -func (b *buffer) Add(ID string) { - b.IDs[b.write] = ID - b.write = (b.write + 1) % b.capacity -} - -func (b *buffer) Contains(ID string) bool { - return slices.Contains(b.IDs, ID) -}