namespace

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

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 is the namespace reserved for erasure coded data.
	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

type Namespace struct {
	Version uint8
	ID      []byte
}

func From

func From(b []byte) (Namespace, error)

From returns a namespace from the provided byte slice.

func MustNew

func MustNew(version uint8, id []byte) Namespace

MustNew returns a new namespace with the provided version and id. It panics if the provided version or id are not supported.

func MustNewV0

func MustNewV0(id []byte) Namespace

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 New

func New(version uint8, id []byte) (Namespace, error)

New returns a new namespace with the provided version and id.

func RandomNamespace

func RandomNamespace() Namespace

func (Namespace) Bytes

func (n Namespace) Bytes() []byte

Bytes returns this namespace as a byte slice.

func (Namespace) Equals

func (n Namespace) Equals(n2 Namespace) bool

func (Namespace) IsGreaterOrEqualThan

func (n Namespace) IsGreaterOrEqualThan(n2 Namespace) bool

func (Namespace) IsGreaterThan

func (n Namespace) IsGreaterThan(n2 Namespace) bool

func (Namespace) IsLessOrEqualThan

func (n Namespace) IsLessOrEqualThan(n2 Namespace) bool

func (Namespace) IsLessThan

func (n Namespace) IsLessThan(n2 Namespace) bool

func (Namespace) IsParityShares

func (n Namespace) IsParityShares() bool

func (Namespace) IsPayForBlob

func (n Namespace) IsPayForBlob() bool

func (Namespace) IsReserved

func (n Namespace) IsReserved() bool

func (Namespace) IsReservedPadding

func (n Namespace) IsReservedPadding() bool

func (Namespace) IsTailPadding

func (n Namespace) IsTailPadding() bool

func (Namespace) IsTx

func (n Namespace) IsTx() bool

func (Namespace) Repeat

func (n Namespace) Repeat(times int) []Namespace

func (Namespace) ValidateBlobNamespace

func (n Namespace) ValidateBlobNamespace() error

ValidateBlobNamespace returns an error if this namespace is not a valid blob namespace.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL