basic

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2019 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const IdealBatchSize = 100 * 1024

Code using batches should try to add this much data to the batch. The value was determined empirically.

Variables

View Source
var (
	ErrLDBNil = errors.New("LDB nil")
)
View Source
var OpenFileLimit = 64

Functions

func Close

func Close()

Close close LDatabase

func CurrentBlockNum

func CurrentBlockNum() *big.Int

CurrentBlockNum get current block num.

func GetContractTransaction

func GetContractTransaction(txHash string) (*types.LKTransaction, error)

GetContractTransaction read Contract Transaction

func GetLKTransaction

func GetLKTransaction(txType, txHash string) ([]*types.LKTransaction, error)

GetLKTransaction get internal Transaction.

func GetLKTransactionsByBlock

func GetLKTransactionsByBlock(txType string, num *big.Int) ([]*types.LKTransaction, error)

GetLKTransactionsByBlock get internal Transaction by Block number.

func GetSuicideTransaction

func GetSuicideTransaction(txHash string) (*types.LKTransaction, error)

GetSuicideTransaction query SuicideTransaction

func Init

func Init(file string) error

Init NewLDatabase

func PutLKTransaction

func PutLKTransaction(lkx *types.LKTransaction) error

PutLKTransaction put internal Transaction.

func UpdateBlockNum

func UpdateBlockNum(num *big.Int)

UpdateBlockNum Update BlockNum for db record after BeginBlock.

Types

type Batch

type Batch interface {
	Putter
	ValueSize() int // amount of data in the batch
	Write() error
}

Batch is a write-only database that commits changes to its host database when Write is called. Batch cannot be used concurrently.

func NewTableBatch

func NewTableBatch(db Database, prefix string) Batch

NewTableBatch returns a Batch object which prefixes all keys with a given string.

type Database

type Database interface {
	Putter
	Get(key []byte) ([]byte, error)
	Has(key []byte) (bool, error)
	Delete(key []byte) error
	Close()
	NewBatch() Batch
}

Database wraps all database operations. All methods are safe for concurrent use.

func NewTable

func NewTable(db Database, prefix string) Database

NewTable returns a Database object that prefixes all keys with a given string.

type EthTransactionGas

type EthTransactionGas struct {
	GasLimit *big.Int `json:"gas_limit"`
	GasUsed  *big.Int `json:"gas_used"`
	GasPrice *big.Int `json:"gas_price"`
	BlockNum *big.Int `json:"block_num"`

	// Result: 0(success), others(fail, details come with Errmsg field)
	Ret    int    `json:"ret"`
	Errmsg string `json:"errmsg"`
}

func GetEthTransactionGas

func GetEthTransactionGas(txHash string) (*EthTransactionGas, error)

GetEthTransactionGas query Gas Info of Ethereum Transaction.

type LDatabase

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

func NewLDatabase

func NewLDatabase(file string, cache int, handles int) (*LDatabase, error)

NewLDatabase returns a LevelDB wrapped object.

func (*LDatabase) Close

func (db *LDatabase) Close()

func (*LDatabase) Delete

func (db *LDatabase) Delete(key []byte) error

Delete deletes the key from the queue and database

func (*LDatabase) Get

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

Get returns the given key if it's present.

func (*LDatabase) Has

func (db *LDatabase) Has(key []byte) (bool, error)

func (*LDatabase) LDB

func (db *LDatabase) LDB() *leveldb.DB

func (*LDatabase) NewBatch

func (db *LDatabase) NewBatch() Batch

func (*LDatabase) NewIterator

func (db *LDatabase) NewIterator() iterator.Iterator

func (*LDatabase) Path

func (db *LDatabase) Path() string

Path returns the path to the database directory.

func (*LDatabase) Put

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

Put puts the given key / value to the queue

type Putter

type Putter interface {
	Put(key []byte, value []byte) error
}

Putter wraps the database write operation supported by both batches and regular databases.

type TxBatch

type TxBatch struct {
	Err error // record vm error.
	// contains filtered or unexported fields
}

func BeginBatch

func BeginBatch() *TxBatch

func (*TxBatch) Cancel

func (tb *TxBatch) Cancel()

func (*TxBatch) Commit

func (tb *TxBatch) Commit() error

Commit commit all the internal transactions.

func (*TxBatch) Put

func (tb *TxBatch) Put(lkx *types.LKTransaction) error

Put put lkx to batch, call CommitBatch when we has done.

Jump to

Keyboard shortcuts

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