Documentation ¶
Overview ¶
Package statesqldb package
Index ¶
- Variables
- type MemberExtraInfo
- func (b *MemberExtraInfo) GetCountSql() (string, []interface{})
- func (b *MemberExtraInfo) GetCreateTableSql(dbType string) string
- func (b *MemberExtraInfo) GetExtraData() *accesscontrol.MemberExtraData
- func (b *MemberExtraInfo) GetInsertSql(dbType string) (string, []interface{})
- func (b *MemberExtraInfo) GetSaveSql() (string, []interface{})
- func (b *MemberExtraInfo) GetTableName() string
- func (b *MemberExtraInfo) GetUpdateSql() (string, []interface{})
- func (b *MemberExtraInfo) ScanObject(scan func(dest ...interface{}) error) error
- type NewDbHandleFunc
- type StateInfo
- func (b *StateInfo) GetCountSql() (string, []interface{})
- func (b *StateInfo) GetCreateTableSql(dbType string) string
- func (b *StateInfo) GetInsertSql(dbType string) (string, []interface{})
- func (b *StateInfo) GetSaveSql(_ string) (string, []interface{})
- func (b *StateInfo) GetTableName() string
- func (b *StateInfo) GetUpdateSql() (string, []interface{})
- func (b *StateInfo) ScanObject(scan func(dest ...interface{}) error) error
- type StateRecordSql
- func (b *StateRecordSql) GetCountSql() (string, []interface{})
- func (b *StateRecordSql) GetCreateTableSql(dbType string) string
- func (b *StateRecordSql) GetInsertSql(dbType string) (string, []interface{})
- func (b *StateRecordSql) GetQueryStatusSql() (string, interface{})
- func (b *StateRecordSql) GetTableName() string
- func (b *StateRecordSql) GetUpdateSql() (string, []interface{})
- type StateSqlDB
- func (s *StateSqlDB) BeginDbTransaction(txName string) (protocol.SqlDBTransaction, error)
- func (s *StateSqlDB) Close()
- func (s *StateSqlDB) CommitBlock(blockWithRWSet *serialization.BlockWithSerializedInfo, isCache bool) error
- func (s *StateSqlDB) CommitDbTransaction(txName string) error
- func (s *StateSqlDB) CreateDatabase(contractName string) error
- func (s *StateSqlDB) DropDatabase(contractName string) error
- func (s *StateSqlDB) ExecDdlSql(contractName, sql, version string) error
- func (s *StateSqlDB) GetChainConfig() (*configPb.ChainConfig, error)
- func (s *StateSqlDB) GetContractByName(name string) (*commonPb.Contract, error)
- func (s *StateSqlDB) GetContractBytecode(name string) ([]byte, error)
- func (s *StateSqlDB) GetContractDbName(contractName string) string
- func (s *StateSqlDB) GetDbTransaction(txName string) (protocol.SqlDBTransaction, error)
- func (s *StateSqlDB) GetLastSavepoint() (uint64, error)
- func (s *StateSqlDB) GetMemberExtraData(member *accesscontrol.Member) (*accesscontrol.MemberExtraData, error)
- func (s *StateSqlDB) InitGenesis(genesisBlock *serialization.BlockWithSerializedInfo) error
- func (s *StateSqlDB) QueryMulti(contractName, sql string, values ...interface{}) (protocol.SqlRows, error)
- func (s *StateSqlDB) QuerySingle(contractName, sql string, values ...interface{}) (protocol.SqlRow, error)
- func (s *StateSqlDB) ReadObject(contractName string, key []byte) ([]byte, error)
- func (s *StateSqlDB) ReadObjects(contractName string, keys [][]byte) ([][]byte, error)
- func (s *StateSqlDB) RollbackDbTransaction(txName string) error
- func (s *StateSqlDB) SelectObject(contractName string, startKey []byte, limit []byte) (protocol.StateIterator, error)
Constants ¶
This section is empty.
Variables ¶
var ( DbType_Mysql = "mysql" DbType_Sqlite = "sqlite" )
nolint
Functions ¶
This section is empty.
Types ¶
type MemberExtraInfo ¶
type MemberExtraInfo struct { MemberHash []byte `gorm:"size:32;primaryKey"` MemberType int `gorm:""` MemberInfo []byte `gorm:"size:2000"` OrgId string `gorm:"size:200"` Seq uint64 //防止Sequence是数据库关键字 }
MemberExtraInfo defines mysql orm model, used to create mysql table 'member_extra_infos' @Description:
func NewMemberExtraInfo ¶
func NewMemberExtraInfo(member *accesscontrol.Member, extra *accesscontrol.MemberExtraData) *MemberExtraInfo
NewMemberExtraInfo construct MemberExtraInfo @Description: @param member @param extra @return *MemberExtraInfo
func (*MemberExtraInfo) GetCountSql ¶
func (b *MemberExtraInfo) GetCountSql() (string, []interface{})
GetCountSql return count sql @Description: @receiver b @return string @return []interface{}
func (*MemberExtraInfo) GetCreateTableSql ¶
func (b *MemberExtraInfo) GetCreateTableSql(dbType string) string
GetCreateTableSql return member_extra_infos table ddl @Description: @receiver b @param dbType @return string
func (*MemberExtraInfo) GetExtraData ¶
func (b *MemberExtraInfo) GetExtraData() *accesscontrol.MemberExtraData
GetExtraData return MemberExtraInfo Seq @Description: @receiver b @return *accesscontrol.MemberExtraData
func (*MemberExtraInfo) GetInsertSql ¶
func (b *MemberExtraInfo) GetInsertSql(dbType string) (string, []interface{})
GetInsertSql return insert sql @Description: @receiver b @param dbType @return string @return []interface{}
func (*MemberExtraInfo) GetSaveSql ¶
func (b *MemberExtraInfo) GetSaveSql() (string, []interface{})
GetSaveSql return update or insert sql @Description: @receiver b @return string @return []interface{}
func (*MemberExtraInfo) GetTableName ¶
func (b *MemberExtraInfo) GetTableName() string
GetTableName 获得表的名字 @Description: @receiver b @return string
func (*MemberExtraInfo) GetUpdateSql ¶
func (b *MemberExtraInfo) GetUpdateSql() (string, []interface{})
GetUpdateSql return update sql @Description: @receiver b @return string @return []interface{}
func (*MemberExtraInfo) ScanObject ¶
func (b *MemberExtraInfo) ScanObject(scan func(dest ...interface{}) error) error
ScanObject scan data from db @Description: @receiver b @param scan @return error
type NewDbHandleFunc ¶
nolint
type StateInfo ¶
type StateInfo struct { //ID uint `gorm:"primarykey"` ContractName string `gorm:"size:128;primaryKey"` ObjectKey []byte `gorm:"size:128;primaryKey;default:''"` ObjectValue []byte `gorm:"type:longblob"` BlockHeight uint64 `gorm:"index:idx_height"` //CreatedAt time.Time `gorm:"default:null"` UpdatedAt time.Time `gorm:"default:null"` }
StateInfo defines mysql orm model, used to create mysql table 'state_infos' @Description:
func NewStateInfo ¶
func NewStateInfo(contractName string, objectKey []byte, objectValue []byte, blockHeight uint64, t time.Time) *StateInfo
NewStateInfo construct a new StateInfo @Description: @param contractName @param objectKey @param objectValue @param blockHeight @param t @return *StateInfo
func (*StateInfo) GetCountSql ¶
GetCountSql return update sql sentence @Description: @receiver b @return string @return []interface{}
func (*StateInfo) GetCreateTableSql ¶
GetCreateTableSql return create table sentence @Description: @receiver b @param dbType @return string
func (*StateInfo) GetInsertSql ¶
GetInsertSql return insert sql sentence @Description: @receiver b @param dbType @return string @return []interface{}
func (*StateInfo) GetSaveSql ¶ added in v2.3.0
GetSaveSql return REPLACE into SQL @param _ @return string @return []interface{}
func (*StateInfo) GetTableName ¶
GetTableName 获得表的名字 @Description: @receiver b @return string
func (*StateInfo) GetUpdateSql ¶
GetUpdateSql return update sql sentence @Description: @receiver b @return string @return []interface{}
type StateRecordSql ¶
type StateRecordSql struct { // id is sql hash Id string `gorm:"size:64;primaryKey"` ContractName string `gorm:"size:100"` SqlString string `gorm:"size:4000"` SqlType int `gorm:"size:1;default:1"` Version string `gorm:"size:20"` Status int `gorm:"default:0"` //0: start process, 1:success 2:fail UpdatedAt time.Time `gorm:"default:null"` }
StateRecordSql defines mysql orm model, used to create mysql table 'state_record_sql' @Description:
func NewStateRecordSql ¶
func NewStateRecordSql(contractName string, sql string, sqlType protocol.SqlType, version string, status int) *StateRecordSql
NewStateRecordSql construct a new StateRecordSql @Description: @param contractName @param sql @param sqlType @param version @param status @return *StateRecordSql
func (*StateRecordSql) GetCountSql ¶
func (b *StateRecordSql) GetCountSql() (string, []interface{})
GetCountSql return count sentence @Description: @receiver b @return string @return []interface{}
func (*StateRecordSql) GetCreateTableSql ¶
func (b *StateRecordSql) GetCreateTableSql(dbType string) string
GetCreateTableSql return create table sentence @Description: @receiver b @param dbType @return string
func (*StateRecordSql) GetInsertSql ¶
func (b *StateRecordSql) GetInsertSql(dbType string) (string, []interface{})
GetInsertSql return insert sentence @Description: @receiver b @param dbType @return string @return []interface{}
func (*StateRecordSql) GetQueryStatusSql ¶
func (b *StateRecordSql) GetQueryStatusSql() (string, interface{})
GetQueryStatusSql return query status sentence @Description: @receiver b @return string @return interface{}
func (*StateRecordSql) GetTableName ¶
func (b *StateRecordSql) GetTableName() string
GetTableName 获得表的名字 @Description: @receiver b @return string
func (*StateRecordSql) GetUpdateSql ¶
func (b *StateRecordSql) GetUpdateSql() (string, []interface{})
GetUpdateSql return update sentence @Description: @receiver b @return string @return []interface{}
type StateSqlDB ¶
StateSqlDB provider a implementation of `statedb.StateDB` @Description: This implementation provides a mysql based data model
func NewStateSqlDB ¶
func NewStateSqlDB(dbPrefix, chainId string, db protocol.SqlDBHandle, newDbHandle NewDbHandleFunc, logger protocol.Logger, sqlDbConnPoolSize int) (*StateSqlDB, error)
NewStateSqlDB construct StateSqlDB @Description: @param dbPrefix @param chainId @param db @param newDbHandle @param logger @param sqlDbConnPoolSize @return *StateSqlDB @return error
func (*StateSqlDB) BeginDbTransaction ¶
func (s *StateSqlDB) BeginDbTransaction(txName string) (protocol.SqlDBTransaction, error)
BeginDbTransaction 开启事务 @Description: @receiver s @param txName @return protocol.SqlDBTransaction @return error
func (*StateSqlDB) Close ¶
func (s *StateSqlDB) Close()
Close is used to close database, there is no need for gorm to close db @Description: @receiver s
func (*StateSqlDB) CommitBlock ¶
func (s *StateSqlDB) CommitBlock(blockWithRWSet *serialization.BlockWithSerializedInfo, isCache bool) error
CommitBlock commits the state in an atomic operation @Description: @receiver s @param blockWithRWSet @param isCache @return error
func (*StateSqlDB) CommitDbTransaction ¶
func (s *StateSqlDB) CommitDbTransaction(txName string) error
CommitDbTransaction 提交事务 @Description: @receiver s @param txName @return error
func (*StateSqlDB) CreateDatabase ¶
func (s *StateSqlDB) CreateDatabase(contractName string) error
CreateDatabase 创建 database @Description: @receiver s @param contractName @return error
func (*StateSqlDB) DropDatabase ¶
func (s *StateSqlDB) DropDatabase(contractName string) error
DropDatabase 删除一个合约对应的数据库 @Description: @receiver s @param contractName @return error
func (*StateSqlDB) ExecDdlSql ¶
func (s *StateSqlDB) ExecDdlSql(contractName, sql, version string) error
ExecDdlSql 执行ddl语句 建库,建表,并写入 初始化数据 @Description: @receiver s @param contractName @param sql @param version @return error
func (*StateSqlDB) GetChainConfig ¶
func (s *StateSqlDB) GetChainConfig() (*configPb.ChainConfig, error)
GetChainConfig 获得链的配置信息 @Description: @receiver s @return *configPb.ChainConfig @return error
func (*StateSqlDB) GetContractByName ¶ added in v2.1.1
func (s *StateSqlDB) GetContractByName(name string) (*commonPb.Contract, error)
GetContractByName 返回合约信息 @Description: @receiver s @param name @return *commonPb.Contract @return error
func (*StateSqlDB) GetContractBytecode ¶ added in v2.1.1
func (s *StateSqlDB) GetContractBytecode(name string) ([]byte, error)
GetContractBytecode 获得 合约对应字节码数据 @Description: @receiver s @param name @return []byte @return error
func (*StateSqlDB) GetContractDbName ¶
func (s *StateSqlDB) GetContractDbName(contractName string) string
GetContractDbName 获得一个合约对应的状态数据库名 @Description: @receiver s @param contractName @return string
func (*StateSqlDB) GetDbTransaction ¶
func (s *StateSqlDB) GetDbTransaction(txName string) (protocol.SqlDBTransaction, error)
GetDbTransaction 获得事务 @Description: @receiver s @param txName @return protocol.SqlDBTransaction @return error
func (*StateSqlDB) GetLastSavepoint ¶
func (s *StateSqlDB) GetLastSavepoint() (uint64, error)
GetLastSavepoint returns the last block height @Description: @receiver s @return uint64 @return error
func (*StateSqlDB) GetMemberExtraData ¶
func (s *StateSqlDB) GetMemberExtraData(member *accesscontrol.Member) (*accesscontrol.MemberExtraData, error)
GetMemberExtraData 获得 member相关信息 @Description: @receiver s @param member @return *accesscontrol.MemberExtraData @return error
func (*StateSqlDB) InitGenesis ¶
func (s *StateSqlDB) InitGenesis(genesisBlock *serialization.BlockWithSerializedInfo) error
InitGenesis 初始化创世块写入 @Description: @receiver s @param genesisBlock @return error
func (*StateSqlDB) QueryMulti ¶
func (s *StateSqlDB) QueryMulti(contractName, sql string, values ...interface{}) (protocol.SqlRows, error)
QueryMulti 查询合约数据 @Description: @receiver s @param contractName @param sql @param values @return protocol.SqlRows @return error
func (*StateSqlDB) QuerySingle ¶
func (s *StateSqlDB) QuerySingle(contractName, sql string, values ...interface{}) (protocol.SqlRow, error)
QuerySingle 查询合约 @Description: @receiver s @param contractName @param sql @param values @return protocol.SqlRow @return error
func (*StateSqlDB) ReadObject ¶
func (s *StateSqlDB) ReadObject(contractName string, key []byte) ([]byte, error)
ReadObject returns the state value for given contract name and key, or returns nil if none exists. @Description: @receiver s @param contractName @param key @return []byte @return error
func (*StateSqlDB) ReadObjects ¶ added in v2.3.0
func (s *StateSqlDB) ReadObjects(contractName string, keys [][]byte) ([][]byte, error)
ReadObjects returns the state values for given contract name and keys
func (*StateSqlDB) RollbackDbTransaction ¶
func (s *StateSqlDB) RollbackDbTransaction(txName string) error
RollbackDbTransaction 事务回滚 @Description: @receiver s @param txName @return error
func (*StateSqlDB) SelectObject ¶
func (s *StateSqlDB) SelectObject(contractName string, startKey []byte, limit []byte) (protocol.StateIterator, error)
SelectObject returns an iterator that contains all the key-values between given key ranges. startKey is included in the results and limit is excluded. @Description: @receiver s @param contractName @param startKey @param limit means endKey @return protocol.StateIterator @return error