Documentation ¶
Index ¶
- Constants
- func BalanceKey(account string) string
- func StakeContractAddr() string
- func ToDelegationKey(delegatorAddress, validatorAddress string) []byte
- func ToDelegationPrefix(delegatorAddress string) []byte
- func ToEpochKey(epochID string) []byte
- func ToNodeIDKey(addr string) []byte
- func ToReverseNodeIDKey(nodeID string) []byte
- func ToUnbondingDelegationKey(epochID uint64, delegatorAddress, validatorAddress string) []byte
- func ToUnbondingDelegationPrefix(epochID uint64) []byte
- func ToValidatorKey(validatorAddress string) []byte
- func ToValidatorPrefix() []byte
- type Collections
- type DPoSERC20Contract
- type DPoSRuntime
- func (r *DPoSRuntime) Allowance(txSimContext protocol.TxSimContext, params map[string][]byte) ([]byte, error)
- func (r *DPoSRuntime) Approve(txSimContext protocol.TxSimContext, params map[string][]byte) (result []byte, err error)
- func (r *DPoSRuntime) BalanceOf(txSimContext protocol.TxSimContext, params map[string][]byte) ([]byte, error)
- func (r *DPoSRuntime) Burn(txSimContext protocol.TxSimContext, params map[string][]byte) (result []byte, err error)
- func (r *DPoSRuntime) Decimals(txSimContext protocol.TxSimContext, params map[string][]byte) ([]byte, error)
- func (r *DPoSRuntime) Mint(txSimContext protocol.TxSimContext, params map[string][]byte) (result []byte, err error)
- func (r *DPoSRuntime) Owner(txSimContext protocol.TxSimContext, params map[string][]byte) (result []byte, err error)
- func (r *DPoSRuntime) Total(txSimContext protocol.TxSimContext, params map[string][]byte) (result []byte, err error)
- func (r *DPoSRuntime) Transfer(txSimContext protocol.TxSimContext, params map[string][]byte) ([]byte, error)
- func (r *DPoSRuntime) TransferFrom(txSimContext protocol.TxSimContext, params map[string][]byte) ([]byte, error)
- func (r *DPoSRuntime) TransferOwnership(txSimContext protocol.TxSimContext, params map[string][]byte) ([]byte, error)
- type DPoSStakeContract
- type DPoSStakeRuntime
- func (s *DPoSStakeRuntime) Delegate(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
- func (s *DPoSStakeRuntime) GetAllCandidates(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
- func (s *DPoSStakeRuntime) GetDelegationsByAddress(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
- func (s *DPoSStakeRuntime) GetNodeID(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
- func (s *DPoSStakeRuntime) GetUserDelegationByValidator(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
- func (s *DPoSStakeRuntime) GetValidatorByAddress(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
- func (s *DPoSStakeRuntime) ReadCompleteUnBoundingEpochNumber(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
- func (s *DPoSStakeRuntime) ReadEpochBlockNumber(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
- func (s *DPoSStakeRuntime) ReadEpochByID(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
- func (s *DPoSStakeRuntime) ReadEpochValidatorNumber(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
- func (s *DPoSStakeRuntime) ReadLatestEpoch(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
- func (s *DPoSStakeRuntime) ReadMinSelfDelegation(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
- func (s *DPoSStakeRuntime) ReadSystemContractAddr(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
- func (s *DPoSStakeRuntime) SetNodeID(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
- func (s *DPoSStakeRuntime) UnDelegate(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
- func (s *DPoSStakeRuntime) UpdateEpochBlockNumber(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
- func (s *DPoSStakeRuntime) UpdateEpochValidatorNumber(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
- func (s *DPoSStakeRuntime) UpdateMinSelfDelegation(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
Constants ¶
const ( // KeyBalanceFormat Balance:map[Account]Value KeyBalanceFormat = "B/%s" // KeyApproveFormat map[sender][to]Value KeyApproveFormat = "A/%s/%s" // KeyTotalSupply The Key of total Supply KeyTotalSupply = "TS" // KeyDecimals The Key of Decimals,value:uint32 KeyDecimals = "DEC" // KeyOwner The Key of owner for contract,value:string KeyOwner = "OWN" )
const ( // KeyNodeIDFormat comment at next version KeyNodeIDFormat = "N/%s" // KeyRevNodeFormat comment at next version KeyRevNodeFormat = "NR/%s" // KeyValidatorFormat comment at next version KeyValidatorFormat = "V/%s" // KeyDelegationFormat comment at next version KeyDelegationFormat = "D/%s/%s" // KeyEpochFormat comment at next version KeyEpochFormat = "E/%s" // KeyUnbondingDelegationFormat comment at next version KeyUnbondingDelegationFormat = "U/%s/%s/%s" // KeyCurrentEpoch comment at next version KeyCurrentEpoch = "CE" // KeyMinSelfDelegation comment at next version KeyMinSelfDelegation = "MSD" // KeyCompletionUnbondingEpochNumber 这个 number 不能改动,若改动,会遇到 unbonding entry 数组中 completionEpochID 不同的情况 KeyCompletionUnbondingEpochNumber = "UEN" // KeyEpochValidatorNumber comment at next version KeyEpochValidatorNumber = "EVN" // KeyEpochBlockNumber comment at next version KeyEpochBlockNumber = "EBN" )
Variables ¶
This section is empty.
Functions ¶
func StakeContractAddr ¶
func StakeContractAddr() string
StakeContractAddr - convert stake contract name string to address: base58.Encode(sha256(stake_contract_name))
func ToDelegationKey ¶
ToDelegationKey - Key: D + "/" + DelegatorAddress + "/" + ValidatorAddress
func ToDelegationPrefix ¶
ToDelegationPrefix - Key: D + "/" + DelegatorAddress
func ToReverseNodeIDKey ¶
ToReverseNodeIDKey - Key:NR + "/" + NodeID
func ToUnbondingDelegationKey ¶
ToUnbondingDelegationKey - Key:U + "/" + BigEndian(EpochID) + "/" + DelegatorAddress + "/" + ValidatorAddress
func ToUnbondingDelegationPrefix ¶
ToUnbondingDelegationPrefix - Key:U + "/" + BigEndian(EpochID)
func ToValidatorKey ¶
ToValidatorKey - Key: V + "/" + ValidatorAddress
Types ¶
type DPoSERC20Contract ¶
type DPoSERC20Contract struct {
// contains filtered or unexported fields
}
DPoSERC20Contract comment at next version
func NewDPoSERC20Contract ¶
func NewDPoSERC20Contract(log protocol.Logger) *DPoSERC20Contract
NewDPoSERC20Contract comment at next version @param log @return *DPoSERC20Contract
func (*DPoSERC20Contract) GetMethod ¶
func (c *DPoSERC20Contract) GetMethod(methodName string, _ uint32) common.ContractFunc
GetMethod get register method by name
type DPoSRuntime ¶
type DPoSRuntime struct {
// contains filtered or unexported fields
}
DPoSRuntime comment at next version
func NewDPoSRuntime ¶
func NewDPoSRuntime(log protocol.Logger) *DPoSRuntime
NewDPoSRuntime comment at next version
func (*DPoSRuntime) Allowance ¶
func (r *DPoSRuntime) Allowance(txSimContext protocol.TxSimContext, params map[string][]byte) ([]byte, error)
Allowance comment at next version params["from"]:${from} params["to"]:${to} return value of approve
func (*DPoSRuntime) Approve ¶
func (r *DPoSRuntime) Approve(txSimContext protocol.TxSimContext, params map[string][]byte) (result []byte, err error)
Approve It is equal with approve(spender string, value uint64) error; for ETH params["to"]:${to} params["value"]:${value} return token value for ${sender} to ${to}
func (*DPoSRuntime) BalanceOf ¶
func (r *DPoSRuntime) BalanceOf(txSimContext protocol.TxSimContext, params map[string][]byte) ([]byte, error)
BalanceOf return balance(token) of owner params["owner"]:${owner} return balance of ${owner}
func (*DPoSRuntime) Burn ¶
func (r *DPoSRuntime) Burn(txSimContext protocol.TxSimContext, params map[string][]byte) (result []byte, err error)
Burn 交易的发送者燃烧一定数量的代币,最多可燃烧殆尽 params["value"]:${value} return balance of sender after burn
func (*DPoSRuntime) Decimals ¶
func (r *DPoSRuntime) Decimals(txSimContext protocol.TxSimContext, params map[string][]byte) ([]byte, error)
Decimals return decimals of DPoS
func (*DPoSRuntime) Mint ¶
func (r *DPoSRuntime) Mint(txSimContext protocol.TxSimContext, params map[string][]byte) (result []byte, err error)
Mint 增发 params["to"]:${to} params["value"]:${value} return newest token of ${to} after mint
func (*DPoSRuntime) Owner ¶
func (r *DPoSRuntime) Owner(txSimContext protocol.TxSimContext, params map[string][]byte) (result []byte, err error)
Owner return owner of DPoS
func (*DPoSRuntime) Total ¶
func (r *DPoSRuntime) Total(txSimContext protocol.TxSimContext, params map[string][]byte) (result []byte, err error)
Total return total supply of tokens
func (*DPoSRuntime) Transfer ¶
func (r *DPoSRuntime) Transfer(txSimContext protocol.TxSimContext, params map[string][]byte) ([]byte, error)
Transfer It is equal with transfer(to string, value uint64) for ETH params["to"]:${to} params["value"]:${value} return token value of ${sender} after transfer
func (*DPoSRuntime) TransferFrom ¶
func (r *DPoSRuntime) TransferFrom(txSimContext protocol.TxSimContext, params map[string][]byte) ([]byte, error)
TransferFrom 交易的发送者,从from的账号中转移指定数目的token给to账户 该操作需要approve,即from已经提前允许当前用户允许转移操作 params["from"]:${from} params["to"]:${to} params["value"]:${value} return token value of ${from} after transfer
type DPoSStakeContract ¶
type DPoSStakeContract struct {
// contains filtered or unexported fields
}
DPoSStakeContract main implement here
func NewDPoSStakeContract ¶
func NewDPoSStakeContract(log protocol.Logger) *DPoSStakeContract
NewDPoSStakeContract comment at next version @param log @return *DPoSStakeContract
func (*DPoSStakeContract) GetMethod ¶
func (d *DPoSStakeContract) GetMethod(methodName string, _ uint32) common.ContractFunc
GetMethod get register method by name
type DPoSStakeRuntime ¶
type DPoSStakeRuntime struct {
// contains filtered or unexported fields
}
DPoSStakeRuntime comment at next version
func NewDPoSStakeRuntime ¶
func NewDPoSStakeRuntime(log protocol.Logger) *DPoSStakeRuntime
NewDPoSStakeRuntime 新建 stake Runtime
func (*DPoSStakeRuntime) Delegate ¶
func (s *DPoSStakeRuntime) Delegate(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
Delegate 创建抵押,更新验证人,如果MsgSender是给自己,即给自己抵押,则创建验证人 @params["to"] 抵押的目标验证人 @params["amount"] 抵押数量,乘上erc20合约 decimal 的结果值,比如用户认知的1USD,系统内是 1 * 10 ^ 18 return Delegation
func (*DPoSStakeRuntime) GetAllCandidates ¶
func (s *DPoSStakeRuntime) GetAllCandidates(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
GetAllCandidates 返回所有满足最低抵押条件验证人候选人 return ValidatorVector
func (*DPoSStakeRuntime) GetDelegationsByAddress ¶
func (s *DPoSStakeRuntime) GetDelegationsByAddress( context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
GetDelegationsByAddress 返回所有 Delegation @params["address"] return DelegationInfo
func (*DPoSStakeRuntime) GetNodeID ¶
func (s *DPoSStakeRuntime) GetNodeID(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
GetNodeID - 系统节点自身身份查询
func (*DPoSStakeRuntime) GetUserDelegationByValidator ¶
func (s *DPoSStakeRuntime) GetUserDelegationByValidator( context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
GetUserDelegationByValidator 返回所有 Delegation @params["validator_address"] return Delegation
func (*DPoSStakeRuntime) GetValidatorByAddress ¶
func (s *DPoSStakeRuntime) GetValidatorByAddress( context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
GetValidatorByAddress 返回所有满足最低抵押条件验证人 @params["address"] return Validator
func (*DPoSStakeRuntime) ReadCompleteUnBoundingEpochNumber ¶
func (s *DPoSStakeRuntime) ReadCompleteUnBoundingEpochNumber( context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
ReadCompleteUnBoundingEpochNumber 读取世代的出块数量 return string
func (*DPoSStakeRuntime) ReadEpochBlockNumber ¶
func (s *DPoSStakeRuntime) ReadEpochBlockNumber( context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
ReadEpochBlockNumber 读取世代的出块数量 return string
func (*DPoSStakeRuntime) ReadEpochByID ¶
func (s *DPoSStakeRuntime) ReadEpochByID(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
ReadEpochByID 读取指定ID的世代数据 @params["epoch_id"] 查询的世代ID return Epoch
func (*DPoSStakeRuntime) ReadEpochValidatorNumber ¶
func (s *DPoSStakeRuntime) ReadEpochValidatorNumber( context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
ReadEpochValidatorNumber 读取每个世代验证人数量 return string
func (*DPoSStakeRuntime) ReadLatestEpoch ¶
func (s *DPoSStakeRuntime) ReadLatestEpoch(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
ReadLatestEpoch 读取当前世代数据 return Epoch
func (*DPoSStakeRuntime) ReadMinSelfDelegation ¶
func (s *DPoSStakeRuntime) ReadMinSelfDelegation( context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
ReadMinSelfDelegation 读取验证人最少抵押token数量 return string
func (*DPoSStakeRuntime) ReadSystemContractAddr ¶
func (s *DPoSStakeRuntime) ReadSystemContractAddr( context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
ReadSystemContractAddr 读取stake系统合约的地址 return string
func (*DPoSStakeRuntime) SetNodeID ¶
func (s *DPoSStakeRuntime) SetNodeID(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
SetNodeID - 系统加入节点绑定自身身份
func (*DPoSStakeRuntime) UnDelegate ¶
func (s *DPoSStakeRuntime) UnDelegate(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
UnDelegate 解除抵押,更新验证人 @params["from"] 解质押的验证人 @params["amount"] 解质押数量,1 * 10 ^ 18 return UnbondingDelegation
func (*DPoSStakeRuntime) UpdateEpochBlockNumber ¶
func (s *DPoSStakeRuntime) UpdateEpochBlockNumber( context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
UpdateEpochBlockNumber 更新世代的出块数量 @params["epoch_block_number"] return nil
func (*DPoSStakeRuntime) UpdateEpochValidatorNumber ¶
func (s *DPoSStakeRuntime) UpdateEpochValidatorNumber( context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
UpdateEpochValidatorNumber 更新每个世代验证人数量,不能大于当前所有验证人数量 @params["epoch_validator_number"] return string
func (*DPoSStakeRuntime) UpdateMinSelfDelegation ¶
func (s *DPoSStakeRuntime) UpdateMinSelfDelegation( context protocol.TxSimContext, params map[string][]byte) ([]byte, error)
UpdateMinSelfDelegation 更新验证人最少抵押token数量,当提高最少抵押门槛时,原先的 validator 状态不会更新,validator 需要尽块增加抵押 @params["min_self_delegation"] return string