Documentation ¶
Index ¶
- type BlockInfo
- func (b *BlockInfo) GetBlock() (*commonPb.Block, error)
- func (b *BlockInfo) GetBlockHeader() *commonPb.BlockHeader
- func (b *BlockInfo) GetCountSql() (string, []interface{})
- func (b *BlockInfo) GetCreateTableSql(dbType string) string
- func (b *BlockInfo) GetFilteredBlock() (*storePb.SerializedBlock, error)
- func (b *BlockInfo) GetInsertSql(dbType string) (string, []interface{})
- func (b *BlockInfo) GetTableName() string
- func (b *BlockInfo) GetTxList() ([]string, error)
- func (b *BlockInfo) GetUpdateSql() (string, []interface{})
- func (b *BlockInfo) ScanObject(scan func(dest ...interface{}) error) error
- type BlockSqlDB
- func (b *BlockSqlDB) BlockExists(blockHash []byte) (bool, error)
- func (b *BlockSqlDB) Close()
- func (b *BlockSqlDB) CommitBlock(blocksInfo *serialization.BlockWithSerializedInfo, isCache bool) error
- func (db *BlockSqlDB) GetArchivedPivot() (uint64, error)
- func (b *BlockSqlDB) GetBlock(height uint64) (*commonPb.Block, error)
- func (b *BlockSqlDB) GetBlockByHash(blockHash []byte) (*commonPb.Block, error)
- func (b *BlockSqlDB) GetBlockByTx(txId string) (*commonPb.Block, error)
- func (db *BlockSqlDB) GetBlockHeaderByHeight(height uint64) (*commonPb.BlockHeader, error)
- func (b *BlockSqlDB) GetBlockIndex(height uint64) (*storePb.StoreInfo, error)
- func (b *BlockSqlDB) GetBlockMetaIndex(height uint64) (*storePb.StoreInfo, error)
- func (b *BlockSqlDB) GetFilteredBlock(height uint64) (*storePb.SerializedBlock, error)
- func (db *BlockSqlDB) GetHeightByHash(blockHash []byte) (uint64, error)
- func (b *BlockSqlDB) GetLastBlock() (*commonPb.Block, error)
- func (b *BlockSqlDB) GetLastConfigBlock() (*commonPb.Block, error)
- func (b *BlockSqlDB) GetLastConfigBlockHeight() (uint64, error)
- func (b *BlockSqlDB) GetLastSavepoint() (uint64, error)
- func (b *BlockSqlDB) GetTx(txId string) (*commonPb.Transaction, error)
- func (b *BlockSqlDB) GetTxConfirmedTime(txId string) (int64, error)
- func (db *BlockSqlDB) GetTxHeight(txId string) (uint64, error)
- func (b *BlockSqlDB) GetTxIndex(txId string) (*storePb.StoreInfo, error)
- func (b *BlockSqlDB) GetTxInfoOnly(txId string) (*storePb.TransactionStoreInfo, error)
- func (b *BlockSqlDB) GetTxWithBlockInfo(txId string) (*storePb.TransactionStoreInfo, error)
- func (b *BlockSqlDB) InitGenesis(genesisBlock *serialization.BlockWithSerializedInfo) error
- func (db *BlockSqlDB) RestoreBlocks(blockInfos []*serialization.BlockWithSerializedInfo) error
- func (db *BlockSqlDB) ShrinkBlocks(startHeight uint64, endHeight uint64) (map[uint64][]string, error)
- func (db *BlockSqlDB) TxArchived(txId string) (bool, error)
- func (b *BlockSqlDB) TxExists(txId string) (bool, error)
- type TxInfo
- func (b *TxInfo) GetCountSql() (string, []interface{})
- func (t *TxInfo) GetCreateTableSql(dbType string) string
- func (t *TxInfo) GetInsertSql(dbType string) (string, []interface{})
- func (t *TxInfo) GetTableName() string
- func (t *TxInfo) GetTx() (*commonPb.Transaction, error)
- func (t *TxInfo) GetTxInfo() (*storePb.TransactionStoreInfo, error)
- func (t *TxInfo) GetUpdateSql() (string, []interface{})
- func (t *TxInfo) ScanObject(scan func(dest ...interface{}) error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockInfo ¶
type BlockInfo struct { ChainId string `gorm:"size:128"` BlockHeight uint64 `gorm:"primaryKey;autoIncrement:false"` PreBlockHash []byte `gorm:"size:128"` BlockHash []byte `gorm:"size:128;index:idx_hash"` PreConfHeight uint64 `gorm:"default:0"` BlockVersion uint32 `gorm:"default:1"` DagHash []byte `gorm:"size:128"` RwSetRoot []byte `gorm:"size:128"` TxRoot []byte `gorm:"size:128"` BlockTimestamp int64 `gorm:"default:0"` ProposerOrgId string `gorm:"size:128"` ProposerMemberInfo []byte `gorm:"type:blob;size:65535"` ProposerMemberType int `gorm:"default:0"` ProposerSA uint32 `gorm:"default:0"` ConsensusArgs []byte `gorm:"type:blob"` TxCount uint32 `gorm:"default:0"` Signature []byte `gorm:"type:blob;size:65535"` BlockType int `gorm:"default:0"` Dag []byte `gorm:"type:blob"` TxIds string `gorm:"type:longtext"` AdditionalData []byte `gorm:"type:longblob"` }
BlockInfo defines mysql orm model, used to create mysql table 'block_infos'
func ConvertHeader2BlockInfo ¶
func ConvertHeader2BlockInfo(header *commonPb.BlockHeader) *BlockInfo
func (*BlockInfo) GetBlockHeader ¶
func (b *BlockInfo) GetBlockHeader() *commonPb.BlockHeader
func (*BlockInfo) GetCountSql ¶
func (*BlockInfo) GetCreateTableSql ¶
func (*BlockInfo) GetFilteredBlock ¶
func (b *BlockInfo) GetFilteredBlock() (*storePb.SerializedBlock, error)
GetFilteredBlock returns a filtered block given it's block height, or return nil if none exists.
func (*BlockInfo) GetInsertSql ¶
func (*BlockInfo) GetTableName ¶
func (*BlockInfo) GetUpdateSql ¶
func (*BlockInfo) ScanObject ¶
type BlockSqlDB ¶
type BlockSqlDB struct {
// contains filtered or unexported fields
}
BlockSqlDB provider a implementation of `blockdb.BlockDB` This implementation provides a mysql based data model
func NewBlockSqlDB ¶
func NewBlockSqlDB(dbName string, db protocol.SqlDBHandle, logger protocol.Logger) *BlockSqlDB
NewBlockSqlDB constructs a new `BlockSqlDB` given an chainId and engine type
func (*BlockSqlDB) BlockExists ¶
func (b *BlockSqlDB) BlockExists(blockHash []byte) (bool, error)
BlockExists returns true if the block hash exist, or returns false if none exists.
func (*BlockSqlDB) CommitBlock ¶
func (b *BlockSqlDB) CommitBlock(blocksInfo *serialization.BlockWithSerializedInfo, isCache bool) error
CommitBlock commits the block and the corresponding rwsets in an atomic operation
func (*BlockSqlDB) GetArchivedPivot ¶
func (db *BlockSqlDB) GetArchivedPivot() (uint64, error)
func (*BlockSqlDB) GetBlock ¶
func (b *BlockSqlDB) GetBlock(height uint64) (*commonPb.Block, error)
GetBlock returns a block given it's block height, or returns nil if none exists.
func (*BlockSqlDB) GetBlockByHash ¶
func (b *BlockSqlDB) GetBlockByHash(blockHash []byte) (*commonPb.Block, error)
GetBlockByHash returns a block given it's hash, or returns nil if none exists.
func (*BlockSqlDB) GetBlockByTx ¶
func (b *BlockSqlDB) GetBlockByTx(txId string) (*commonPb.Block, error)
GetBlockByTx returns a block which contains a tx.
func (*BlockSqlDB) GetBlockHeaderByHeight ¶
func (db *BlockSqlDB) GetBlockHeaderByHeight(height uint64) (*commonPb.BlockHeader, error)
通过块高得到header
func (*BlockSqlDB) GetBlockIndex ¶
func (b *BlockSqlDB) GetBlockIndex(height uint64) (*storePb.StoreInfo, error)
GetBlockIndex returns the offset of the block in the file
func (*BlockSqlDB) GetBlockMetaIndex ¶
func (b *BlockSqlDB) GetBlockMetaIndex(height uint64) (*storePb.StoreInfo, error)
GetBlockMetaIndex returns the offset of the transaction in the file
func (*BlockSqlDB) GetFilteredBlock ¶
func (b *BlockSqlDB) GetFilteredBlock(height uint64) (*storePb.SerializedBlock, error)
GetFilteredBlock returns a filtered block given it's block height, or return nil if none exists.
func (*BlockSqlDB) GetHeightByHash ¶
func (db *BlockSqlDB) GetHeightByHash(blockHash []byte) (uint64, error)
通过hash得到块高
func (*BlockSqlDB) GetLastBlock ¶
func (b *BlockSqlDB) GetLastBlock() (*commonPb.Block, error)
GetLastBlock returns the last block.
func (*BlockSqlDB) GetLastConfigBlock ¶
func (b *BlockSqlDB) GetLastConfigBlock() (*commonPb.Block, error)
GetLastConfigBlock returns the last config block.
func (*BlockSqlDB) GetLastConfigBlockHeight ¶
func (b *BlockSqlDB) GetLastConfigBlockHeight() (uint64, error)
GetLastConfigBlockHeight returns the last config block height.
func (*BlockSqlDB) GetLastSavepoint ¶
func (b *BlockSqlDB) GetLastSavepoint() (uint64, error)
GetLastSavepoint reurns the last block height
func (*BlockSqlDB) GetTx ¶
func (b *BlockSqlDB) GetTx(txId string) (*commonPb.Transaction, error)
GetTx retrieves a transaction by txid, or returns nil if none exists.
func (*BlockSqlDB) GetTxConfirmedTime ¶
func (b *BlockSqlDB) GetTxConfirmedTime(txId string) (int64, error)
func (*BlockSqlDB) GetTxHeight ¶
func (db *BlockSqlDB) GetTxHeight(txId string) (uint64, error)
通过txid得到块高
func (*BlockSqlDB) GetTxIndex ¶
func (b *BlockSqlDB) GetTxIndex(txId string) (*storePb.StoreInfo, error)
GetTxIndex returns the offset of the transaction in the file
func (*BlockSqlDB) GetTxInfoOnly ¶
func (b *BlockSqlDB) GetTxInfoOnly(txId string) (*storePb.TransactionStoreInfo, error)
GetTxInfoOnly 获得除Tx之外的其他TxInfo信息
func (*BlockSqlDB) GetTxWithBlockInfo ¶
func (b *BlockSqlDB) GetTxWithBlockInfo(txId string) (*storePb.TransactionStoreInfo, error)
通过交易id 得到交易Info信息
func (*BlockSqlDB) InitGenesis ¶
func (b *BlockSqlDB) InitGenesis(genesisBlock *serialization.BlockWithSerializedInfo) error
func getDbName(dbConfig *localconf.SqlDbConfig, chainId string) string { return dbConfig.DbPrefix + "blockdb_" + chainId }
创世块初始化
func (*BlockSqlDB) RestoreBlocks ¶
func (db *BlockSqlDB) RestoreBlocks(blockInfos []*serialization.BlockWithSerializedInfo) error
func (*BlockSqlDB) ShrinkBlocks ¶
type TxInfo ¶
type TxInfo struct { ChainId string `gorm:"size:128"` TxType int32 `gorm:"default:0"` TxId string `gorm:"primaryKey;size:128"` Timestamp int64 `gorm:"default:0"` ExpirationTime int64 `gorm:"default:0"` ContractName string `gorm:"size:128"` // invoke method Method string `gorm:"size:128"` // invoke parameters in k-v format Parameters []byte `gorm:"type:longblob"` //json //sequence number 交易顺序号,以Sender为主键,0表示无顺序要求,>0则必须连续递增。 Sequence uint64 `gorm:"default:0"` // gas price+gas limit; fee; timeout seconds; Limit *commonPb.Limit `gorm:"type:blob;size:65535"` SenderOrgId string `gorm:"size:128"` SenderMemberInfo []byte `gorm:"type:blob;size:65535"` SenderMemberType int `gorm:"default:0"` //SenderSA uint32 `gorm:"default:0"` SenderSignature []byte `gorm:"type:blob;size:65535"` Endorsers string `gorm:"type:longtext"` //json TxStatusCode int32 ContractResultCode uint32 ResultData []byte `gorm:"type:longblob"` ResultMessage string `gorm:"size:2000"` GasUsed uint64 ContractEvents string `gorm:"type:longtext"` //json RwSetHash []byte `gorm:"size:128"` Message string `gorm:"size:2000"` BlockHeight uint64 `gorm:"index:idx_height_offset"` BlockHash []byte `gorm:"size:128"` Offset uint32 `gorm:"index:idx_height_offset"` }
TxInfo defines mysql orm model, used to create mysql table 'tx_infos'
func NewTxInfo ¶
func NewTxInfo(tx *commonPb.Transaction, blockHeight uint64, blockHash []byte, offset uint32) (*TxInfo, error)
NewTxInfo construct new `TxInfo`
func (*TxInfo) GetCountSql ¶
func (*TxInfo) GetCreateTableSql ¶
func (*TxInfo) GetInsertSql ¶
func (*TxInfo) GetTableName ¶
func (*TxInfo) GetTx ¶
func (t *TxInfo) GetTx() (*commonPb.Transaction, error)
GetTx transfer TxInfo to commonPb.Transaction