-
Notifications
You must be signed in to change notification settings - Fork 348
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
Open
ZwangaMukwevho
wants to merge
10
commits into
celestiaorg:main
Choose a base branch
from
ZwangaMukwevho:refactor-mebibyte
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+34
−40
Open
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
df0dee1
refactor: change mebibyte to a constant
ZwangaMukwevho 7cf298a
refactor: refactor mebibyte in the test files
ZwangaMukwevho 9606750
Merge branch 'main' into refactor-mebibyte
ZwangaMukwevho 79a4e47
fix: remove circular dependencies
ZwangaMukwevho 49beac4
Merge branch 'refactor-mebibyte' of github.com:ZwangaMukwevho/celesti…
ZwangaMukwevho 29b2ee8
Merge branch 'main' into refactor-mebibyte
ZwangaMukwevho f0c9ecf
fix: fix further linter changes
ZwangaMukwevho fbbd173
Merge branch 'refactor-mebibyte' of github.com:ZwangaMukwevho/celesti…
ZwangaMukwevho 6116a94
fix: add seperate mebibyte constant in x/blob/ante/blob_share_decorat…
ZwangaMukwevho 1114ebe
chore: use Mebibyte seperately in ant_test package
ZwangaMukwevho File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,4 @@ package app_test | |
|
||
const ( | ||
kibibyte = 1024 | ||
mebibyte = 1024 * kibibyte | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? |
||
} | ||
|
||
// 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 |
||
} | ||
|
||
func BenchmarkCalculateBlockProvision(b *testing.B) { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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