storage

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2021 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package storage is storage module of all chains

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockData

type BlockData struct {
	// block hash
	BlockHash []byte
	// serialized block header
	SerializedHeader []byte
}

BlockData contains block hash and serialized block header for committing to db

func NewBlockData

func NewBlockData(blockHash []byte, serializedHeader []byte) *BlockData

NewBlockData creates BlockData

type StateDB

type StateDB interface {
	// CommitBlockDataAndTxData commits block data and transaction data in an atomic operation
	CommitBlockDataAndTxData(chainId string, height uint64, blockData *BlockData, txData *TransactionData) error

	// GetBlockHeaderByHeight returns the serialized block header given it's height, or returns nil if none exists
	GetBlockHeaderByHeight(chainId string, height uint64) ([]byte, bool)

	// GetBlockHeaderAndHeightByHash returns the serialized block header and height given it's block hash,
	// or returns nil if none exists
	GetBlockHeaderAndHeightByHash(chainId string, blockHash []byte) ([]byte, uint64, bool)

	// GetLastCommittedBlockHeaderAndHeight returns the last committed block header,or returns nil if none exists
	GetLastCommittedBlockHeaderAndHeight(chainId string) ([]byte, uint64, bool)

	// GetTransactionHashAndHeightByTxKey returns transaction hash and block height by txId, or returns nil if none exists
	GetTransactionHashAndHeightByTxKey(chainId string, txKey string) ([]byte, uint64, bool)

	// GetTransactionByTxKey returns transaction bytes by txId, or returns nil if none exists
	GetTransactionByTxKey(chainId string, txKey string) ([]byte, bool)

	// GetTxExtraDataByTxKey returns transaction extra data by txId, or returns nil if none exists
	GetTxExtraDataByTxKey(chainId string, txKey string) ([]byte, bool)

	// GetTransactionTotalNum returns the total num of transactions, or returns -1 if none exists
	GetTransactionTotalNum(chainId string) (uint64, bool)

	// WriteChainConfig put the chain config to db
	WriteChainConfig(chainId string, chainConfig []byte) error

	// GetChainConfig returns chain config, or returns nil if none exists
	GetChainConfig(chainId string) ([]byte, bool)

	// Close is used to close database
	Close()
}

StateDB defines storage interface

type TransactionData

type TransactionData struct {
	// map[TxId] = TxHash
	TxHashMap map[string][]byte
	// map[TxId] = TxBytes
	TxBytesMap map[string][]byte
	// map[TxId] = TxExtraDataBytes
	ExtraDataMap map[string][]byte
}

TransactionData contains TxHashMap TxBytesMap and ExtraDataMap for committing to db

func NewTransactionData

func NewTransactionData() *TransactionData

NewTransactionData creates TransactionData

Directories

Path Synopsis
Package kvdb is kvdb module
Package kvdb is kvdb module
leveldb
Package leveldb is leveldb module
Package leveldb is leveldb module

Jump to

Keyboard shortcuts

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