-
Notifications
You must be signed in to change notification settings - Fork 5
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
Allow only price aggregator contract to have multiple bindings [CCIP-4781] #426
Conversation
… contracts should only have one instance at any single time.
} else { | ||
if len(e.contractBindingsByName[binding.Name]) > 0 { | ||
// Unbind the previous binding | ||
err := e.reader.Unbind(ctx, []types.BoundContract{e.contractBindingsByName[binding.Name][0].Binding}) |
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.
Double checking - are we certain there's only one other binding in this situation?
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.
Because of the current condition yes there should only be one binding.
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.
There could be more if the extended reader was created with a reader that already had bound contracts. But that would just mean there are some dangling bindings, our discovery code would work fine because error checking is done using the contractBindingsByName
list.
|
if e.multiBindAllowed[binding.Name] { | ||
e.contractBindingsByName[binding.Name] = append(e.contractBindingsByName[binding.Name], ExtendedBoundContract{ | ||
BoundAt: time.Now(), | ||
Binding: binding, | ||
}) |
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.
style nit: I would be tempted to rewrite this to avoid the else
. Something like
// unbind previous contract if needed
if len(e.contractBindingsByName[binding.Name]) > 0 && e.multiBindAllowed[binding.Name] {
e.reader.Unbind(...)
e.contractBindingsByName[binding.Name] = nil
}
// existing logic here
}
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.
Looks good, one minor suggestions
Allow only price aggregator contract to have multiple bindings, othe contracts should only have one instance at any single time.
core ref: 843e228fba3c5264d34fb5bc2bd972f1576057d8
Core PR: smartcontractkit/chainlink#15854