sequence

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const EncodedSeqLength = 4

Variables

View Source
var (
	ErrSequenceUniqueConstraint = errors.Register("sequence_u256", 1, "sequence already initialized")
)

Functions

This section is empty.

Types

type Number added in v0.2.3

type Number interface {
	uint32 | math.Uint
}

type Sequence added in v0.2.3

type Sequence[T Number] struct {
	// contains filtered or unexported fields
}

func NewSequence added in v0.2.3

func NewSequence[T Number](prefix []byte) Sequence[T]

func (Sequence[T]) CurVal added in v0.2.3

func (s Sequence[T]) CurVal(store storetypes.KVStore) T

CurVal returns the last value used. 0 if none.

func (Sequence[T]) DecodeSequence added in v0.2.3

func (s Sequence[T]) DecodeSequence(bz []byte) T

func (Sequence[T]) EncodeSequence added in v0.2.3

func (s Sequence[T]) EncodeSequence(t T) []byte

func (Sequence[T]) IncreaseSequence added in v0.2.3

func (s Sequence[T]) IncreaseSequence(t T) T

func (Sequence[T]) InitVal added in v0.2.3

func (s Sequence[T]) InitVal(store storetypes.KVStore, seq T) error

InitVal this function sets the starting value for a sequence and can only be called once on an empty database. If the key already exists, an error will be returned. The provided start value will be stored as the current value. It is advised to use this function only when the sequence start value is not '1', as calling it unnecessarily will consume unnecessary gas. An example scenario would be importing from genesis. WARNING: only for test now

func (Sequence[T]) NextVal added in v0.2.3

func (s Sequence[T]) NextVal(store storetypes.KVStore) T

func (Sequence[T]) ToUint256 added in v0.2.3

func (s Sequence[T]) ToUint256(seq T) math.Uint

func (Sequence[T]) ToUint32 added in v0.2.3

func (s Sequence[T]) ToUint32(seq T) uint32

Jump to

Keyboard shortcuts

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