Skip to content

Commit

Permalink
fix: events: close initial query; handle lint failures
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Jun 14, 2024
1 parent c76f83a commit 2003bdb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions chain/events/filter/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,9 @@ func NewEventIndex(ctx context.Context, path string, chainStore *store.ChainStor
eventIndex := EventIndex{db: db}

q, err := db.QueryContext(ctx, "SELECT name FROM sqlite_master WHERE type='table' AND name='_meta';")
if q != nil {
defer func() { _ = q.Close() }()
}
if errors.Is(err, sql.ErrNoRows) || !q.Next() {
// empty database, create the schema
for _, ddl := range ddls {
Expand Down Expand Up @@ -744,7 +747,7 @@ func (ei *EventIndex) prefillFilter(ctx context.Context, f *eventFilter, exclude
if err != nil {
return xerrors.Errorf("prepare prefill query: %w", err)
}
defer stmt.Close()
defer func() { _ = stmt.Close() }()

q, err := stmt.QueryContext(ctx, values...)
if err != nil {
Expand All @@ -753,7 +756,7 @@ func (ei *EventIndex) prefillFilter(ctx context.Context, f *eventFilter, exclude
}
return xerrors.Errorf("exec prefill query: %w", err)
}
defer q.Close()
defer func() { _ = q.Close() }()

var ces []*CollectedEvent
var currentID int64 = -1
Expand Down

0 comments on commit 2003bdb

Please sign in to comment.