From 758a37750bf27f5c5b89e9dc0168f327ccedaac1 Mon Sep 17 00:00:00 2001 From: pippellia-btc Date: Fri, 19 Sep 2025 15:56:37 +0200 Subject: [PATCH] removed events and pubkey capacities, favoring single channel capacity variable --- cmd/crawl/main.go | 6 +++--- cmd/sync/main.go | 4 ++-- pkg/config/config.go | 13 +++++-------- pkg/pipe/engine.go | 2 +- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/cmd/crawl/main.go b/cmd/crawl/main.go index d8a31fd..86ccc4c 100644 --- a/cmd/crawl/main.go +++ b/cmd/crawl/main.go @@ -50,9 +50,9 @@ func main() { panic(err) } - recorderQueue := make(chan *nostr.Event, config.EventsCapacity) - engineQueue := make(chan *nostr.Event, config.EventsCapacity) - fetcherQueue := make(chan string, config.PubkeysCapacity) + recorderQueue := make(chan *nostr.Event, config.ChannelCapacity) + engineQueue := make(chan *nostr.Event, config.ChannelCapacity) + fetcherQueue := make(chan string, config.ChannelCapacity) nodes, err := db.NodeCount(ctx) if err != nil { diff --git a/cmd/sync/main.go b/cmd/sync/main.go index 612984e..685711f 100644 --- a/cmd/sync/main.go +++ b/cmd/sync/main.go @@ -47,8 +47,8 @@ func main() { panic(err) } - builderQueue := make(chan *nostr.Event, config.EventsCapacity) - fetcherQueue := make(chan string, config.PubkeysCapacity) + builderQueue := make(chan *nostr.Event, config.ChannelCapacity) + fetcherQueue := make(chan string, config.ChannelCapacity) nodes, err := db.NodeCount(ctx) if err != nil { diff --git a/pkg/config/config.go b/pkg/config/config.go index df3fb18..4300ee0 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -15,8 +15,7 @@ import ( type SystemConfig struct { RedisAddress string `envconfig:"REDIS_ADDRESS"` SQLiteURL string `envconfig:"SQLITE_URL"` - EventsCapacity int `envconfig:"EVENTS_CAPACITY"` - PubkeysCapacity int `envconfig:"PUBKEYS_CAPACITY"` + ChannelCapacity int `envconfig:"CHANNEL_CAPACITY"` InitPubkeys []string `envconfig:"INIT_PUBKEYS"` PrintStats bool `envconfig:"PRINT_STATS"` } @@ -25,14 +24,13 @@ func NewSystemConfig() SystemConfig { return SystemConfig{ RedisAddress: "localhost:6379", SQLiteURL: "events.sqlite", - EventsCapacity: 1000, - PubkeysCapacity: 1000, + ChannelCapacity: 10_000, } } func (c SystemConfig) Validate() error { - if c.EventsCapacity < 0 { - return errors.New("events: value cannot be negative") + if c.ChannelCapacity < 0 { + return errors.New("channel capacity cannot be negative") } for _, pk := range c.InitPubkeys { @@ -47,8 +45,7 @@ func (c SystemConfig) Print() { fmt.Println("System:") fmt.Printf(" RedisAddress: %s\n", c.RedisAddress) fmt.Printf(" SQLiteURL: %s\n", c.SQLiteURL) - fmt.Printf(" EventsCapacity: %d\n", c.EventsCapacity) - fmt.Printf(" PubkeysCapacity: %d\n", c.PubkeysCapacity) + fmt.Printf(" ChannelCapacity: %d\n", c.ChannelCapacity) fmt.Printf(" InitPubkeys: %v\n", c.InitPubkeys) fmt.Printf(" PrintStats: %v\n", c.PrintStats) } diff --git a/pkg/pipe/engine.go b/pkg/pipe/engine.go index a912b3b..6e4d6fe 100644 --- a/pkg/pipe/engine.go +++ b/pkg/pipe/engine.go @@ -21,7 +21,7 @@ import ( type EngineConfig struct { Archiver ArchiverConfig Builder GraphBuilderConfig - ChannelCapacity int `envconfig:"ENGINE_BUILDER_CAPACITY"` + ChannelCapacity int `envconfig:"CHANNEL_CAPACITY"` } func NewEngineConfig() EngineConfig {