lib

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: May 18, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ListMapper

type ListMapper interface {

	// Len() returns the length of the list
	// The length is only increased by Push() and not decreased
	// ListMapper dosen't check if an index is in bounds
	// The user should check Len() before doing any actions
	Len(sdk.Context) uint64

	// Get() returns the element by its index
	Get(sdk.Context, uint64, interface{}) error

	// Set() stores the element to the given position
	// Setting element out of range will break length counting
	// Use Push() instead of Set() to append a new element
	Set(sdk.Context, uint64, interface{})

	// Delete() deletes the element in the given position
	// Other elements' indices are preserved after deletion
	// Panics when the index is out of range
	Delete(sdk.Context, uint64)

	// Push() inserts the element to the end of the list
	// It will increase the length when it is called
	Push(sdk.Context, interface{})

	// CONTRACT: No writes may happen within a domain while iterating over it.
	IterateRead(sdk.Context, interface{}, func(sdk.Context, uint64) bool)

	// IterateWrite() is safe to write over the domain
	IterateWrite(sdk.Context, interface{}, func(sdk.Context, uint64) bool)

	// Key for the length of the list
	LengthKey() []byte

	// Key for getting elements
	ElemKey(uint64) []byte
}

ListMapper is a Mapper interface that provides list-like functions It panics when the element type cannot be (un/)marshalled by the codec

func NewListMapper

func NewListMapper(cdc *wire.Codec, key sdk.StoreKey, prefix string) ListMapper

NewListMapper constructs new ListMapper

type Mapper

type Mapper struct {
	// contains filtered or unexported fields
}

Mapper defines a primitive mapper type

func (Mapper) Delete

func (m Mapper) Delete(ctx sdk.Context, index uint64)

Delete implements ListMapper

func (Mapper) ElemKey

func (m Mapper) ElemKey(i uint64) []byte

ElemKey implements ListMapper

func (Mapper) Flush

func (m Mapper) Flush(ctx sdk.Context, ptr interface{}, fn func(sdk.Context) bool)

Flush implements QueueMapper

func (Mapper) Get

func (m Mapper) Get(ctx sdk.Context, index uint64, ptr interface{}) error

Get implements ListMapper

func (Mapper) IsEmpty

func (m Mapper) IsEmpty(ctx sdk.Context) bool

IsEmpty implements QueueMapper

func (Mapper) IterateRead

func (m Mapper) IterateRead(ctx sdk.Context, ptr interface{}, fn func(sdk.Context, uint64) bool)

IterateRead implements ListMapper

func (Mapper) IterateWrite

func (m Mapper) IterateWrite(ctx sdk.Context, ptr interface{}, fn func(sdk.Context, uint64) bool)

IterateWrite implements ListMapper

func (Mapper) Len

func (m Mapper) Len(ctx sdk.Context) uint64

Len implements ListMapper

func (Mapper) LengthKey

func (m Mapper) LengthKey() []byte

LengthKey implements ListMapper

func (Mapper) Peek

func (m Mapper) Peek(ctx sdk.Context, ptr interface{}) error

Peek implements QueueMapper

func (Mapper) Pop

func (m Mapper) Pop(ctx sdk.Context)

Pop implements QueueMapper

func (Mapper) Push

func (m Mapper) Push(ctx sdk.Context, value interface{})

Push implements ListMapper

func (Mapper) Set

func (m Mapper) Set(ctx sdk.Context, index uint64, value interface{})

Set implements ListMapper

func (Mapper) TopKey

func (m Mapper) TopKey() []byte

TopKey implements QueueMapper

type QueueMapper

type QueueMapper interface {
	// Push() inserts the elements to the rear of the queue
	Push(sdk.Context, interface{})

	// Peek() returns the element at the front of the queue without removing it
	Peek(sdk.Context, interface{}) error

	// Pop() returns the element at the front of the queue and removes it
	Pop(sdk.Context)

	// IsEmpty() checks if the queue is empty
	IsEmpty(sdk.Context) bool

	// Flush() removes elements it processed
	// Return true in the continuation to break
	// The interface{} is unmarshalled before the continuation is called
	// Starts from the top(head) of the queue
	// CONTRACT: Pop() or Push() should not be performed while flushing
	Flush(sdk.Context, interface{}, func(sdk.Context) bool)

	// Key for the index of top element
	TopKey() []byte
}

QueueMapper is a Mapper interface that provides queue-like functions It panics when the element type cannot be (un/)marshalled by the codec

func NewQueueMapper

func NewQueueMapper(cdc *wire.Codec, key sdk.StoreKey, prefix string) QueueMapper

NewQueueMapper constructs new QueueMapper

Jump to

Keyboard shortcuts

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