From 6d84fad3d97469aebcca3fdbdb2ef4852f33d41b Mon Sep 17 00:00:00 2001 From: Akshay Date: Thu, 27 Mar 2025 21:25:40 +0000 Subject: [PATCH] minor tweaks, add logging --- appview/state/state.go | 2 +- jetstream/jetstream.go | 5 +++++ knotserver/handler.go | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/appview/state/state.go b/appview/state/state.go index 1256ca0..dbb7bda 100644 --- a/appview/state/state.go +++ b/appview/state/state.go @@ -63,7 +63,7 @@ func Make(config *appview.Config) (*State, error) { jc, err := jetstream.NewJetstreamClient( config.JetstreamEndpoint, "appview", - []string{tangled.GraphFollowNSID}, + []string{tangled.GraphFollowNSID, tangled.FeedStarNSID}, nil, slog.Default(), wrapper, diff --git a/jetstream/jetstream.go b/jetstream/jetstream.go index 1220de4..615316d 100644 --- a/jetstream/jetstream.go +++ b/jetstream/jetstream.go @@ -43,6 +43,7 @@ func (j *JetstreamClient) AddDid(did string) { return } + j.l.Info("adding did to in-memory filter", "did", did) j.mu.Lock() j.wantedDids[did] = struct{}{} j.mu.Unlock() @@ -51,6 +52,10 @@ func (j *JetstreamClient) AddDid(did string) { type processor func(context.Context, *models.Event) error func (j *JetstreamClient) withDidFilter(processFunc processor) processor { + // empty filter => all dids allowed + if len(j.wantedDids) == 0 { + return processFunc + } // since this closure references j.WantedDids; it should auto-update // existing instances of the closure when j.WantedDids is mutated return func(ctx context.Context, evt *models.Event) error { diff --git a/knotserver/handler.go b/knotserver/handler.go index 5207f40..e354caf 100644 --- a/knotserver/handler.go +++ b/knotserver/handler.go @@ -60,6 +60,7 @@ func Setup(ctx context.Context, c *config.Config, db *db.DB, e *rbac.Enforcer, j if err != nil { return nil, fmt.Errorf("failed to get all Dids: %w", err) } + if len(dids) > 0 { h.knotInitialized = true close(h.init) -- 2.51.2