@@ -10,6 +10,8 @@ import (
1010// Implemented in accordance to https://celestiaorg.github.io/celestia-app/namespace.html
1111
1212const (
13+ // NamespaceVersionIndex is the index of the namespace version in the byte slice
14+ NamespaceVersionIndex = 0
1315 // NamespaceVersionSize is the size of the namespace version in bytes
1416 NamespaceVersionSize = 1
1517 // NamespaceIDSize is the size of the namespace ID in bytes
@@ -37,8 +39,8 @@ type Namespace struct {
3739// Bytes returns the namespace as a byte slice
3840func (n Namespace ) Bytes () []byte {
3941 result := make ([]byte , NamespaceSize )
40- result [0 ] = n .Version
41- copy (result [1 :], n .ID [:])
42+ result [NamespaceVersionIndex ] = n .Version
43+ copy (result [NamespaceVersionSize :], n .ID [:])
4244 return result
4345}
4446
@@ -49,7 +51,7 @@ func (n Namespace) IsValidForVersion0() bool {
4951 return false
5052 }
5153
52- for i := 0 ; i < NamespaceVersionZeroPrefixSize ; i ++ {
54+ for i := range NamespaceVersionZeroPrefixSize {
5355 if n .ID [i ] != 0 {
5456 return false
5557 }
@@ -84,9 +86,9 @@ func NamespaceFromBytes(b []byte) (*Namespace, error) {
8486 }
8587
8688 ns := & Namespace {
87- Version : b [0 ],
89+ Version : b [NamespaceVersionIndex ],
8890 }
89- copy (ns .ID [:], b [1 :])
91+ copy (ns .ID [:], b [NamespaceVersionSize :])
9092
9193 // Validate if it's version 0
9294 if ns .Version == NamespaceVersionZero && ! ns .IsValidForVersion0 () {
0 commit comments