db

package
v0.0.0-...-c1b05a4 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2020 License: MIT, MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NamespaceStateTrie                                    = []byte("st")
	NamespaceRollupBlockTrie                              = []byte("rbt")
	NamespaceTokenAddressToTokenIndex                     = []byte("tatti")
	NamespaceTokenIndexToTokenAddress                     = []byte("titta")
	NamespaceMainchainTokenAddressToSidechainTokenAddress = []byte("mtatst")
	NamespaceAccountAddressToKey                          = []byte("aatk")
	NamespaceLastKey                                      = []byte("lk")
	NamespaceKeyToAccountInfo                             = []byte("ktai")
	NamespaceRollupBlockNumber                            = []byte("rbn")
	EmptyKey                                              = []byte{}
	Separator                                             = []byte("|")
)

Functions

func ConvNilToBytes

func ConvNilToBytes(byteArray []byte) []byte

func PrependNamespace

func PrependNamespace(namespace []byte, key []byte) []byte

Types

type Bulk

type Bulk interface {
	Set(namespace []byte, key []byte, value []byte) error
	Delete(namespace []byte, key []byte) error
	Flush() error
	DiscardLast()
}

Bulk is used to batch multiple transactions This will internally commit transactions when reach maximum tx size

type DB

type DB interface {
	Type() string
	Set(namespace []byte, key []byte, value []byte) error
	Delete(namespace []byte, key []byte) error
	Get(namespace []byte, key []byte) ([]byte, bool, error)
	Exist(namespace []byte, key []byte) (bool, error)
	Iterator(start []byte, end []byte) Iterator
	NewTx() Transaction
	NewBulk() Bulk
	Close() error
}

DB is an general interface to access at storage data

type Iterator

type Iterator interface {
	Next() error
	Valid() bool
	Key() ([]byte, error)
	Value() ([]byte, error)
}

Iterator is used to navigate specific key ranges

type Transaction

type Transaction interface {
	Set(namespace []byte, key []byte, value []byte) error
	Delete(namespace []byte, key []byte) error
	Commit() error
	Discard()
}

Transaction is used to batch multiple operations

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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