store

package module
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2021 License: Apache-2.0 Imports: 47 Imported by: 1

Documentation

Index

Constants

View Source
const (
	//StoreBlockDBDir blockdb folder name
	StoreBlockDBDir = "store_block"
	//StoreStateDBDir statedb folder name
	StoreStateDBDir = "store_state"
	//StoreHistoryDBDir historydb folder name
	StoreHistoryDBDir = "store_history"
	//StoreResultDBDir resultdb folder name
	StoreResultDBDir   = "store_result"
	StoreEventLogDBDir = "store_event_log"
	StoreLocalDBDir    = "localdb"
	DBName_BlockDB     = "blockdb"
	DBName_StateDB     = "statedb"
	DBName_HistoryDB   = "historydb"
	DBName_ResultDB    = "resultdb"
	DBName_EventDB     = "eventdb"
	DBName_LocalDB     = "localdb"
)

Variables

This section is empty.

Functions

func NewAsyncBlockStoreImpl

func NewAsyncBlockStoreImpl(blockStoreImpl protocol.BlockchainStore, logger protocol.Logger) protocol.BlockchainStore

Types

type AsyncBlockStoreImpl

type AsyncBlockStoreImpl struct {
	protocol.BlockchainStore
	// contains filtered or unexported fields
}

AsyncBlockStoreImpl Asynchronous storage of block data.

func (*AsyncBlockStoreImpl) GetBlock

func (async *AsyncBlockStoreImpl) GetBlock(height uint64) (*commonPb.Block, error)

GetBlock returns a block given its block height, or returns nil if none exists.

func (*AsyncBlockStoreImpl) PutBlock

func (async *AsyncBlockStoreImpl) PutBlock(block *commonPb.Block, txRWSets []*commonPb.TxRWSet) error

PutBlock Asynchronous storage of block data. The block data will be cached and stored by idle working GO routines later. Note: Concurrent calls are not allowed

type BlockStoreImpl

type BlockStoreImpl struct {
	ArchiveMgr *archive.ArchiveMgr
	// contains filtered or unexported fields
}

BlockStoreImpl provides an implementation of `protocol.BlockchainStore`.

func NewBlockStoreImpl

func NewBlockStoreImpl(chainId string,
	storeConfig *conf.StorageConfig,
	blockDB blockdb.BlockDB,
	stateDB statedb.StateDB,
	historyDB historydb.HistoryDB,
	contractEventDB contracteventdb.ContractEventDB,
	resultDB resultdb.ResultDB,
	commonDB protocol.DBHandle,
	binLog binlog.BinLogger,
	logger protocol.Logger) (*BlockStoreImpl, error)

NewBlockStoreImpl constructs new `BlockStoreImpl`

func (*BlockStoreImpl) ArchiveBlock

func (bs *BlockStoreImpl) ArchiveBlock(archiveHeight uint64) error

ArchiveBlock the block after backup

func (*BlockStoreImpl) BeginDbTransaction

func (bs *BlockStoreImpl) BeginDbTransaction(txName string) (protocol.SqlDBTransaction, error)

BeginDbTransaction 启用一个事务

func (*BlockStoreImpl) BlockExists

func (bs *BlockStoreImpl) BlockExists(blockHash []byte) (bool, error)

BlockExists returns true if the black hash exist, or returns false if none exists.

func (*BlockStoreImpl) Close

func (bs *BlockStoreImpl) Close() error

Close is used to close database

func (*BlockStoreImpl) CommitDbTransaction

func (bs *BlockStoreImpl) CommitDbTransaction(txName string) error

CommitDbTransaction 提交一个事务

func (*BlockStoreImpl) CreateDatabase

func (bs *BlockStoreImpl) CreateDatabase(contractName string) error

func (*BlockStoreImpl) DropDatabase

func (bs *BlockStoreImpl) DropDatabase(contractName string) error

DropDatabase 删除一个合约对应的数据库

func (*BlockStoreImpl) ExecDdlSql

func (bs *BlockStoreImpl) ExecDdlSql(contractName, sql, version string) error

ExecDdlSql execute DDL SQL in a contract

func (*BlockStoreImpl) GetAccountTxHistory

func (bs *BlockStoreImpl) GetAccountTxHistory(accountId []byte) (protocol.TxHistoryIterator, error)

func (*BlockStoreImpl) GetArchivedPivot

func (bs *BlockStoreImpl) GetArchivedPivot() uint64

GetArchivedPivot return archived pivot

func (*BlockStoreImpl) GetBlock

func (bs *BlockStoreImpl) GetBlock(height uint64) (*commonPb.Block, error)

GetBlock returns a block given it's block height, or returns nil if none exists.

func (*BlockStoreImpl) GetBlockByHash

func (bs *BlockStoreImpl) GetBlockByHash(blockHash []byte) (*commonPb.Block, error)

GetBlockByHash returns a block given it's hash, or returns nil if none exists.

func (*BlockStoreImpl) GetBlockByTx

func (bs *BlockStoreImpl) GetBlockByTx(txId string) (*commonPb.Block, error)

GetBlockByTx returns a block which contains a tx.

func (*BlockStoreImpl) GetBlockHeaderByHeight

func (bs *BlockStoreImpl) GetBlockHeaderByHeight(height uint64) (*commonPb.BlockHeader, error)

GetBlockHeaderByHeight returns a block header by given it's height, or returns nil if none exists.

func (*BlockStoreImpl) GetBlockWithRWSets

func (bs *BlockStoreImpl) GetBlockWithRWSets(height uint64) (*storePb.BlockWithRWSet, error)

GetBlockWithRWSets returns the block and all the rwsets corresponding to the block, or returns nil if zhe block does not exist

func (*BlockStoreImpl) GetContractByName

func (bs *BlockStoreImpl) GetContractByName(name string) (*commonPb.Contract, error)

func (*BlockStoreImpl) GetContractBytecode

func (bs *BlockStoreImpl) GetContractBytecode(name string) ([]byte, error)

func (*BlockStoreImpl) GetContractDbName

func (bs *BlockStoreImpl) GetContractDbName(contractName string) string

GetContractDbName 获得一个合约对应的状态数据库名

func (*BlockStoreImpl) GetContractTxHistory

func (bs *BlockStoreImpl) GetContractTxHistory(contractName string) (protocol.TxHistoryIterator, error)

func (*BlockStoreImpl) GetDBHandle

func (bs *BlockStoreImpl) GetDBHandle(dbName string) protocol.DBHandle

GetDBHandle returns the database handle for given dbName(chainId)

func (*BlockStoreImpl) GetDbTransaction

func (bs *BlockStoreImpl) GetDbTransaction(txName string) (protocol.SqlDBTransaction, error)

GetDbTransaction 根据事务名,获得一个已经启用的事务

func (*BlockStoreImpl) GetHeightByHash

func (bs *BlockStoreImpl) GetHeightByHash(blockHash []byte) (uint64, error)

GetHeightByHash returns a block height given it's hash, or returns nil if none exists.

func (*BlockStoreImpl) GetHistoryForKey

func (bs *BlockStoreImpl) GetHistoryForKey(contractName string, key []byte) (protocol.KeyHistoryIterator, error)

func (*BlockStoreImpl) GetLastBlock

func (bs *BlockStoreImpl) GetLastBlock() (*commonPb.Block, error)

GetLastBlock returns the last block.

func (*BlockStoreImpl) GetLastChainConfig

func (bs *BlockStoreImpl) GetLastChainConfig() (*configPb.ChainConfig, error)

GetLastChainConfig returns the last chain config

func (*BlockStoreImpl) GetLastConfigBlock

func (bs *BlockStoreImpl) GetLastConfigBlock() (*commonPb.Block, error)

GetLastConfigBlock returns the last config block.

func (*BlockStoreImpl) GetMemberExtraData

func (bs *BlockStoreImpl) GetMemberExtraData(member *accesscontrol.Member) (*accesscontrol.MemberExtraData, error)

func (*BlockStoreImpl) GetTx

func (bs *BlockStoreImpl) GetTx(txId string) (*commonPb.Transaction, error)

GetTx retrieves a transaction by txid, or returns nil if none exists.

func (*BlockStoreImpl) GetTxConfirmedTime

func (bs *BlockStoreImpl) GetTxConfirmedTime(txId string) (int64, error)

GetTxConfirmedTime returns the confirmed time of a given tx

func (*BlockStoreImpl) GetTxHeight

func (bs *BlockStoreImpl) GetTxHeight(txId string) (uint64, error)

GetTxHeight retrieves a transaction height by txid, or returns nil if none exists.

func (*BlockStoreImpl) GetTxRWSet

func (bs *BlockStoreImpl) GetTxRWSet(txId string) (*commonPb.TxRWSet, error)

GetTxRWSet returns an txRWSet for given txId, or returns nil if none exists.

func (*BlockStoreImpl) GetTxRWSetsByHeight

func (bs *BlockStoreImpl) GetTxRWSetsByHeight(height uint64) ([]*commonPb.TxRWSet, error)

GetTxRWSetsByHeight returns all the rwsets corresponding to the block, or returns nil if zhe block does not exist

func (*BlockStoreImpl) GetTxWithBlockInfo

func (bs *BlockStoreImpl) GetTxWithBlockInfo(txId string) (*commonPb.TransactionInfo, error)

func (*BlockStoreImpl) InitArchiveMgr

func (bs *BlockStoreImpl) InitArchiveMgr(chainId string) error

func (*BlockStoreImpl) InitGenesis

func (bs *BlockStoreImpl) InitGenesis(genesisBlock *storePb.BlockWithRWSet) error

InitGenesis 初始化创世区块到数据库,对应的数据库必须为空数据库,否则报错

func (*BlockStoreImpl) PutBlock

func (bs *BlockStoreImpl) PutBlock(block *commonPb.Block, txRWSets []*commonPb.TxRWSet) error

PutBlock commits the block and the corresponding rwsets in an atomic operation

func (*BlockStoreImpl) QueryMulti

func (bs *BlockStoreImpl) QueryMulti(contractName, sql string, values ...interface{}) (protocol.SqlRows, error)

QueryMulti 不在事务中,直接查询状态数据库,返回多行结果

func (*BlockStoreImpl) QuerySingle

func (bs *BlockStoreImpl) QuerySingle(contractName, sql string, values ...interface{}) (protocol.SqlRow, error)

QuerySingle 不在事务中,直接查询状态数据库,返回一行结果

func (*BlockStoreImpl) ReadObject

func (bs *BlockStoreImpl) ReadObject(contractName string, key []byte) ([]byte, error)

ReadObject returns the state value for given contract name and key, or returns nil if none exists.

func (*BlockStoreImpl) RestoreBlocks

func (bs *BlockStoreImpl) RestoreBlocks(serializedBlocks [][]byte) error

RestoreBlocks restore blocks from outside serialized block data

func (*BlockStoreImpl) RollbackDbTransaction

func (bs *BlockStoreImpl) RollbackDbTransaction(txName string) error

RollbackDbTransaction 回滚一个事务

func (*BlockStoreImpl) SelectObject

func (bs *BlockStoreImpl) SelectObject(contractName string, startKey []byte, limit []byte) (
	protocol.StateIterator, error)

SelectObject returns an iterator that contains all the key-values between given key ranges. startKey is included in the results and limit is excluded.

func (*BlockStoreImpl) TxExists

func (bs *BlockStoreImpl) TxExists(txId string) (bool, error)

TxExists returns true if the tx exist, or returns false if none exists.

func (*BlockStoreImpl) WriteBatchToDB

func (bs *BlockStoreImpl) WriteBatchToDB()

type Factory

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

Factory is a factory function to create an instance of the block store which commits block into the ledger.

func NewFactory

func NewFactory() *Factory

func (*Factory) NewStore

func (m *Factory) NewStore(chainId string, storeConfig *conf.StorageConfig,
	logger protocol.Logger, p11Handle *pkcs11.P11Handle) (protocol.BlockchainStore, error)

NewStore constructs new BlockStore

Jump to

Keyboard shortcuts

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