dbstore

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LastHashKey    = "lh" // Last hash key ( lastHash -> hash)
	HashesKey      = "hs" // Hashes key (hash->block)
	BlockNumberKey = "bn" // Block number key (blockNumber -> hash)
	BalanceKey     = "bl" // Balance key (address -> balance)
	NonceKey       = "nc" // Nonce key (address -> nonce)
)

Variables

This section is empty.

Functions

func PrefixKey

func PrefixKey(prefix string, str string) string

PrefixKey prefixes a string with another string.

Types

type BlockchainDB

type BlockchainDB struct {
	DB *DB
}

func NewBlockchainDB

func NewBlockchainDB(db *DB) *BlockchainDB

func (*BlockchainDB) GetBlockByHash

func (bdb *BlockchainDB) GetBlockByHash(hash *util.Hash) (*types.Block, error)

func (*BlockchainDB) GetBlockByNumber added in v1.1.0

func (bdb *BlockchainDB) GetBlockByNumber(number *big.Int) (*types.Block, error)

func (*BlockchainDB) GetBlocksInRange

func (bdb *BlockchainDB) GetBlocksInRange(start uint, end uint) ([]*types.Block, error)

func (*BlockchainDB) GetLatestBlock

func (bdb *BlockchainDB) GetLatestBlock() (*types.Block, error)

type DB

type DB struct {
	LevelDb *leveldb.DB
	// contains filtered or unexported fields
}

DB is a wrapper around leveldb.

func NewDBInstance

func NewDBInstance(dbPath string) (*DB, error)

NewDB creates a new DB instance.

func (*DB) Close

func (db *DB) Close() error

Close closes the db.

func (*DB) Delete

func (db *DB) Delete(key string) error

Delete deletes the value for the given key.

func (*DB) Get

func (db *DB) Get(key string) ([]byte, error)

Get returns the value for the given key.

func (*DB) Has

func (db *DB) Has(key string) (bool, error)

Has returns true if the given key exists.

func (*DB) NewBatch

func (db *DB) NewBatch() *leveldb.Batch

NewBatch creates a new batch.

func (*DB) Put

func (db *DB) Put(key string, value []byte) error

Put sets the value for the given key.

func (*DB) WriteBatch

func (db *DB) WriteBatch(batch *leveldb.Batch) error

WriteBatch writes a batch to the db.

type StateDB

type StateDB struct {
	DB *DB
}

func NewStateDB

func NewStateDB(db *DB) *StateDB

Jump to

Keyboard shortcuts

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