-
Notifications
You must be signed in to change notification settings - Fork 122
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
Fix faulty iterator callsite callback return booleans #447
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the fix @danwt!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @danwt.
@@ -140,7 +140,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) (genesis *consumertypes.GenesisSt | |||
ValidatorConsensusAddress: addr, | |||
} | |||
outstandingDowntimes = append(outstandingDowntimes, od) | |||
return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comments describing the intended outcome, e.g., continue iterating. It will make it easier to change afterwards to the SDK pattern.
@@ -43,7 +43,7 @@ func (k Keeper) QueryConsumerChains(goCtx context.Context, req *types.QueryConsu | |||
ChainId: chainID, | |||
ClientId: clientID, | |||
}) | |||
return false | |||
return true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Until a better fix, change the return field from stop
to continue
, i.e.,
func (k Keeper) IterateConsumerChains(ctx sdk.Context, cb func(ctx sdk.Context, chainID, clientID string) (continue bool)) {
@@ -354,7 +354,7 @@ func (k Keeper) EndBlockCCR(ctx sdk.Context) { | |||
return false | |||
}) | |||
// continue to iterate through all consumers | |||
return true | |||
return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto: IterateChannelToChain
change stop
to continue
I merged to get the fix in as changing the New issue |
We had some errors in the way we were using iterators.
This PR fixes 5 bugs. I could have easily made a mistake and missed others, as it's a bit error prone.
( Fixes #433 )
Note: based on concerns to minimize diffs I flipped the bools to fix the issues. Really we need a larger change to match the SDK pattern. Please see here #440 for discussion of a larger solution where we'd change our iterators to match the SDK style.
This could have been avoided with better guidelines about var naming IMO.