blockdb

package
v0.0.0-...-8b03266 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

README

区块链数据库

区块头数据

将Header转换为blockinfo进行存储

交易数据

将Transaction转换为TxInfo进行存储

SQLDB 存储

数据库名为 chainId+"_blockdb"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockDB

type BlockDB interface {
	// InitGenesis 完成创世区块的写入
	InitGenesis(genesisBlock *serialization.BlockWithSerializedInfo) error

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

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

	// GetBlockByHash returns a block given it's hash, or returns nil if none exists.
	GetBlockByHash(blockHash []byte) (*commonPb.Block, error)

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

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

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

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

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

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

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

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

	// TxArchived returns true if the tx archived, or returns false.
	TxArchived(txId string) (bool, error)

	// GetTxConfirmedTime retrieves time of the tx confirmed in the blockChain
	GetTxConfirmedTime(txId string) (int64, error)

	// GetLastBlock returns the last block.
	GetLastBlock() (*commonPb.Block, error)

	// GetFilteredBlock returns a filtered block given it's block height, or return nil if none exists.
	GetFilteredBlock(height uint64) (*storePb.SerializedBlock, error)

	// GetLastSavepoint returns the last block height
	GetLastSavepoint() (uint64, error)

	// GetLastConfigBlock returns the last config block.
	GetLastConfigBlock() (*commonPb.Block, error)

	// GetLastConfigBlockHeight returns the last config block height.
	GetLastConfigBlockHeight() (uint64, error)

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

	// GetArchivedPivot get archived pivot
	GetArchivedPivot() (uint64, error)

	// ShrinkBlocks archive old blocks in an atomic operation
	ShrinkBlocks(startHeight uint64, endHeight uint64) (map[uint64][]string, error)

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

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

	// GetTxIndex reurns the offset of the transaction in the file
	GetTxIndex(txId string) (*storePb.StoreInfo, error)

	// GetBlockIndex returns the offset of the transaction in the file
	GetBlockIndex(height uint64) (*storePb.StoreInfo, error)

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

BlockDB provides handle to block and tx instances

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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