storage

package
v0.0.0-...-84d53aa Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2019 License: GPL-3.0 Imports: 8 Imported by: 18

Documentation

Overview

Package storage implements Backend for BlockChain State

Index

Constants

This section is empty.

Variables

View Source
var ErrKeyNotFound = errors.New("not found")

ErrKeyNotFound entry not found error.

Functions

This section is empty.

Types

type LeveldbStorage

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

LeveldbStorage storage which backend is leveldb

func NewLeveldbStorage

func NewLeveldbStorage(path string) (*LeveldbStorage, error)

NewLeveldbStorage init a LeveldbStorage

func (*LeveldbStorage) Close

func (storage *LeveldbStorage) Close() error

Close closes leveldb storage

func (*LeveldbStorage) Delete

func (storage *LeveldbStorage) Delete(key []byte) error

Delete delete the key entry in Storage.

func (*LeveldbStorage) DisableBatch

func (storage *LeveldbStorage) DisableBatch()

DisableBatch disable batch write.

func (*LeveldbStorage) EnableBatch

func (storage *LeveldbStorage) EnableBatch()

EnableBatch enable batch write.

func (*LeveldbStorage) Flush

func (storage *LeveldbStorage) Flush() error

Flush write and flush pending batch write.

func (*LeveldbStorage) Get

func (storage *LeveldbStorage) Get(key []byte) ([]byte, error)

Get return the value to the key in Storage.

func (*LeveldbStorage) Put

func (storage *LeveldbStorage) Put(key []byte, value []byte) error

Put put the key-value entry to Storage.

type MemoryStorage

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

MemoryStorage memory storage

func NewMemoryStorage

func NewMemoryStorage() (*MemoryStorage, error)

NewMemoryStorage init a storage

func (*MemoryStorage) Close

func (s *MemoryStorage) Close() error

Close closes memory storage

func (*MemoryStorage) Delete

func (s *MemoryStorage) Delete(key []byte) error

Delete delete the key entry in Storage.

func (*MemoryStorage) DisableBatch

func (s *MemoryStorage) DisableBatch()

DisableBatch disable batch write.

func (*MemoryStorage) EnableBatch

func (s *MemoryStorage) EnableBatch()

EnableBatch enable batch write.

func (*MemoryStorage) Flush

func (s *MemoryStorage) Flush() error

Flush write and flush pending batch write.

func (*MemoryStorage) Get

func (s *MemoryStorage) Get(key []byte) ([]byte, error)

Get return the value to the key in Storage.

func (*MemoryStorage) Len

func (s *MemoryStorage) Len() int

Len returns number of keys in memory storage

func (*MemoryStorage) Put

func (s *MemoryStorage) Put(key []byte, value []byte) error

Put put the key-value entry to Storage.

type RocksStorage

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

RocksStorage the nodes in trie.

func NewRocksStorage

func NewRocksStorage(path string) (*RocksStorage, error)

NewRocksStorage init a storage

func (*RocksStorage) Close

func (storage *RocksStorage) Close() error

Close levelDB

func (*RocksStorage) Delete

func (storage *RocksStorage) Delete(key []byte) error

Delete delete the key in Storage.

func (*RocksStorage) DisableBatch

func (storage *RocksStorage) DisableBatch()

DisableBatch disable batch write.

func (*RocksStorage) EnableBatch

func (storage *RocksStorage) EnableBatch()

EnableBatch enable batch write.

func (*RocksStorage) Flush

func (storage *RocksStorage) Flush() error

Flush write and flush pending batch write.

func (*RocksStorage) Get

func (storage *RocksStorage) Get(key []byte) ([]byte, error)

Get return value to the key in Storage

func (*RocksStorage) Put

func (storage *RocksStorage) Put(key []byte, value []byte) error

Put put the key-value entry to Storage

type Storage

type Storage interface {
	// Delete delete the key entry in Storage.
	Delete(key []byte) error

	// Get return the value to the key in Storage.
	Get(key []byte) ([]byte, error)

	// Put put the key-value entry to Storage.
	Put(key []byte, value []byte) error

	// EnableBatch enables batch write.
	EnableBatch()

	// DisableBatch disables batch write.
	DisableBatch()

	// Flush writes pending batch write.
	Flush() error

	// Close closes storage
	Close() error
}

Storage interface of Storage.

Jump to

Keyboard shortcuts

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