blockdb

package
v2.3.6 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

README

区块链数据库

区块头数据

将Header转换为blockinfo进行存储

交易数据

将Transaction转换为TxInfo进行存储

SQLDB 存储

数据库名为 chainId+"_blockdb"

Documentation

Overview

Package blockdb implement

Package blockdb is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockDB

type BlockDB interface {

	// InitGenesis 完成创世区块的写入
	//  @Description:
	//  @param genesisBlock
	//  @return error
	InitGenesis(genesisBlock *serialization.BlockWithSerializedInfo) error

	// CommitBlock commits the block and the corresponding rwsets in an atomic operation
	//  @Description:
	//  @param blockInfo
	//  @param isCache
	//  @return error
	CommitBlock(blockInfo *serialization.BlockWithSerializedInfo, isCache bool) error

	// BlockExists returns true if the block hash exist, or returns false if none exists.
	//  @Description:
	//  @param blockHash
	//  @return bool
	//  @return error
	BlockExists(blockHash []byte) (bool, error)

	// GetBlockByHash returns a block given its hash, or returns nil if none exists.
	//  @Description:
	//  @param blockHash
	//  @return *commonPb.Block
	//  @return error
	GetBlockByHash(blockHash []byte) (*commonPb.Block, error)

	// GetHeightByHash returns a block height given it's hash, or returns nil if none exists.
	//  @Description:
	//  @param blockHash
	//  @return uint64
	//  @return error
	GetHeightByHash(blockHash []byte) (uint64, error)

	// GetBlockHeaderByHeight returns a block header by given it's height, or returns nil if none exists.
	//  @Description:
	//  @param height
	//  @return *commonPb.BlockHeader
	//  @return error
	GetBlockHeaderByHeight(height uint64) (*commonPb.BlockHeader, error)

	// GetBlock returns a block given it's block height, or returns nil if none exists.
	//  @Description:
	//  @param height
	//  @return *commonPb.Block
	//  @return error
	GetBlock(height uint64) (*commonPb.Block, error)

	// GetTx retrieves a transaction by txid, or returns nil if none exists.
	//  @Description:
	//  @param txId
	//  @return *commonPb.Transaction
	//  @return error
	GetTx(txId string) (*commonPb.Transaction, error)

	// GetTxWithBlockInfo retrieves a transaction info by txid, or returns nil if none exists.
	//  @Description:
	//  @param txId
	//  @return *storePb.TransactionStoreInfo
	//  @return error
	GetTxWithBlockInfo(txId string) (*storePb.TransactionStoreInfo, error)

	// GetTxInfoOnly 获得除Tx之外的其他TxInfo信息
	//  @Description:
	//  @param txId
	//  @return *storePb.TransactionStoreInfo
	//  @return error
	GetTxInfoOnly(txId string) (*storePb.TransactionStoreInfo, error)

	// GetTxHeight retrieves a transaction height by txid, or returns nil if none exists.
	//  @Description:
	//  @param txId
	//  @return uint64
	//  @return error
	GetTxHeight(txId string) (uint64, error)

	// TxExists returns true if the tx exist, or returns false if none exists.
	//  @Description:
	//  @param txId
	//  @return bool
	//  @return error
	TxExists(txId string) (bool, error)

	// TxArchived returns true if the tx archived, or returns false.
	//  @Description:
	//  @param txId
	//  @return bool
	//  @return error
	TxArchived(txId string) (bool, error)

	// GetTxConfirmedTime retrieves time of the tx confirmed in the blockChain
	//  @Description:
	//  @param txId
	//  @return int64
	//  @return error
	GetTxConfirmedTime(txId string) (int64, error)

	// GetLastBlock returns the last block.
	//  @Description:
	//  @return *commonPb.Block
	//  @return error
	GetLastBlock() (*commonPb.Block, error)

	// GetFilteredBlock returns a filtered block given its block height, or return nil if none exists.
	//  @Description:
	//  @param height
	//  @return *storePb.SerializedBlock
	//  @return error
	GetFilteredBlock(height uint64) (*storePb.SerializedBlock, error)

	// GetLastSavepoint returns the last block height
	//  @Description:
	//  @return uint64
	//  @return error
	GetLastSavepoint() (uint64, error)

	// GetLastConfigBlock returns the last config block.
	//  @Description:
	//  @return *commonPb.Block
	//  @return error
	GetLastConfigBlock() (*commonPb.Block, error)

	// GetLastConfigBlockHeight returns the last config block height.
	//  @Description:
	//  @return uint64
	//  @return error
	GetLastConfigBlockHeight() (uint64, error)

	// GetBlockByTx returns a block which contains a tx.如果查询不到,则返回nil,nil
	//  @Description:
	//  @param txId
	//  @return *commonPb.Block
	//  @return error
	GetBlockByTx(txId string) (*commonPb.Block, error)

	// GetArchivedPivot get archived pivot
	//  @Description:
	//  @return uint64
	//  @return error
	GetArchivedPivot() (uint64, error)

	// ShrinkBlocks
	//  @Description: archive old blocks in an atomic operation
	//  @param startHeight
	//  @param endHeight
	//  @param bfdbPath
	//  @return map[uint64][]string
	//  @return error
	ShrinkBlocks(startHeight uint64, endHeight uint64, bfdbPath string) (map[uint64][]string, error)

	// RestoreBlocks
	//  @Description: restore blocks from outside block data in an atomic operation
	//  @param blockInfos
	//  @return error
	RestoreBlocks(blockInfos []*serialization.BlockWithSerializedInfo) error

	// GetBlockMetaIndex
	//  @Description: returns the offset of the block metadata in the file
	//  @param height
	//  @return *storePb.StoreInfo
	//  @return error
	GetBlockMetaIndex(height uint64) (*storePb.StoreInfo, error)

	// GetTxIndex
	//  @Description: returns the offset of the transaction in the file
	//  @param txId
	//  @return *storePb.StoreInfo
	//  @return error
	GetTxIndex(txId string) (*storePb.StoreInfo, error)

	// GetBlockIndex
	//  @Description: returns the offset of the transaction in the file
	//  @param height
	//  @return *storePb.StoreInfo
	//  @return error
	GetBlockIndex(height uint64) (*storePb.StoreInfo, error)

	// GetDbType add next time
	// @Description:
	// @return string
	GetDbType() string

	// CompactRange fo kvdb compact action
	// @Description:
	// @return error
	CompactRange() error

	// Close
	//  @Description: Close is used to close database
	Close()
}

BlockDB provides handle to block and tx instances

type MockBlockDB added in v2.3.0

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

MockBlockDB is a mock of BlockDB interface.

func NewMockBlockDB added in v2.3.0

func NewMockBlockDB(ctrl *gomock.Controller) *MockBlockDB

NewMockBlockDB creates a new mock instance.

func (*MockBlockDB) BlockExists added in v2.3.0

func (m *MockBlockDB) BlockExists(blockHash []byte) (bool, error)

BlockExists mocks base method.

func (*MockBlockDB) Close added in v2.3.0

func (m *MockBlockDB) Close()

Close mocks base method.

func (*MockBlockDB) CommitBlock added in v2.3.0

func (m *MockBlockDB) CommitBlock(blockInfo *serialization.BlockWithSerializedInfo, isCache bool) error

CommitBlock mocks base method.

func (*MockBlockDB) CompactRange added in v2.3.4

func (m *MockBlockDB) CompactRange() error

CompactRange mocks base method.

func (*MockBlockDB) EXPECT added in v2.3.0

func (m *MockBlockDB) EXPECT() *MockBlockDBMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockBlockDB) GetArchivedPivot added in v2.3.0

func (m *MockBlockDB) GetArchivedPivot() (uint64, error)

GetArchivedPivot mocks base method.

func (*MockBlockDB) GetBlock added in v2.3.0

func (m *MockBlockDB) GetBlock(height uint64) (*common.Block, error)

GetBlock mocks base method.

func (*MockBlockDB) GetBlockByHash added in v2.3.0

func (m *MockBlockDB) GetBlockByHash(blockHash []byte) (*common.Block, error)

GetBlockByHash mocks base method.

func (*MockBlockDB) GetBlockByTx added in v2.3.0

func (m *MockBlockDB) GetBlockByTx(txId string) (*common.Block, error)

GetBlockByTx mocks base method.

func (*MockBlockDB) GetBlockHeaderByHeight added in v2.3.0

func (m *MockBlockDB) GetBlockHeaderByHeight(height uint64) (*common.BlockHeader, error)

GetBlockHeaderByHeight mocks base method.

func (*MockBlockDB) GetBlockIndex added in v2.3.0

func (m *MockBlockDB) GetBlockIndex(height uint64) (*store.StoreInfo, error)

GetBlockIndex mocks base method.

func (*MockBlockDB) GetBlockMetaIndex added in v2.3.0

func (m *MockBlockDB) GetBlockMetaIndex(height uint64) (*store.StoreInfo, error)

GetBlockMetaIndex mocks base method.

func (*MockBlockDB) GetDbType added in v2.3.4

func (m *MockBlockDB) GetDbType() string

GetDbType mocks base method.

func (*MockBlockDB) GetFilteredBlock added in v2.3.0

func (m *MockBlockDB) GetFilteredBlock(height uint64) (*store.SerializedBlock, error)

GetFilteredBlock mocks base method.

func (*MockBlockDB) GetHeightByHash added in v2.3.0

func (m *MockBlockDB) GetHeightByHash(blockHash []byte) (uint64, error)

GetHeightByHash mocks base method.

func (*MockBlockDB) GetLastBlock added in v2.3.0

func (m *MockBlockDB) GetLastBlock() (*common.Block, error)

GetLastBlock mocks base method.

func (*MockBlockDB) GetLastConfigBlock added in v2.3.0

func (m *MockBlockDB) GetLastConfigBlock() (*common.Block, error)

GetLastConfigBlock mocks base method.

func (*MockBlockDB) GetLastConfigBlockHeight added in v2.3.0

func (m *MockBlockDB) GetLastConfigBlockHeight() (uint64, error)

GetLastConfigBlockHeight mocks base method.

func (*MockBlockDB) GetLastSavepoint added in v2.3.0

func (m *MockBlockDB) GetLastSavepoint() (uint64, error)

GetLastSavepoint mocks base method.

func (*MockBlockDB) GetTx added in v2.3.0

func (m *MockBlockDB) GetTx(txId string) (*common.Transaction, error)

GetTx mocks base method.

func (*MockBlockDB) GetTxConfirmedTime added in v2.3.0

func (m *MockBlockDB) GetTxConfirmedTime(txId string) (int64, error)

GetTxConfirmedTime mocks base method.

func (*MockBlockDB) GetTxHeight added in v2.3.0

func (m *MockBlockDB) GetTxHeight(txId string) (uint64, error)

GetTxHeight mocks base method.

func (*MockBlockDB) GetTxIndex added in v2.3.0

func (m *MockBlockDB) GetTxIndex(txId string) (*store.StoreInfo, error)

GetTxIndex mocks base method.

func (*MockBlockDB) GetTxInfoOnly added in v2.3.0

func (m *MockBlockDB) GetTxInfoOnly(txId string) (*store.TransactionStoreInfo, error)

GetTxInfoOnly mocks base method.

func (*MockBlockDB) GetTxWithBlockInfo added in v2.3.0

func (m *MockBlockDB) GetTxWithBlockInfo(txId string) (*store.TransactionStoreInfo, error)

GetTxWithBlockInfo mocks base method.

func (*MockBlockDB) InitGenesis added in v2.3.0

func (m *MockBlockDB) InitGenesis(genesisBlock *serialization.BlockWithSerializedInfo) error

InitGenesis mocks base method.

func (*MockBlockDB) RestoreBlocks added in v2.3.0

func (m *MockBlockDB) RestoreBlocks(blockInfos []*serialization.BlockWithSerializedInfo) error

RestoreBlocks mocks base method.

func (*MockBlockDB) ShrinkBlocks added in v2.3.0

func (m *MockBlockDB) ShrinkBlocks(startHeight, endHeight uint64, bfdbPath string) (map[uint64][]string, error)

ShrinkBlocks mocks base method.

func (*MockBlockDB) TxArchived added in v2.3.0

func (m *MockBlockDB) TxArchived(txId string) (bool, error)

TxArchived mocks base method.

func (*MockBlockDB) TxExists added in v2.3.0

func (m *MockBlockDB) TxExists(txId string) (bool, error)

TxExists mocks base method.

type MockBlockDBMockRecorder added in v2.3.0

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

MockBlockDBMockRecorder is the mock recorder for MockBlockDB.

func (*MockBlockDBMockRecorder) BlockExists added in v2.3.0

func (mr *MockBlockDBMockRecorder) BlockExists(blockHash interface{}) *gomock.Call

BlockExists indicates an expected call of BlockExists.

func (*MockBlockDBMockRecorder) Close added in v2.3.0

func (mr *MockBlockDBMockRecorder) Close() *gomock.Call

Close indicates an expected call of Close.

func (*MockBlockDBMockRecorder) CommitBlock added in v2.3.0

func (mr *MockBlockDBMockRecorder) CommitBlock(blockInfo, isCache interface{}) *gomock.Call

CommitBlock indicates an expected call of CommitBlock.

func (*MockBlockDBMockRecorder) CompactRange added in v2.3.4

func (mr *MockBlockDBMockRecorder) CompactRange() *gomock.Call

CompactRange indicates an expected call of CompactRange.

func (*MockBlockDBMockRecorder) GetArchivedPivot added in v2.3.0

func (mr *MockBlockDBMockRecorder) GetArchivedPivot() *gomock.Call

GetArchivedPivot indicates an expected call of GetArchivedPivot.

func (*MockBlockDBMockRecorder) GetBlock added in v2.3.0

func (mr *MockBlockDBMockRecorder) GetBlock(height interface{}) *gomock.Call

GetBlock indicates an expected call of GetBlock.

func (*MockBlockDBMockRecorder) GetBlockByHash added in v2.3.0

func (mr *MockBlockDBMockRecorder) GetBlockByHash(blockHash interface{}) *gomock.Call

GetBlockByHash indicates an expected call of GetBlockByHash.

func (*MockBlockDBMockRecorder) GetBlockByTx added in v2.3.0

func (mr *MockBlockDBMockRecorder) GetBlockByTx(txId interface{}) *gomock.Call

GetBlockByTx indicates an expected call of GetBlockByTx.

func (*MockBlockDBMockRecorder) GetBlockHeaderByHeight added in v2.3.0

func (mr *MockBlockDBMockRecorder) GetBlockHeaderByHeight(height interface{}) *gomock.Call

GetBlockHeaderByHeight indicates an expected call of GetBlockHeaderByHeight.

func (*MockBlockDBMockRecorder) GetBlockIndex added in v2.3.0

func (mr *MockBlockDBMockRecorder) GetBlockIndex(height interface{}) *gomock.Call

GetBlockIndex indicates an expected call of GetBlockIndex.

func (*MockBlockDBMockRecorder) GetBlockMetaIndex added in v2.3.0

func (mr *MockBlockDBMockRecorder) GetBlockMetaIndex(height interface{}) *gomock.Call

GetBlockMetaIndex indicates an expected call of GetBlockMetaIndex.

func (*MockBlockDBMockRecorder) GetDbType added in v2.3.4

func (mr *MockBlockDBMockRecorder) GetDbType() *gomock.Call

GetDbType indicates an expected call of GetDbType.

func (*MockBlockDBMockRecorder) GetFilteredBlock added in v2.3.0

func (mr *MockBlockDBMockRecorder) GetFilteredBlock(height interface{}) *gomock.Call

GetFilteredBlock indicates an expected call of GetFilteredBlock.

func (*MockBlockDBMockRecorder) GetHeightByHash added in v2.3.0

func (mr *MockBlockDBMockRecorder) GetHeightByHash(blockHash interface{}) *gomock.Call

GetHeightByHash indicates an expected call of GetHeightByHash.

func (*MockBlockDBMockRecorder) GetLastBlock added in v2.3.0

func (mr *MockBlockDBMockRecorder) GetLastBlock() *gomock.Call

GetLastBlock indicates an expected call of GetLastBlock.

func (*MockBlockDBMockRecorder) GetLastConfigBlock added in v2.3.0

func (mr *MockBlockDBMockRecorder) GetLastConfigBlock() *gomock.Call

GetLastConfigBlock indicates an expected call of GetLastConfigBlock.

func (*MockBlockDBMockRecorder) GetLastConfigBlockHeight added in v2.3.0

func (mr *MockBlockDBMockRecorder) GetLastConfigBlockHeight() *gomock.Call

GetLastConfigBlockHeight indicates an expected call of GetLastConfigBlockHeight.

func (*MockBlockDBMockRecorder) GetLastSavepoint added in v2.3.0

func (mr *MockBlockDBMockRecorder) GetLastSavepoint() *gomock.Call

GetLastSavepoint indicates an expected call of GetLastSavepoint.

func (*MockBlockDBMockRecorder) GetTx added in v2.3.0

func (mr *MockBlockDBMockRecorder) GetTx(txId interface{}) *gomock.Call

GetTx indicates an expected call of GetTx.

func (*MockBlockDBMockRecorder) GetTxConfirmedTime added in v2.3.0

func (mr *MockBlockDBMockRecorder) GetTxConfirmedTime(txId interface{}) *gomock.Call

GetTxConfirmedTime indicates an expected call of GetTxConfirmedTime.

func (*MockBlockDBMockRecorder) GetTxHeight added in v2.3.0

func (mr *MockBlockDBMockRecorder) GetTxHeight(txId interface{}) *gomock.Call

GetTxHeight indicates an expected call of GetTxHeight.

func (*MockBlockDBMockRecorder) GetTxIndex added in v2.3.0

func (mr *MockBlockDBMockRecorder) GetTxIndex(txId interface{}) *gomock.Call

GetTxIndex indicates an expected call of GetTxIndex.

func (*MockBlockDBMockRecorder) GetTxInfoOnly added in v2.3.0

func (mr *MockBlockDBMockRecorder) GetTxInfoOnly(txId interface{}) *gomock.Call

GetTxInfoOnly indicates an expected call of GetTxInfoOnly.

func (*MockBlockDBMockRecorder) GetTxWithBlockInfo added in v2.3.0

func (mr *MockBlockDBMockRecorder) GetTxWithBlockInfo(txId interface{}) *gomock.Call

GetTxWithBlockInfo indicates an expected call of GetTxWithBlockInfo.

func (*MockBlockDBMockRecorder) InitGenesis added in v2.3.0

func (mr *MockBlockDBMockRecorder) InitGenesis(genesisBlock interface{}) *gomock.Call

InitGenesis indicates an expected call of InitGenesis.

func (*MockBlockDBMockRecorder) RestoreBlocks added in v2.3.0

func (mr *MockBlockDBMockRecorder) RestoreBlocks(blockInfos interface{}) *gomock.Call

RestoreBlocks indicates an expected call of RestoreBlocks.

func (*MockBlockDBMockRecorder) ShrinkBlocks added in v2.3.0

func (mr *MockBlockDBMockRecorder) ShrinkBlocks(startHeight, endHeight, bfdbPath interface{}) *gomock.Call

ShrinkBlocks indicates an expected call of ShrinkBlocks.

func (*MockBlockDBMockRecorder) TxArchived added in v2.3.0

func (mr *MockBlockDBMockRecorder) TxArchived(txId interface{}) *gomock.Call

TxArchived indicates an expected call of TxArchived.

func (*MockBlockDBMockRecorder) TxExists added in v2.3.0

func (mr *MockBlockDBMockRecorder) TxExists(txId interface{}) *gomock.Call

TxExists indicates an expected call of TxExists.

Directories

Path Synopsis
Package blockfiledb package
Package blockfiledb package
Package blockhelper package
Package blockhelper package
Package blockkvdb package
Package blockkvdb package
Package blocksqldb package
Package blocksqldb package

Jump to

Keyboard shortcuts

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