Skip to content

Commit

Permalink
Merge pull request #304 from forta-network/ali/forta-1571-investigate…
Browse files Browse the repository at this point in the history
…-overlapping-combiner-feeds

Fix combiner feed pointer usage
  • Loading branch information
dkeysil authored Mar 6, 2024
2 parents ede0028 + 265e284 commit a1ac54a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion domain/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ type AlertEvent struct {
Event *protocol.AlertEvent
Logs []LogEntry
Timestamps *TrackingTimestamps
Subscriber *Subscriber
Subscriber Subscriber
}

// ToMessage converts the AlertEvent to the protocol.TransactionEvent message
Expand Down
4 changes: 2 additions & 2 deletions feeds/combiner.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func (cf *combinerFeed) handleSubscriptions(alertHandlers []cfHandler, subscript
break
}
}
cf.processAlerts(cf.ctx, logger, &subscriber, subscriberAlerts, alertHandlers)
cf.processAlerts(cf.ctx, logger, subscriber, subscriberAlerts, alertHandlers)
}
}

Expand Down Expand Up @@ -293,7 +293,7 @@ func subscriptionsToAlertInputs(subscriptions []*protocol.CombinerBotSubscriptio
// the remaining alerts to the alert handlers passed in as an argument.
// It uses a cache to prevent duplicate processing of alerts and creates an AlertEvent object to pass to each alert handler.
// It is thread-safe as it acquires a lock on the combinerCache mutex before accessing or modifying it.
func (cf *combinerFeed) processAlerts(_ context.Context, logger *log.Entry, subscriber *domain.Subscriber,
func (cf *combinerFeed) processAlerts(_ context.Context, logger *log.Entry, subscriber domain.Subscriber,
alerts []*protocol.AlertEvent,
alertHandlers []cfHandler) {
for _, alert := range alerts {
Expand Down
4 changes: 2 additions & 2 deletions feeds/combiner_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ func newCombinerCache(path string) (*combinerCache, error) {
return &combinerCache{cache: alertCache, path: path}, nil
}

func (c *combinerCache) Exists(subscriber *domain.Subscriber, alert *protocol.AlertEvent) bool {
func (c *combinerCache) Exists(subscriber domain.Subscriber, alert *protocol.AlertEvent) bool {
_, exists := c.cache.Get(encodeAlertCacheKey(subscriber.BotID, subscriber.BotImage, alert.Alert.Hash))
return exists
}

func (c *combinerCache) Set(subscriber *domain.Subscriber, alert *protocol.AlertEvent) {
func (c *combinerCache) Set(subscriber domain.Subscriber, alert *protocol.AlertEvent) {
c.cache.Set(encodeAlertCacheKey(subscriber.BotID, subscriber.BotImage, alert.Alert.Hash), struct{}{}, cache.DefaultExpiration)
}

Expand Down

0 comments on commit a1ac54a

Please sign in to comment.