Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Rod Vagg <[email protected]>
  • Loading branch information
aarshkshah1992 and rvagg authored Jun 20, 2024
1 parent 306aded commit 4869218
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
3 changes: 1 addition & 2 deletions chain/events/filter/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const (
restoreEvent = `UPDATE event SET reverted=false WHERE height=? AND tipset_key=? AND tipset_key_cid=? AND emitter_addr=? AND event_index=? AND message_cid=? AND message_index=?`
revertEventSeen = `UPDATE events_seen SET reverted=true WHERE height=? AND tipset_key_cid=?`
restoreEventSeen = `UPDATE events_seen SET reverted=false WHERE height=? AND tipset_key_cid=?`
upsertEventsSeen = `INSERT INTO events_seen(height, tipset_key_cid, reverted) VALUES(?, ?, ?) ON CONFLICT(height, tipset_key_cid) DO UPDATE SET reverted=false`
upsertEventsSeen = `INSERT INTO events_seen(height, tipset_key_cid, reverted) VALUES(?, ?, false) ON CONFLICT(height, tipset_key_cid) DO UPDATE SET reverted=false`
isTipsetProcessed = `SELECT COUNT(*) > 0 FROM events_seen WHERE tipset_key_cid=?`
getMaxHeightInIndex = `SELECT MAX(height) FROM events_seen`
isHeightProcessed = `SELECT COUNT(*) > 0 FROM events_seen WHERE height=?`
Expand Down Expand Up @@ -867,7 +867,6 @@ func (ei *EventIndex) CollectEvents(ctx context.Context, te *TipSetEvents, rever
_, err = tx.Stmt(ei.stmtUpsertEventsSeen).Exec(
te.msgTs.Height(),
tsKeyCid.Bytes(),
false,
)
if err != nil {
return xerrors.Errorf("exec upsert events seen: %w", err)
Expand Down
10 changes: 4 additions & 6 deletions node/impl/full/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -1278,7 +1278,7 @@ func (e *EthEventHandler) EthGetLogs(ctx context.Context, filterSpec *ethtypes.E
maxHeight = e.Chain.GetHeaviestTipSet().Height()
}
if maxHeight > e.Chain.GetHeaviestTipSet().Height() {
return nil, xerrors.Errorf("max height requested is greater than the heaviest tipset")
return nil, xerrors.Errorf("maxHeight requested is greater than the heaviest tipset")
}

err := e.waitForHeightProcessed(ctx, maxHeight)
Expand All @@ -1289,7 +1289,7 @@ func (e *EthEventHandler) EthGetLogs(ctx context.Context, filterSpec *ethtypes.E
// should also have the minHeight in the filter indexed
b, err := e.EventFilterManager.EventIndex.IsHeightProcessed(ctx, uint64(pf.minHeight))
if err != nil {
return nil, xerrors.Errorf("failed to check if event index has events for the minheight: %w", err)
return nil, xerrors.Errorf("failed to check if event index has events for the minHeight: %w", err)
}
if !b {
return nil, xerrors.Errorf("event index does not have event for epoch %d", pf.minHeight)
Expand Down Expand Up @@ -1335,11 +1335,9 @@ func (e *EthEventHandler) waitForHeightProcessed(ctx context.Context, height abi
defer cancel()

// if the height we're interested in has already been indexed -> there's nothing to do here
b, err := ei.IsHeightProcessed(ctx, uint64(height))
if err != nil {
if b, err := ei.IsHeightProcessed(ctx, uint64(height)); err != nil {
return xerrors.Errorf("failed to check if event index has events for given height: %w", err)
}
if b {
} else if b {
return nil
}

Expand Down

0 comments on commit 4869218

Please sign in to comment.