namespace

package
v0.0.0-...-4ef5390 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NamespaveVersionSize is the size of a namespace version in bytes.
	NamespaceVersionSize = appconsts.NamespaceVersionSize

	// NamespaceIDSize is the size of a namespace ID in bytes.
	NamespaceIDSize = appconsts.NamespaceIDSize

	// NamespaceSize is the size of a namespace (version + ID) in bytes.
	NamespaceSize = appconsts.NamespaceSize

	// 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 ordinary Cosmos SDK transactions.
	TxNamespace = primaryReservedNamespace(0x01)

	// IntermediateStateRootsNamespace is the namespace reserved for
	// intermediate state root data.
	IntermediateStateRootsNamespace = primaryReservedNamespace(0x02)

	// PayForBlobNamespace is the namespace reserved for PayForBlobs transactions.
	PayForBlobNamespace = primaryReservedNamespace(0x04)

	// PrimaryReservedPaddingNamespace is the namespace used for padding after all
	// primary reserved namespaces.
	PrimaryReservedPaddingNamespace = primaryReservedNamespace(0xFF)

	// MaxPrimaryReservedNamespace is the highest primary reserved namespace.
	// Namespaces lower than this are reserved for protocol use.
	MaxPrimaryReservedNamespace = primaryReservedNamespace(0xFF)

	// MinSecondaryReservedNamespace is the lowest secondary reserved namespace
	// reserved for protocol use. Namespaces higher than this are reserved for
	// protocol use.
	MinSecondaryReservedNamespace = secondaryReservedNamespace(0x00)

	// TailPaddingNamespace is the namespace reserved for tail padding. All data
	// with this namespace will be ignored.
	TailPaddingNamespace = secondaryReservedNamespace(0xFE)

	// ParitySharesNamespace is the namespace reserved for erasure coded data.
	ParitySharesNamespace = secondaryReservedNamespace(0xFF)

	// SupportedBlobNamespaceVersions is a list of namespace versions that can be specified by a user for blobs.
	SupportedBlobNamespaceVersions = []uint8{NamespaceVersionZero}
)

Functions

func RandomBlobNamespaceID

func RandomBlobNamespaceID() []byte

func RandomBlobNamespaceIDWithPRG

func RandomBlobNamespaceIDWithPRG(prg *tmrand.Rand) []byte

RandomBlobNamespaceIDWithPRG returns a random blob namespace ID using the supplied Pseudo-Random number Generator (PRG).

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(subID []byte) Namespace

MustNewV0 returns a new namespace with version 0 and the provided subID. This function panics if the provided subID would result in an invalid namespace.

func New

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

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

func NewV0

func NewV0(subID []byte) (Namespace, error)

NewV0 returns a new namespace with version 0 and the provided subID. subID must be <= 10 bytes. If subID is < 10 bytes, it will be left-padded with 0s to fill 10 bytes.

func RandomBlobNamespace

func RandomBlobNamespace() Namespace

func RandomBlobNamespaceWithPRG

func RandomBlobNamespaceWithPRG(prg *tmrand.Rand) Namespace

RandomBlobNamespaceWithPRG generates and returns a random blob namespace using the supplied Pseudo-Random number Generator (PRG).

func RandomBlobNamespaces

func RandomBlobNamespaces(rand *tmrand.Rand, count int) (namespaces []Namespace)

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) IsPrimaryReserved

func (n Namespace) IsPrimaryReserved() bool

func (Namespace) IsPrimaryReservedPadding

func (n Namespace) IsPrimaryReservedPadding() bool

func (Namespace) IsReserved

func (n Namespace) IsReserved() bool

IsReserved returns true if the namespace is reserved for protocol-use.

func (Namespace) IsSecondaryReserved

func (n Namespace) IsSecondaryReserved() 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

Jump to

Keyboard shortcuts

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