-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove duplicated random valid namespace (#838)
Closes celestiaorg/celestia-app#836 Hey, @rootulp I'm not an expert go, so I don't know if the move I've made is the best possible, but it did its job. That said if you have any suggestions to improve that I'm open to adjusting it. PS: Since the repo doesn't contain the tag `hacktoberfest`, would be possible to label this PR with `hacktoberfest-accepted` so it can be validated there by the rule below? > PR/MRs that also have the “hacktoberfest-accepted” label cannot be marked as spammy via a label.
- Loading branch information
1 parent
bafe683
commit 38cf37c
Showing
8 changed files
with
34 additions
and
70 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package namespace | ||
|
||
import ( | ||
"bytes" | ||
|
||
"github.com/celestiaorg/celestia-app/pkg/appconsts" | ||
nmtnamespace "github.com/celestiaorg/nmt/namespace" | ||
tmrand "github.com/tendermint/tendermint/libs/rand" | ||
) | ||
|
||
func RandomMessageNamespace() nmtnamespace.ID { | ||
for { | ||
ns := tmrand.Bytes(8) | ||
isReservedNS := bytes.Compare(ns, appconsts.MaxReservedNamespace) <= 0 | ||
isParityNS := bytes.Equal(ns, appconsts.ParitySharesNamespaceID) | ||
isTailPaddingNS := bytes.Equal(ns, appconsts.TailPaddingNamespaceID) | ||
if isReservedNS || isParityNS || isTailPaddingNS { | ||
continue | ||
} | ||
return ns | ||
} | ||
} |
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