Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Access] Sort events returned from index in tx index order - backport #5444

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

peterargue
Copy link
Contributor

Backport: #5404

[Access] Sort events returned from index in tx index order
@codecov-commenter
Copy link

codecov-commenter commented Feb 22, 2024

Codecov Report

Attention: Patch coverage is 70.00000% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 56.01%. Comparing base (514461a) to head (8a6bbaf).

Files Patch % Lines
engine/access/rpc/backend/events_index.go 70.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5444      +/-   ##
==========================================
+ Coverage   55.99%   56.01%   +0.01%     
==========================================
  Files        1026     1026              
  Lines       99815    99824       +9     
==========================================
+ Hits        55894    55917      +23     
+ Misses      39627    39610      -17     
- Partials     4294     4297       +3     
Flag Coverage Δ
unittests 56.01% <70.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@peterargue peterargue added this pull request to the merge queue Feb 23, 2024
Comment on lines +49 to +52
if events[i].TransactionIndex == events[j].TransactionIndex {
return events[i].EventIndex < events[j].EventIndex
}
return events[i].TransactionIndex < events[j].TransactionIndex
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe factor the repeated indexing expressions into variables:

Suggested change
if events[i].TransactionIndex == events[j].TransactionIndex {
return events[i].EventIndex < events[j].EventIndex
}
return events[i].TransactionIndex < events[j].TransactionIndex
a := events[i]
b := events[j]
if a.TransactionIndex == b.TransactionIndex {
return a.EventIndex < b.EventIndex
}
return a.TransactionIndex < b.TransactionIndex

Comment on lines +57 to +62
cmp := bytes.Compare(events[i].TransactionID[:], events[j].TransactionID[:])
if cmp == 0 {
if events[i].TransactionIndex == events[j].TransactionIndex {
return events[i].EventIndex < events[j].EventIndex
}
return events[i].TransactionIndex < events[j].TransactionIndex
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Merged via the queue into master with commit e1e2ddd Feb 23, 2024
49 of 51 checks passed
@peterargue peterargue deleted the petera/backport-fix-event-tx-order branch February 23, 2024 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants