Skip to content

Commit

Permalink
refactor: simplify roundUpByMultipleOf
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp committed Jul 27, 2023
1 parent 53e7b57 commit e9f5c15
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions pkg/shares/blob_share_commitment_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,10 @@ func NextShareIndex(cursor, blobShareLen, subtreeRootThreshold int) int {
// roundUpByMultipleOf rounds cursor up to the next multiple of v. If cursor is divisible
// by v, then it returns cursor
func roundUpByMultipleOf(cursor, v int) int {
switch {
case cursor == 0:
if cursor%v == 0 {
return cursor
case cursor%v == 0:
return cursor
default:
return ((cursor / v) + 1) * v
}
return ((cursor / v) + 1) * v
}

// BlobMinSquareSize returns the minimum square size that can contain shareCount
Expand Down
2 changes: 1 addition & 1 deletion pkg/shares/blob_share_commitment_rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func TestNextShareIndex(t *testing.T) {
}
}

func Test_roundUpBy(t *testing.T) {
func Test_roundUpByMultipleOf(t *testing.T) {
type test struct {
cursor, v int
expectedIndex int
Expand Down

0 comments on commit e9f5c15

Please sign in to comment.