blockdb

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

README

区块链数据库

区块头数据

将Header转换为blockinfo进行存储

交易数据

将Transaction转换为TxInfo进行存储

SQLDB 存储

数据库名为 chainId+"_blockdb"

Documentation

Overview

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

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

MockBlockDB is a mock of BlockDB interface.

func NewMockBlockDB

func NewMockBlockDB(ctrl *gomock.Controller) *MockBlockDB

NewMockBlockDB creates a new mock instance.

func (*MockBlockDB) BlockExists

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

BlockExists mocks base method.

func (*MockBlockDB) Close

func (m *MockBlockDB) Close()

Close mocks base method.

func (*MockBlockDB) CommitBlock

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

CommitBlock mocks base method.

func (*MockBlockDB) CompactRange added in v3.0.1

func (m *MockBlockDB) CompactRange() error

CompactRange mocks base method.

func (*MockBlockDB) EXPECT

func (m *MockBlockDB) EXPECT() *MockBlockDBMockRecorder

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

func (*MockBlockDB) GetArchivedPivot

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

GetArchivedPivot mocks base method.

func (*MockBlockDB) GetBlock

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

GetBlock mocks base method.

func (*MockBlockDB) GetBlockByHash

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

GetBlockByHash mocks base method.

func (*MockBlockDB) GetBlockByTx

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

GetBlockByTx mocks base method.

func (*MockBlockDB) GetBlockHeaderByHeight

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

GetBlockHeaderByHeight mocks base method.

func (*MockBlockDB) GetBlockIndex

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

GetBlockIndex mocks base method.

func (*MockBlockDB) GetBlockMetaIndex

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

GetBlockMetaIndex mocks base method.

func (*MockBlockDB) GetDbType added in v3.0.1

func (m *MockBlockDB) GetDbType() string

GetDbType mocks base method.

func (*MockBlockDB) GetFilteredBlock

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

GetFilteredBlock mocks base method.

func (*MockBlockDB) GetHeightByHash

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

GetHeightByHash mocks base method.

func (*MockBlockDB) GetLastBlock

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

GetLastBlock mocks base method.

func (*MockBlockDB) GetLastConfigBlock

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

GetLastConfigBlock mocks base method.

func (*MockBlockDB) GetLastConfigBlockHeight

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

GetLastConfigBlockHeight mocks base method.

func (*MockBlockDB) GetLastSavepoint

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

GetLastSavepoint mocks base method.

func (*MockBlockDB) GetTx

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

GetTx mocks base method.

func (*MockBlockDB) GetTxConfirmedTime

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

GetTxConfirmedTime mocks base method.

func (*MockBlockDB) GetTxHeight

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

GetTxHeight mocks base method.

func (*MockBlockDB) GetTxIndex

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

GetTxIndex mocks base method.

func (*MockBlockDB) GetTxInfoOnly

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

GetTxInfoOnly mocks base method.

func (*MockBlockDB) GetTxWithBlockInfo

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

GetTxWithBlockInfo mocks base method.

func (*MockBlockDB) InitGenesis

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

InitGenesis mocks base method.

func (*MockBlockDB) RestoreBlocks

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

RestoreBlocks mocks base method.

func (*MockBlockDB) ShrinkBlocks

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

ShrinkBlocks mocks base method.

func (*MockBlockDB) TxArchived

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

TxArchived mocks base method.

func (*MockBlockDB) TxExists

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

TxExists mocks base method.

type MockBlockDBMockRecorder

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

MockBlockDBMockRecorder is the mock recorder for MockBlockDB.

func (*MockBlockDBMockRecorder) BlockExists

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

BlockExists indicates an expected call of BlockExists.

func (*MockBlockDBMockRecorder) Close

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

Close indicates an expected call of Close.

func (*MockBlockDBMockRecorder) CommitBlock

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

CommitBlock indicates an expected call of CommitBlock.

func (*MockBlockDBMockRecorder) CompactRange added in v3.0.1

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

CompactRange indicates an expected call of CompactRange.

func (*MockBlockDBMockRecorder) GetArchivedPivot

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

GetArchivedPivot indicates an expected call of GetArchivedPivot.

func (*MockBlockDBMockRecorder) GetBlock

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

GetBlock indicates an expected call of GetBlock.

func (*MockBlockDBMockRecorder) GetBlockByHash

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

GetBlockByHash indicates an expected call of GetBlockByHash.

func (*MockBlockDBMockRecorder) GetBlockByTx

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

GetBlockByTx indicates an expected call of GetBlockByTx.

func (*MockBlockDBMockRecorder) GetBlockHeaderByHeight

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

GetBlockHeaderByHeight indicates an expected call of GetBlockHeaderByHeight.

func (*MockBlockDBMockRecorder) GetBlockIndex

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

GetBlockIndex indicates an expected call of GetBlockIndex.

func (*MockBlockDBMockRecorder) GetBlockMetaIndex

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

GetBlockMetaIndex indicates an expected call of GetBlockMetaIndex.

func (*MockBlockDBMockRecorder) GetDbType added in v3.0.1

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

GetDbType indicates an expected call of GetDbType.

func (*MockBlockDBMockRecorder) GetFilteredBlock

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

GetFilteredBlock indicates an expected call of GetFilteredBlock.

func (*MockBlockDBMockRecorder) GetHeightByHash

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

GetHeightByHash indicates an expected call of GetHeightByHash.

func (*MockBlockDBMockRecorder) GetLastBlock

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

GetLastBlock indicates an expected call of GetLastBlock.

func (*MockBlockDBMockRecorder) GetLastConfigBlock

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

GetLastConfigBlock indicates an expected call of GetLastConfigBlock.

func (*MockBlockDBMockRecorder) GetLastConfigBlockHeight

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

GetLastConfigBlockHeight indicates an expected call of GetLastConfigBlockHeight.

func (*MockBlockDBMockRecorder) GetLastSavepoint

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

GetLastSavepoint indicates an expected call of GetLastSavepoint.

func (*MockBlockDBMockRecorder) GetTx

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

GetTx indicates an expected call of GetTx.

func (*MockBlockDBMockRecorder) GetTxConfirmedTime

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

GetTxConfirmedTime indicates an expected call of GetTxConfirmedTime.

func (*MockBlockDBMockRecorder) GetTxHeight

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

GetTxHeight indicates an expected call of GetTxHeight.

func (*MockBlockDBMockRecorder) GetTxIndex

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

GetTxIndex indicates an expected call of GetTxIndex.

func (*MockBlockDBMockRecorder) GetTxInfoOnly

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

GetTxInfoOnly indicates an expected call of GetTxInfoOnly.

func (*MockBlockDBMockRecorder) GetTxWithBlockInfo

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

GetTxWithBlockInfo indicates an expected call of GetTxWithBlockInfo.

func (*MockBlockDBMockRecorder) InitGenesis

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

InitGenesis indicates an expected call of InitGenesis.

func (*MockBlockDBMockRecorder) RestoreBlocks

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

RestoreBlocks indicates an expected call of RestoreBlocks.

func (*MockBlockDBMockRecorder) ShrinkBlocks

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

ShrinkBlocks indicates an expected call of ShrinkBlocks.

func (*MockBlockDBMockRecorder) TxArchived

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

TxArchived indicates an expected call of TxArchived.

func (*MockBlockDBMockRecorder) TxExists

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

TxExists indicates an expected call of TxExists.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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