-
Notifications
You must be signed in to change notification settings - Fork 6
Initial work for workflow registry v2: limits #40
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
Conversation
a37a2df
to
7a16d99
Compare
0530b5e
to
28b1d42
Compare
if (isSet) { | ||
s_cfg.userOverride[user] = Config.Value(limit, true); | ||
} else { | ||
delete s_cfg.userOverride[user]; |
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.
Not 100% sure on this, but generally, deleting elements in mappings/arrays is avoided due to gas costs, so resetting values is more desirable. Since you're already using this isSet
field value, maybe you can just set it false
? In that case, this code is as simple as:
s_cfg.userOverride[user] = Config.Value(limit, isSet);
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.
delete is only costly for large structures, but this is one slot size, so delete versus setting this to false cost the same storage write but has the slight benefit of the cleared slot refund. the only benefit potentially in allowing it is record I think.
// Struct to distinguish between unset and explicitly set zero values | ||
struct Value { | ||
uint32 value; | ||
bool isSet; |
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.
You could also use the uint32
max value or any other arbitrarily large value to have a special meaning, but this is certainly easier to understand!
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.
This looks like it's more complicated but actually not much more as both are small and fits into one storage slot, but much more explicit and readable than using an arbitrary value to get around the falsey zeros
28b1d42
to
5561750
Compare
5561750
to
af24803
Compare
b7cd0d0
to
453fbeb
Compare
453fbeb
to
67f2f0b
Compare
3ff3c89
to
0db8d50
Compare
d41e70c
to
dc36809
Compare
3fececd
to
a6df1f0
Compare
a6df1f0
to
ebf89cb
Compare
746180c
to
af37a41
Compare
No description provided.