Documentation ¶
Overview ¶
Package dapp 系统基础dapp包
Index ¶
- Constants
- func CheckAddress(cfg *types.Chain33Config, addr string, height int64) error
- func ExecAddress(name string) string
- func HeightIndexStr(height, index int64) string
- func IsDriverAddress(addr string, height int64) bool
- func Register(cfg *types.Chain33Config, name string, create DriverCreate, height int64)
- type Driver
- type DriverBase
- func (d *DriverBase) AddRollbackKV(tx *types.Transaction, execer []byte, kvs []*types.KeyValue) []*types.KeyValue
- func (d *DriverBase) Allow(tx *types.Transaction, index int) error
- func (d *DriverBase) AllowIsSame(execer []byte) bool
- func (d *DriverBase) AllowIsUserDot1(execer []byte) bool
- func (d *DriverBase) AllowIsUserDot2(execer []byte) bool
- func (d *DriverBase) CheckReceiptExecOk() bool
- func (d *DriverBase) CheckSignatureData(tx *types.Transaction, index int) bool
- func (d *DriverBase) CheckTx(tx *types.Transaction, index int) error
- func (d *DriverBase) DelRollbackKV(tx *types.Transaction, execer []byte) ([]*types.KeyValue, error)
- func (d *DriverBase) Exec(tx *types.Transaction, index int) (receipt *types.Receipt, err error)
- func (d *DriverBase) ExecDelLocal(tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error)
- func (d *DriverBase) ExecLocal(tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error)
- func (d *DriverBase) ExecutorOrder() int64
- func (d *DriverBase) GetAPI() client.QueueProtocolAPI
- func (d *DriverBase) GetActionName(tx *types.Transaction) string
- func (d *DriverBase) GetAddrTxsCount(reqkey *types.ReqKey) (types.Message, error)
- func (d *DriverBase) GetBlockTime() int64
- func (d *DriverBase) GetCoinsAccount() *account.DB
- func (d *DriverBase) GetCurrentExecName() string
- func (d *DriverBase) GetDifficulty() uint64
- func (d *DriverBase) GetExecutorAPI() api.ExecutorAPI
- func (d *DriverBase) GetExecutorType() types.ExecutorType
- func (d *DriverBase) GetFuncMap() map[string]reflect.Method
- func (d *DriverBase) GetHeight() int64
- func (d *DriverBase) GetLastHash() []byte
- func (d *DriverBase) GetLocalDB() dbm.KVDB
- func (d *DriverBase) GetMainHeight() int64
- func (d *DriverBase) GetName() string
- func (d *DriverBase) GetParentHash() []byte
- func (d *DriverBase) GetPayloadValue() types.Message
- func (d *DriverBase) GetPrefixCount(key *types.ReqKey) (types.Message, error)
- func (d *DriverBase) GetReceipt() []*types.ReceiptData
- func (d *DriverBase) GetStateDB() dbm.KV
- func (d *DriverBase) GetTxGroup(index int) ([]*types.Transaction, error)
- func (d *DriverBase) GetTxs() []*types.Transaction
- func (d *DriverBase) GetTxsByAddr(addr *types.ReqAddr) (types.Message, error)
- func (d *DriverBase) IsFree() bool
- func (d *DriverBase) IsFriend(myexec, writekey []byte, othertx *types.Transaction) bool
- func (d *DriverBase) Query(funcname string, params []byte) (msg types.Message, err error)
- func (d *DriverBase) SetAPI(queueapi client.QueueProtocolAPI)
- func (d *DriverBase) SetBlockInfo(parentHash, mainHash []byte, mainHeight int64)
- func (d *DriverBase) SetChild(e Driver)
- func (d *DriverBase) SetCurrentExecName(name string)
- func (d *DriverBase) SetEnv(height, blocktime int64, difficulty uint64)
- func (d *DriverBase) SetExecutorAPI(queueapi client.QueueProtocolAPI, chain33api types.Chain33Client)
- func (d *DriverBase) SetExecutorType(e types.ExecutorType)
- func (d *DriverBase) SetIsFree(isFree bool)
- func (d *DriverBase) SetLocalDB(db dbm.KVDB)
- func (d *DriverBase) SetName(name string)
- func (d *DriverBase) SetReceipt(receipts []*types.ReceiptData)
- func (d *DriverBase) SetStateDB(db dbm.KV)
- func (d *DriverBase) SetTxs(txs []*types.Transaction)
- func (d *DriverBase) Upgrade() (*types.LocalDBSet, error)
- type DriverCreate
- type KVCreator
- func (c *KVCreator) Add(key, value []byte) *KVCreator
- func (c *KVCreator) AddKVListOnly(list []*types.KeyValue) *KVCreator
- func (c *KVCreator) AddKVOnly(key, value []byte) *KVCreator
- func (c *KVCreator) AddList(list []*types.KeyValue) *KVCreator
- func (c *KVCreator) AddListNoPrefix(list []*types.KeyValue) *KVCreator
- func (c *KVCreator) AddNoPrefix(key, value []byte) *KVCreator
- func (c *KVCreator) AddRollbackKV()
- func (c *KVCreator) AddToLogs(logs []*types.ReceiptLog) []*types.ReceiptLog
- func (c *KVCreator) DelRollbackKV()
- func (c *KVCreator) Get(key []byte) ([]byte, error)
- func (c *KVCreator) GetNoPrefix(key []byte) ([]byte, error)
- func (c *KVCreator) GetRollbackKVList() ([]*types.KeyValue, error)
- func (c *KVCreator) KVList() []*types.KeyValue
Constants ¶
const ( // TxIndexFrom transaction index from TxIndexFrom = 1 // TxIndexTo transaction index to TxIndexTo = 2 //ExecLocalSameTime Exec 的时候 同时执行 ExecLocal ExecLocalSameTime = int64(1) )
Variables ¶
This section is empty.
Functions ¶
func CheckAddress ¶
func CheckAddress(cfg *types.Chain33Config, addr string, height int64) error
CheckAddress check address
func HeightIndexStr ¶
HeightIndexStr height and index format string
func IsDriverAddress ¶
IsDriverAddress whether or not execdrivers by address
func Register ¶
func Register(cfg *types.Chain33Config, name string, create DriverCreate, height int64)
Register register dcriver height in name
Types ¶
type Driver ¶
type Driver interface { SetStateDB(dbm.KV) GetCoinsAccount() *account.DB SetLocalDB(dbm.KVDB) //当前交易执行器名称 GetCurrentExecName() string //驱动的名字,这个名称是固定的 GetDriverName() string //执行器的别名(一个驱动(code),允许创建多个执行器,类似evm一份代码可以创建多个合约) GetName() string GetExecutorAPI() api.ExecutorAPI //设置执行器的真实名称 SetName(string) SetCurrentExecName(string) Allow(tx *types.Transaction, index int) error IsFriend(myexec []byte, writekey []byte, othertx *types.Transaction) bool GetActionName(tx *types.Transaction) string SetEnv(height, blocktime int64, difficulty uint64) SetBlockInfo([]byte, []byte, int64) CheckTx(tx *types.Transaction, index int) error Exec(tx *types.Transaction, index int) (*types.Receipt, error) ExecLocal(tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) ExecDelLocal(tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) Query(funcName string, params []byte) (types.Message, error) IsFree() bool SetAPI(client.QueueProtocolAPI) SetExecutorAPI(queueapi client.QueueProtocolAPI, chain33api types.Chain33Client) SetTxs(txs []*types.Transaction) SetReceipt(receipts []*types.ReceiptData) //GetTxs and TxGroup GetTxs() []*types.Transaction GetTxGroup(index int) ([]*types.Transaction, error) GetPayloadValue() types.Message GetFuncMap() map[string]reflect.Method GetExecutorType() types.ExecutorType CheckReceiptExecOk() bool ExecutorOrder() int64 Upgrade() (*types.LocalDBSet, error) }
Driver defines some interface
func LoadDriver ¶
LoadDriver load driver
func LoadDriverAllow ¶
func LoadDriverAllow(qclent client.QueueProtocolAPI, tx *types.Transaction, index int, height int64) (driver Driver)
LoadDriverAllow load driver allow
func LoadDriverWithClient ¶
type DriverBase ¶
type DriverBase struct {
// contains filtered or unexported fields
}
DriverBase defines driverbase type
func (*DriverBase) AddRollbackKV ¶
func (d *DriverBase) AddRollbackKV(tx *types.Transaction, execer []byte, kvs []*types.KeyValue) []*types.KeyValue
AddRollbackKV add rollback kv
func (*DriverBase) Allow ¶
func (d *DriverBase) Allow(tx *types.Transaction, index int) error
Allow default behavior: same name or parallel chain
func (*DriverBase) AllowIsSame ¶
func (d *DriverBase) AllowIsSame(execer []byte) bool
AllowIsSame allow issame drivername
func (*DriverBase) AllowIsUserDot1 ¶
func (d *DriverBase) AllowIsUserDot1(execer []byte) bool
AllowIsUserDot1 user.evm
func (*DriverBase) AllowIsUserDot2 ¶
func (d *DriverBase) AllowIsUserDot2(execer []byte) bool
AllowIsUserDot2 user.evm.xxx
func (*DriverBase) CheckReceiptExecOk ¶
func (d *DriverBase) CheckReceiptExecOk() bool
CheckReceiptExecOk default return true to check if receipt ty is ok, for specific plugin can overwrite it self
func (*DriverBase) CheckSignatureData ¶
func (d *DriverBase) CheckSignatureData(tx *types.Transaction, index int) bool
CheckSignatureData check signature data
func (*DriverBase) CheckTx ¶
func (d *DriverBase) CheckTx(tx *types.Transaction, index int) error
CheckTx default:,tx.To address points to the contract address
func (*DriverBase) DelRollbackKV ¶
func (d *DriverBase) DelRollbackKV(tx *types.Transaction, execer []byte) ([]*types.KeyValue, error)
DelRollbackKV del rollback kv when exec_del_local
func (*DriverBase) Exec ¶
func (d *DriverBase) Exec(tx *types.Transaction, index int) (receipt *types.Receipt, err error)
Exec call the check exectx subclass, you can also do it without calling , implement your own checktx
func (*DriverBase) ExecDelLocal ¶
func (d *DriverBase) ExecDelLocal(tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error)
ExecDelLocal local execdel
func (*DriverBase) ExecLocal ¶
func (d *DriverBase) ExecLocal(tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error)
ExecLocal local exec
func (*DriverBase) ExecutorOrder ¶
func (d *DriverBase) ExecutorOrder() int64
ExecutorOrder 执行顺序, 如果要使用 ExecLocalSameTime 那么会同时执行 ExecLocal
func (*DriverBase) GetAPI ¶
func (d *DriverBase) GetAPI() client.QueueProtocolAPI
GetAPI return queue protocol api
func (*DriverBase) GetActionName ¶
func (d *DriverBase) GetActionName(tx *types.Transaction) string
GetActionName get action name
func (*DriverBase) GetAddrTxsCount ¶
GetAddrTxsCount query the transaction count for the specified address ,for statistical
func (*DriverBase) GetBlockTime ¶
func (d *DriverBase) GetBlockTime() int64
GetBlockTime return block time
func (*DriverBase) GetCoinsAccount ¶
func (d *DriverBase) GetCoinsAccount() *account.DB
GetCoinsAccount get coins account
func (*DriverBase) GetCurrentExecName ¶
func (d *DriverBase) GetCurrentExecName() string
GetCurrentExecName defines get current execname
func (*DriverBase) GetDifficulty ¶
func (d *DriverBase) GetDifficulty() uint64
GetDifficulty return difficulty
func (*DriverBase) GetExecutorAPI ¶
func (d *DriverBase) GetExecutorAPI() api.ExecutorAPI
GetExecutorAPI return executor api
func (*DriverBase) GetExecutorType ¶
func (d *DriverBase) GetExecutorType() types.ExecutorType
GetExecutorType defines get executortype func
func (*DriverBase) GetFuncMap ¶
func (d *DriverBase) GetFuncMap() map[string]reflect.Method
GetFuncMap defines get execfuncmap func
func (*DriverBase) GetLastHash ¶
func (d *DriverBase) GetLastHash() []byte
GetLastHash 获取最后区块的hash,主链和平行链不同
func (*DriverBase) GetLocalDB ¶
func (d *DriverBase) GetLocalDB() dbm.KVDB
GetLocalDB return localdb
func (*DriverBase) GetMainHeight ¶
func (d *DriverBase) GetMainHeight() int64
GetMainHeight return height
func (*DriverBase) GetParentHash ¶
func (d *DriverBase) GetParentHash() []byte
GetParentHash 获取上一个区块的hash
func (*DriverBase) GetPayloadValue ¶
func (d *DriverBase) GetPayloadValue() types.Message
GetPayloadValue define get payload func
func (*DriverBase) GetPrefixCount ¶
GetPrefixCount query the number keys of the specified prefix, for statistical
func (*DriverBase) GetReceipt ¶
func (d *DriverBase) GetReceipt() []*types.ReceiptData
GetReceipt return receipts
func (*DriverBase) GetTxGroup ¶
func (d *DriverBase) GetTxGroup(index int) ([]*types.Transaction, error)
GetTxGroup get txgroup
func (*DriverBase) GetTxs ¶
func (d *DriverBase) GetTxs() []*types.Transaction
GetTxs get transactions
func (*DriverBase) GetTxsByAddr ¶
GetTxsByAddr find all transactions in this address by the addr prefix query transaction are placed by default :coins in the query
func (*DriverBase) IsFriend ¶
func (d *DriverBase) IsFriend(myexec, writekey []byte, othertx *types.Transaction) bool
IsFriend defines a isfriend function
func (*DriverBase) SetAPI ¶
func (d *DriverBase) SetAPI(queueapi client.QueueProtocolAPI)
SetAPI set queue protocol api
func (*DriverBase) SetBlockInfo ¶
func (d *DriverBase) SetBlockInfo(parentHash, mainHash []byte, mainHeight int64)
SetBlockInfo 设置区块的信息
func (*DriverBase) SetCurrentExecName ¶
func (d *DriverBase) SetCurrentExecName(name string)
SetCurrentExecName set current execname
func (*DriverBase) SetEnv ¶
func (d *DriverBase) SetEnv(height, blocktime int64, difficulty uint64)
SetEnv set env
func (*DriverBase) SetExecutorAPI ¶
func (d *DriverBase) SetExecutorAPI(queueapi client.QueueProtocolAPI, chain33api types.Chain33Client)
SetExecutorAPI set queue protocol api
func (*DriverBase) SetExecutorType ¶
func (d *DriverBase) SetExecutorType(e types.ExecutorType)
SetExecutorType set exectortype
func (*DriverBase) SetReceipt ¶
func (d *DriverBase) SetReceipt(receipts []*types.ReceiptData)
SetReceipt set receipt
func (*DriverBase) SetTxs ¶
func (d *DriverBase) SetTxs(txs []*types.Transaction)
SetTxs set transactions
func (*DriverBase) Upgrade ¶
func (d *DriverBase) Upgrade() (*types.LocalDBSet, error)
Upgrade default upgrade only print a message
type KVCreator ¶
type KVCreator struct {
// contains filtered or unexported fields
}
KVCreator 创建KV的辅助工具
func NewKVCreator ¶
NewKVCreator 创建创建者 注意: 自动回滚可能会严重影响系统性能
func (*KVCreator) AddKVListOnly ¶
AddKVListOnly only add KVList (can't auto rollback)
func (*KVCreator) AddListNoPrefix ¶
AddListNoPrefix only add KVList
func (*KVCreator) AddNoPrefix ¶
AddNoPrefix 不自动添加prefix
func (*KVCreator) AddToLogs ¶
func (c *KVCreator) AddToLogs(logs []*types.ReceiptLog) []*types.ReceiptLog
AddToLogs add not empty log to logs
func (*KVCreator) GetNoPrefix ¶
GetNoPrefix 从KV中获取 value, 不自动添加前缀
func (*KVCreator) GetRollbackKVList ¶
GetRollbackKVList 获取 rollback 到 Key and Vaue
Directories ¶
Path | Synopsis |
---|---|
Package coins 系统级coins dapp插件
|
Package coins 系统级coins dapp插件 |
autotest
Package autotest 系统级coins dapp自动测试包
|
Package autotest 系统级coins dapp自动测试包 |
executor
Package executor coins执行器
|
Package executor coins执行器 |
Package commands 系统级dapp相关命令包
|
Package commands 系统级dapp相关命令包 |
types
Package types commands中结构体定义
|
Package types commands中结构体定义 |
Package init 初始化系统dapp包
|
Package init 初始化系统dapp包 |
Package manage manage负责管理配置的插件 1.
|
Package manage manage负责管理配置的插件 1. |
commands
Package commands 管理插件命令
|
Package commands 管理插件命令 |
executor
Package executor 管理插件执行器
|
Package executor 管理插件执行器 |
types
Package types 管理插件相关的定义
|
Package types 管理插件相关的定义 |
Package none 系统级dapp,执行内容为空
|
Package none 系统级dapp,执行内容为空 |
executor
Package executor none执行器
|
Package executor none执行器 |