-
Notifications
You must be signed in to change notification settings - Fork 353
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
refactor: make mebibyte a constant #4225
base: main
Are you sure you want to change the base?
Changes from all commits
df0dee1
7cf298a
9606750
79a4e47
49beac4
29b2ee8
f0c9ecf
fbbd173
6116a94
1114ebe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,4 @@ package app_test | |
|
||
const ( | ||
kibibyte = 1024 | ||
mebibyte = 1024 * kibibyte | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,14 +156,14 @@ func TestCalculateBlockProvisionError(t *testing.T) { | |
} | ||
|
||
func randomBlockInterval() time.Duration { | ||
min := (14 * time.Second).Nanoseconds() | ||
max := (16 * time.Second).Nanoseconds() | ||
return time.Duration(randInRange(min, max)) | ||
minimum := (14 * time.Second).Nanoseconds() | ||
maximum := (16 * time.Second).Nanoseconds() | ||
return time.Duration(randInRange(minimum, maximum)) | ||
Comment on lines
-159
to
+161
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why were these also changed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed min and max to minimum and maximum because linting failed with redefines-builtin-id: redefinition of the built-in function min (revive). |
||
} | ||
|
||
// randInRange returns a random number in the range (min, max) inclusive. | ||
func randInRange(min int64, max int64) int64 { | ||
return rand.Int63n(max-min) + min | ||
func randInRange(minimum int64, maximum int64) int64 { | ||
return rand.Int63n(maximum-minimum) + minimum | ||
Comment on lines
-165
to
+166
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed |
||
} | ||
|
||
func BenchmarkCalculateBlockProvision(b *testing.B) { | ||
|
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.
if we want this to be a constant, then we might as well use a global constant in the constant package
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.
that's a good idea. Where is the constant package? you mean the one in core
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.
We have https://github.com/celestiaorg/celestia-app/tree/main/pkg/appconsts.
My uber nit is that we don't want
Mebibyte
part of the public API of any of our packages so seems fine to define it once per package as a private constant.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.
got you 👍 My initial motivation is just to stop writing that magic number everywhere and give it a name
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.
I'm fine with whichever you prefer :D