mirror of
https://github.com/aljazceru/crawler_v2.git
synced 2025-12-17 07:24:21 +01:00
moved buffer closer to its usage in Firehose
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user