You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
iterate looking for a specific target but once it has found it just keeps iterating and comparing over all all the cellar ids and at no point do we modify found=false in the loop. If we notice down below, we only append to the slice if !found hence we really should just end that loop immediately to avoid needless CPU cycles being wasted
Suggestion
for _, inputID := range p.CellarIds.Ids {
if existingID == common.HexToAddress(inputID) {
found = true // We found the existing inputID
break
}
}
if !found {
outputCellarIDs.Ids = append(outputCellarIDs.Ids, existingID.String())
}
The text was updated successfully, but these errors were encountered:
odeke-em
changed the title
x/cork/keeper: HandleRemoveManagedCellarsProposal should bail out immediately found=true to avoid needless/wasted iterations
x/axelarcork/keeper, x/cork/keeper: HandleRemoveManagedCellarsProposal should bail out immediately found=true to avoid needless/wasted iterations
Mar 15, 2024
Summary of Bug
The loops here
sommelier/x/cork/keeper/proposal_handler.go
Lines 62 to 70 in 3157d97
and
sommelier/x/axelarcork/keeper/proposal_handler.go
Lines 41 to 47 in 3157d97
iterate looking for a specific target but once it has found it just keeps iterating and comparing over all all the cellar ids and at no point do we modify found=false in the loop. If we notice down below, we only append to the slice if !found hence we really should just end that loop immediately to avoid needless CPU cycles being wasted
Suggestion
The text was updated successfully, but these errors were encountered: