moved buffer closer to its usage in Firehose

This commit is contained in:
pippellia-btc
2025-09-19 15:56:07 +02:00
parent 7d8907984d
commit 1de9a84ba3
2 changed files with 22 additions and 23 deletions

View File

@@ -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)
}