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) GetSaveSql(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 (b *BlockSqlDB) CompactRange() error
- func (b *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 (b *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) GetDbType() string
- func (b *BlockSqlDB) GetFilteredBlock(height uint64) (*storePb.SerializedBlock, error)
- func (b *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 (b *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 (b *BlockSqlDB) RestoreBlocks(blockInfos []*serialization.BlockWithSerializedInfo) error
- func (b *BlockSqlDB) ShrinkBlocks(startHeight uint64, endHeight uint64, bfdbPath string) (map[uint64][]string, error)
- func (b *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) GetSaveSql(_ 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 is string , json marshal array of payload's tx_ids
TxIds string `gorm:"type:longtext"`
AdditionalData []byte `gorm:"type:longblob"`
}
BlockInfo defines mysql orm model, used to create mysql table 'block_infos'
@Description:
func ConvertHeader2BlockInfo ¶
func ConvertHeader2BlockInfo(header *commonPb.BlockHeader) *BlockInfo
ConvertHeader2BlockInfo transform BlockHeader to BlockInfo
@Description: @param header @return *BlockInfo
func NewBlockInfo ¶
NewBlockInfo add next time
@Description: @param block @return *BlockInfo @return error
func (*BlockInfo) GetBlock ¶
GetBlock transfer the BlockInfo to commonPb.Block
@Description: @receiver b @return *commonPb.Block @return error
func (*BlockInfo) GetBlockHeader ¶
func (b *BlockInfo) GetBlockHeader() *commonPb.BlockHeader
GetBlockHeader retrieve BlockHeader from BlockInfo
@Description: @receiver b @return *commonPb.BlockHeader
func (*BlockInfo) GetCountSql ¶
GetCountSql generate table(block_infos)-count sentence , query item-counts according to block_height
@Description:
@receiver b
@return string
@return []interface{}
func (*BlockInfo) GetCreateTableSql ¶
GetCreateTableSql generate table(block_infos)-create sentence , according to dbType
@Description: @receiver b @param dbType @return string
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.
@Description: @receiver b @return *storePb.SerializedBlock @return error
func (*BlockInfo) GetInsertSql ¶
GetInsertSql generate table(block_infos)-insert sentence , according to dbType
@Description:
@receiver b
@param dbType
@return string
@return []interface{}
func (*BlockInfo) GetSaveSql ¶
GetSaveSql return REPLACE into sql @param dbType @return string @return []interface{}
func (*BlockInfo) GetTxList ¶
GetTxList returns the txId list , or return nil if an error occurred
@Description: @receiver b @return []string @return error
func (*BlockInfo) GetUpdateSql ¶
GetUpdateSql generate table(block_infos)-update sentence , update chain_id according to block_height
@Description:
@receiver b
@return string
@return []interface{}
type BlockSqlDB ¶
type BlockSqlDB struct {
// contains filtered or unexported fields
}
BlockSqlDB provider an implementation of `blockdb.BlockDB` This implementation provides a mysql based data model @Description:
func NewBlockSqlDB ¶
func NewBlockSqlDB(dbName string, db protocol.SqlDBHandle, logger protocol.Logger) *BlockSqlDB
NewBlockSqlDB constructs a new `BlockSqlDB` given an chainId and engine type
@Description: @param dbName @param db @param logger @return *BlockSqlDB
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.
@Description: @receiver b @param blockHash @return bool @return error
func (*BlockSqlDB) Close ¶
func (b *BlockSqlDB) Close()
Close is used to close database
@Description: @receiver b
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
@Description: @receiver b @param blocksInfo @param isCache @return error
func (*BlockSqlDB) CompactRange ¶ added in v3.0.1
func (b *BlockSqlDB) CompactRange() error
CompactRange fo kvdb compact action @Description: @return error
func (*BlockSqlDB) GetArchivedPivot ¶
func (b *BlockSqlDB) GetArchivedPivot() (uint64, error)
GetArchivedPivot return default 0 and nil
@Description: @receiver db @return uint64 @return 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.
@Description: @receiver b @param height @return *commonPb.Block @return error
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.
@Description: @receiver b @param blockHash @return *commonPb.Block @return error
func (*BlockSqlDB) GetBlockByTx ¶
func (b *BlockSqlDB) GetBlockByTx(txId string) (*commonPb.Block, error)
GetBlockByTx returns a block which contains a tx.
@Description: @receiver b @param txId @return *commonPb.Block @return error
func (*BlockSqlDB) GetBlockHeaderByHeight ¶
func (b *BlockSqlDB) GetBlockHeaderByHeight(height uint64) (*commonPb.BlockHeader, error)
GetBlockHeaderByHeight 通过块高得到header
@Description: @receiver db @param height @return *commonPb.BlockHeader @return error
func (*BlockSqlDB) GetBlockIndex ¶
func (b *BlockSqlDB) GetBlockIndex(height uint64) (*storePb.StoreInfo, error)
GetBlockIndex NotImplement
@Description: @receiver b @param height @return *storePb.StoreInfo @return error
func (*BlockSqlDB) GetBlockMetaIndex ¶
func (b *BlockSqlDB) GetBlockMetaIndex(height uint64) (*storePb.StoreInfo, error)
GetBlockMetaIndex NotImplement
@Description: @receiver b @param height @return *storePb.StoreInfo @return error
func (*BlockSqlDB) GetDbType ¶ added in v3.0.1
func (b *BlockSqlDB) GetDbType() string
GetDbType add next time @Description: @receiver b @return string
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.
@Description: @receiver b @param height @return *storePb.SerializedBlock @return error
func (*BlockSqlDB) GetHeightByHash ¶
func (b *BlockSqlDB) GetHeightByHash(blockHash []byte) (uint64, error)
GetHeightByHash 通过hash得到块高
@Description: @receiver db @param blockHash @return uint64 @return error
func (*BlockSqlDB) GetLastBlock ¶
func (b *BlockSqlDB) GetLastBlock() (*commonPb.Block, error)
GetLastBlock returns the last block.
@Description: @receiver b @return *commonPb.Block @return error
func (*BlockSqlDB) GetLastConfigBlock ¶
func (b *BlockSqlDB) GetLastConfigBlock() (*commonPb.Block, error)
GetLastConfigBlock returns the last config block.
@Description: @receiver b @return *commonPb.Block @return error
func (*BlockSqlDB) GetLastConfigBlockHeight ¶
func (b *BlockSqlDB) GetLastConfigBlockHeight() (uint64, error)
GetLastConfigBlockHeight returns the last config block height.
@Description: @receiver b @return uint64 @return error
func (*BlockSqlDB) GetLastSavepoint ¶
func (b *BlockSqlDB) GetLastSavepoint() (uint64, error)
GetLastSavepoint returns the last block height
@Description: @receiver b @return uint64 @return error
func (*BlockSqlDB) GetTx ¶
func (b *BlockSqlDB) GetTx(txId string) (*commonPb.Transaction, error)
GetTx retrieves a transaction by txid, or returns nil if none exists.
@Description: @receiver b @param txId @return *commonPb.Transaction @return error
func (*BlockSqlDB) GetTxConfirmedTime ¶
func (b *BlockSqlDB) GetTxConfirmedTime(txId string) (int64, error)
GetTxConfirmedTime NotImplement
@Description: @receiver b @param txId @return int64 @return error
func (*BlockSqlDB) GetTxHeight ¶
func (b *BlockSqlDB) GetTxHeight(txId string) (uint64, error)
GetTxHeight 通过txid得到块高
@Description: @receiver db @param txId @return uint64 @return error
func (*BlockSqlDB) GetTxIndex ¶
func (b *BlockSqlDB) GetTxIndex(txId string) (*storePb.StoreInfo, error)
GetTxIndex NotImplement
@Description: @receiver b @param txId @return *storePb.StoreInfo @return error
func (*BlockSqlDB) GetTxInfoOnly ¶
func (b *BlockSqlDB) GetTxInfoOnly(txId string) (*storePb.TransactionStoreInfo, error)
GetTxInfoOnly 获得除Tx之外的其他TxInfo信息
@Description: @receiver b @param txId @return *storePb.TransactionStoreInfo @return error
func (*BlockSqlDB) GetTxWithBlockInfo ¶
func (b *BlockSqlDB) GetTxWithBlockInfo(txId string) (*storePb.TransactionStoreInfo, error)
GetTxWithBlockInfo 通过交易id 得到交易Info信息
@Description: @receiver b @param txId @return *storePb.TransactionStoreInfo @return error
func (*BlockSqlDB) InitGenesis ¶
func (b *BlockSqlDB) InitGenesis(genesisBlock *serialization.BlockWithSerializedInfo) error
InitGenesis 创世块初始化
@Description: @receiver b @param genesisBlock @return error
func (*BlockSqlDB) RestoreBlocks ¶
func (b *BlockSqlDB) RestoreBlocks(blockInfos []*serialization.BlockWithSerializedInfo) error
RestoreBlocks NotImplement
@Description: @receiver db @param blockInfos @return error
func (*BlockSqlDB) ShrinkBlocks ¶
func (b *BlockSqlDB) ShrinkBlocks(startHeight uint64, endHeight uint64, bfdbPath string) (map[uint64][]string, error)
ShrinkBlocks add NotImplement
@Description: @receiver db @param startHeight @param endHeight @return map[uint64][]string @return error
func (*BlockSqlDB) TxArchived ¶
func (b *BlockSqlDB) TxArchived(txId string) (bool, error)
TxArchived 交易归档
@Description: @receiver db @param txId @return bool @return error
func (*BlockSqlDB) TxExists ¶
func (b *BlockSqlDB) TxExists(txId string) (bool, error)
TxExists returns true if the tx exist, or returns false if none exists.
@Description: @receiver b @param txId @return bool @return error
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"`
Limit []byte `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'
@Description:
func NewTxInfo ¶
func NewTxInfo(tx *commonPb.Transaction, blockHeight uint64, blockHash []byte, offset uint32) (*TxInfo, error)
NewTxInfo construct new `TxInfo`
@Description: @param tx @param blockHeight @param blockHash @param offset @return *TxInfo @return error
func (*TxInfo) GetCountSql ¶
GetCountSql generate table(tx_infos)-count sentence , query item-counts according to tx_id
@Description:
@receiver b
@return string
@return []interface{}
func (*TxInfo) GetCreateTableSql ¶
GetCreateTableSql generate table(tx_infos)-create sentence , according to dbType
@Description: @receiver t @param dbType @return string
func (*TxInfo) GetInsertSql ¶
GetInsertSql generate table(tx_infos)-insert sentence , according to dbType
@Description:
@receiver t
@param dbType
@return string
@return []interface{}
func (*TxInfo) GetSaveSql ¶
GetSaveSql REPLACE sql @param _ @return string @return []interface{}
func (*TxInfo) GetTx ¶
func (t *TxInfo) GetTx() (*commonPb.Transaction, error)
GetTx transfer TxInfo to commonPb.Transaction
@Description: @receiver t @return *commonPb.Transaction @return error
func (*TxInfo) GetTxInfo ¶
func (t *TxInfo) GetTxInfo() (*storePb.TransactionStoreInfo, error)
GetTxInfo retrieve TransactionStoreInfo from TxInfo
@Description: @receiver t @return *storePb.TransactionStoreInfo @return error
func (*TxInfo) GetUpdateSql ¶
GetUpdateSql generate table(tx_infos)-update sentence , update chain_id according to tx_id
@Description:
@receiver t
@return string
@return []interface{}
Source Files
¶
- blockinfo.go
- blocksqldb.go
- txinfo.go