Skip to content

Commit

Permalink
Merge pull request #506 from onflow/gregor/bugfix-filter-lock
Browse files Browse the repository at this point in the history
Bugfix locking on logs filters
  • Loading branch information
sideninja authored Sep 2, 2024
2 parents 0d6f8eb + 43d0a9f commit 305ac9b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions api/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ func (api *PullAPI) UninstallFilter(id rpc.ID) bool {
api.mux.Lock()
defer api.mux.Unlock()

return api.uninstallFilter(id)
}

func (api *PullAPI) uninstallFilter(id rpc.ID) bool {
if _, ok := api.filters[id]; !ok { // not found
return false
}
Expand Down Expand Up @@ -301,7 +305,7 @@ func (api *PullAPI) GetFilterLogs(
}

if filter.expired() {
api.UninstallFilter(id)
api.uninstallFilter(id)
return nil, fmt.Errorf("%w: filter by id %s has expired", errs.ErrEntityNotFound, id)
}

Expand Down Expand Up @@ -352,7 +356,7 @@ func (api *PullAPI) GetFilterChanges(ctx context.Context, id rpc.ID) (any, error
}

if f.expired() {
api.UninstallFilter(id)
api.uninstallFilter(id)
return nil, fmt.Errorf("%w: filter by id %s has expired", errs.ErrEntityNotFound, id)
}

Expand Down

0 comments on commit 305ac9b

Please sign in to comment.