Skip to content

Commit

Permalink
Start EncodedLogCollector as soon as filters are loaded
Browse files Browse the repository at this point in the history
Also: add missing return from lp.loadFilters
  • Loading branch information
reductionista committed Jan 15, 2025
1 parent 7c4058b commit dabd063
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/solana/logpoller/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func (fl *filters) removeFilterFromIndexes(filter Filter) {
// Requires LoadFilters to be called at least once.
func (fl *filters) matchingFilters(addr PublicKey, eventSignature EventSignature) iter.Seq[Filter] {
if !fl.loadedFilters.Load() {
fl.lggr.Critical("Invariant violation: expected filters to be loaded before call to MatchingFilters")
fl.lggr.Critical("Invariant violation: expected filters to be loaded before call to matchingFilters")
return nil
}
return func(yield func(Filter) bool) {
Expand Down
9 changes: 6 additions & 3 deletions pkg/solana/logpoller/log_poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ func (lp *LogPoller) loadFilters(ctx context.Context) error {
case <-retryTicker.C:
}
err := lp.filters.LoadFilters(ctx)
if err != nil {
lp.lggr.Errorw("Failed loading filters in init logpoller loop, retrying later", "err", err)
continue
if err == nil {
return nil
}
lp.lggr.Errorw("Failed loading filters in init logpoller loop, retrying later", "err", err)
}
// unreachable
}
Expand All @@ -201,6 +201,9 @@ func (lp *LogPoller) run(ctx context.Context) {
return
}

// safe to start fetching logs, now that filters are loaded
lp.collector.Start(ctx)

var blocks chan struct {
BlockNumber int64
Logs any // to be defined
Expand Down

0 comments on commit dabd063

Please sign in to comment.