Documentation
¶
Index ¶
- Constants
- Variables
- type Number
- type Sequence
- func (s Sequence[T]) CurVal(store storetypes.KVStore) T
- func (s Sequence[T]) DecodeSequence(bz []byte) T
- func (s Sequence[T]) EncodeSequence(t T) []byte
- func (s Sequence[T]) IncreaseSequence(t T) T
- func (s Sequence[T]) InitVal(store storetypes.KVStore, seq T) error
- func (s Sequence[T]) NextVal(store storetypes.KVStore) T
- func (s Sequence[T]) ToUint256(seq T) math.Uint
- func (s Sequence[T]) ToUint32(seq T) uint32
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 Sequence ¶ added in v0.2.3
type Sequence[T Number] struct { // contains filtered or unexported fields }
func NewSequence ¶ added in v0.2.3
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 (Sequence[T]) EncodeSequence ¶ added in v0.2.3
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
Click to show internal directories.
Click to hide internal directories.