Documentation ¶
Index ¶
- Constants
- Variables
- func RandomVerzionZeroID() []byte
- type Namespace
- func (n Namespace) Bytes() []byte
- func (n Namespace) Equals(n2 Namespace) bool
- func (n Namespace) IsGreaterOrEqualThan(n2 Namespace) bool
- func (n Namespace) IsGreaterThan(n2 Namespace) bool
- func (n Namespace) IsLessOrEqualThan(n2 Namespace) bool
- func (n Namespace) IsLessThan(n2 Namespace) bool
- func (n Namespace) IsParityShares() bool
- func (n Namespace) IsPayForBlob() bool
- func (n Namespace) IsReserved() bool
- func (n Namespace) IsReservedPadding() bool
- func (n Namespace) IsTailPadding() bool
- func (n Namespace) IsTx() bool
- func (n Namespace) Repeat(times int) []Namespace
- func (n Namespace) ValidateBlobNamespace() error
Constants ¶
View Source
const ( // NamespaveVersionSize is the size of a namespace version in bytes. NamespaceVersionSize = 1 // NamespaceIDSize is the size of a namespace ID in bytes. NamespaceIDSize = 28 // NamespaceSize is the size of a namespace (version + ID) in bytes. NamespaceSize = NamespaceVersionSize + NamespaceIDSize // NamespaceVersionZero is the first namespace version. NamespaceVersionZero = uint8(0) // NamespaceVersionMax is the max namespace version. NamespaceVersionMax = math.MaxUint8 // NamespaceZeroPrefixSize is the number of `0` bytes that are prefixed to // namespace IDs for version 0. NamespaceVersionZeroPrefixSize = 18 // NamespaceVersionZeroIDSize is the number of bytes available for // user-specified namespace ID in a namespace ID for version 0. NamespaceVersionZeroIDSize = NamespaceIDSize - NamespaceVersionZeroPrefixSize )
Variables ¶
View Source
var ( // NamespaceVersionZeroPrefix is the prefix of a namespace ID for version 0. NamespaceVersionZeroPrefix = bytes.Repeat([]byte{0}, NamespaceVersionZeroPrefixSize) // TxNamespace is the namespace reserved for transaction data. TxNamespace = MustNewV0([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 1}) // IntermediateStateRootsNamespace is the namespace reserved for // intermediate state root data. IntermediateStateRootsNamespace = MustNewV0([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 2}) // PayForBlobNamespace is the namespace reserved for PayForBlobs transactions. PayForBlobNamespace = MustNewV0([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 4}) // ReservedPaddingNamespace is the namespace used for padding after all // reserved namespaces. In practice this padding is after transactions // (ordinary and PFBs) but before blobs. ReservedPaddingNamespace = MustNewV0([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 255}) // MaxReservedNamespace is lexicographically the largest namespace that is // reserved for protocol use. MaxReservedNamespace = MustNewV0([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 255}) // TailPaddingNamespace is the namespace reserved for tail padding. All data // with this namespace will be ignored. TailPaddingNamespace = Namespace{ Version: math.MaxUint8, ID: append(bytes.Repeat([]byte{0xFF}, NamespaceIDSize-1), 0xFE), } ParitySharesNamespace = Namespace{ Version: math.MaxUint8, ID: bytes.Repeat([]byte{0xFF}, NamespaceIDSize), } )
View Source
var ( // NewBaseHashFunc is the base hash function used by NMT. Change accordingly // if another hash.Hash should be used as a base hasher in the NMT. NewBaseHashFunc = sha256.New )
Functions ¶
func RandomVerzionZeroID ¶
func RandomVerzionZeroID() []byte
Types ¶
type Namespace ¶
func MustNew ¶
MustNew returns a new namespace with the provided version and id. It panics if the provided version or id are not supported.
func MustNewV0 ¶
MustNewV0 returns a new namespace with version 0 and the provided id. This function panics if the provided id is not exactly NamespaceVersionZeroIDSize bytes.
func RandomNamespace ¶
func RandomNamespace() Namespace
func (Namespace) IsGreaterOrEqualThan ¶
func (Namespace) IsGreaterThan ¶
func (Namespace) IsLessOrEqualThan ¶
func (Namespace) IsLessThan ¶
func (Namespace) IsParityShares ¶
func (Namespace) IsPayForBlob ¶
func (Namespace) IsReserved ¶
func (Namespace) IsReservedPadding ¶
func (Namespace) IsTailPadding ¶
func (Namespace) ValidateBlobNamespace ¶
ValidateBlobNamespace returns an error if this namespace is not a valid blob namespace.
Click to show internal directories.
Click to hide internal directories.