dposmgr210

package
v0.0.0-...-e3261ea Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Balance:map[Account]Value
	KeyBalanceFormat = "B/%s"
	// map[sender][to]Value
	KeyApproveFormat = "A/%s/%s"
	// The Key of total Supply
	KeyTotalSupply = "TS"
	// The Key of Decimals,value:uint32
	KeyDecimals = "DEC"
	// The Key of owner for contract,value:string
	KeyOwner = "OWN"
)
View Source
const (
	KeyNodeIDFormat              = "N/%s"
	KeyRevNodeFormat             = "NR/%s"
	KeyValidatorFormat           = "V/%s"
	KeyDelegationFormat          = "D/%s/%s"
	KeyEpochFormat               = "E/%s"
	KeyUnbondingDelegationFormat = "U/%s/%s/%s"

	KeyCurrentEpoch                   = "CE"
	KeyMinSelfDelegation              = "MSD"
	KeyCompletionUnbondingEpochNumber = "UEN" // 这个 number 不能改动,若改动,会遇到 unbonding entry 数组中 completionEpochID 不同的情况
	KeyEpochValidatorNumber           = "EVN"
	KeyEpochBlockNumber               = "EBN"
)

Variables

This section is empty.

Functions

func BalanceKey

func BalanceKey(account string) string

func StakeContractAddr

func StakeContractAddr() string

StakeContractAddr - convert stake contract name string to address: base58.Encode(sha256(stake_contract_name))

func ToDelegationKey

func ToDelegationKey(delegatorAddress, validatorAddress string) []byte

ToDelegationKey - Key: D + "/" + DelegatorAddress + "/" + ValidatorAddress

func ToDelegationPrefix

func ToDelegationPrefix(delegatorAddress string) []byte

ToDelegationPrefix - Key: D + "/" + DelegatorAddress

func ToEpochKey

func ToEpochKey(epochID string) []byte

ToEpochKey - Key:E + "/" + EpochID

func ToNodeIDKey

func ToNodeIDKey(addr string) []byte

ToNodeIDKey - Key:N + "/" + NodeID

func ToReverseNodeIDKey

func ToReverseNodeIDKey(nodeID string) []byte

ToReverseNodeIDKey - Key:NR + "/" + NodeID

func ToUnbondingDelegationKey

func ToUnbondingDelegationKey(epochID uint64, delegatorAddress, validatorAddress string) []byte

ToUnbondingDelegationKey - Key:U + "/" + BigEndian(EpochID) + "/" + DelegatorAddress + "/" + ValidatorAddress

func ToUnbondingDelegationPrefix

func ToUnbondingDelegationPrefix(epochID uint64) []byte

ToUnbondingDelegationPrefix - Key:U + "/" + BigEndian(EpochID)

func ToValidatorKey

func ToValidatorKey(validatorAddress string) []byte

ToValidatorKey - Key: V + "/" + ValidatorAddress

func ToValidatorPrefix

func ToValidatorPrefix() []byte

ToValidatorPrefix - Key: V + "/"

Types

type Collections

type Collections []string

SelfDelegation array for sort

func (Collections) Len

func (s Collections) Len() int

func (Collections) Less

func (s Collections) Less(i, j int) bool

func (Collections) Swap

func (s Collections) Swap(i, j int)

type DPoSERC20Contract

type DPoSERC20Contract struct {
	// contains filtered or unexported fields
}

func NewDPoSERC20Contract

func NewDPoSERC20Contract(log protocol.Logger) *DPoSERC20Contract

func (*DPoSERC20Contract) GetMethod

func (c *DPoSERC20Contract) GetMethod(methodName string) common.ContractFunc

type DPoSRuntime

type DPoSRuntime struct {
	// contains filtered or unexported fields
}

[DPoS]

func NewDPoSRuntime

func NewDPoSRuntime(log protocol.Logger) *DPoSRuntime

NewDPoSRuntime

func (*DPoSRuntime) Allowance

func (r *DPoSRuntime) Allowance(txSimContext protocol.TxSimContext, params map[string][]byte) ([]byte, error)

Allowance 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

func (*DPoSRuntime) TransferOwnership

func (r *DPoSRuntime) TransferOwnership(txSimContext protocol.TxSimContext, params map[string][]byte) ([]byte, error)

TransferOwnership 转移拥有者给其他账户 params["to"]:${to} return new owner

type DPoSStakeContract

type DPoSStakeContract struct {
	// contains filtered or unexported fields
}

main implement here

func NewDPoSStakeContract

func NewDPoSStakeContract(log protocol.Logger) *DPoSStakeContract

func (*DPoSStakeContract) GetMethod

func (d *DPoSStakeContract) GetMethod(methodName string) common.ContractFunc

type DPoSStakeRuntime

type DPoSStakeRuntime struct {
	// contains filtered or unexported fields
}

func NewDPoSStakeRuntime

func NewDPoSStakeRuntime(log protocol.Logger) *DPoSStakeRuntime

新建 stake Runtime

func (*DPoSStakeRuntime) Delegate

func (s *DPoSStakeRuntime) Delegate(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)

* Delegate(to string, amount string) (delegation, error) // 创建抵押,更新验证人,如果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)

GetAllValidator() []ValidatorAddress // 返回所有满足最低抵押条件验证人候选人 return ValidatorVector

func (*DPoSStakeRuntime) GetDelegationsByAddress

func (s *DPoSStakeRuntime) GetDelegationsByAddress(
	context protocol.TxSimContext, params map[string][]byte) ([]byte, error)

GetDelegationsByAddress() []Delegation // 返回所有 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 // 返回所有 Delegation @params["validator_address"] return Delegation

func (*DPoSStakeRuntime) GetValidatorByAddress

func (s *DPoSStakeRuntime) GetValidatorByAddress(
	context protocol.TxSimContext, params map[string][]byte) ([]byte, error)

GetValidatorByAddress() Validator // 返回所有满足最低抵押条件验证人 @params["address"] return Validator

func (*DPoSStakeRuntime) ReadCompleteUnBoundingEpochNumber

func (s *DPoSStakeRuntime) ReadCompleteUnBoundingEpochNumber(
	context protocol.TxSimContext, params map[string][]byte) ([]byte, error)

ReadEpochBlockNumber() string // 读取世代的出块数量 return string

func (*DPoSStakeRuntime) ReadEpochBlockNumber

func (s *DPoSStakeRuntime) ReadEpochBlockNumber(
	context protocol.TxSimContext, params map[string][]byte) ([]byte, error)

ReadEpochBlockNumber() string // 读取世代的出块数量 return string

func (*DPoSStakeRuntime) ReadEpochByID

func (s *DPoSStakeRuntime) ReadEpochByID(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)

ReadEpochByID() []ValidatorAddress // 读取指定ID的世代数据 @params["epoch_id"] 查询的世代ID return Epoch

func (*DPoSStakeRuntime) ReadEpochValidatorNumber

func (s *DPoSStakeRuntime) ReadEpochValidatorNumber(
	context protocol.TxSimContext, params map[string][]byte) ([]byte, error)

ReadEpochValidatorNumber() string // 读取每个世代验证人数量 return string

func (*DPoSStakeRuntime) ReadLatestEpoch

func (s *DPoSStakeRuntime) ReadLatestEpoch(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)

ReadEpochByID() []ValidatorAddress // 读取当前世代数据 return Epoch

func (*DPoSStakeRuntime) ReadMinSelfDelegation

func (s *DPoSStakeRuntime) ReadMinSelfDelegation(
	context protocol.TxSimContext, params map[string][]byte) ([]byte, error)

ReadMinSelfDelegation() string // 读取验证人最少抵押token数量 return string

func (*DPoSStakeRuntime) ReadSystemContractAddr

func (s *DPoSStakeRuntime) ReadSystemContractAddr(
	context protocol.TxSimContext, params map[string][]byte) ([]byte, error)

ReadSystemContractAddr() string // 读取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)

Undelegation(from string, amount string) bool // 解除抵押,更新验证人 @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() bool // 更新世代的出块数量 @params["epoch_block_number"] return nil

func (*DPoSStakeRuntime) UpdateEpochValidatorNumber

func (s *DPoSStakeRuntime) UpdateEpochValidatorNumber(
	context protocol.TxSimContext, params map[string][]byte) ([]byte, error)

更新每个世代验证人数量,不能大于当前所有验证人数量 UpdateEpochValidatorNumber() string @params["epoch_validator_number"] return string

func (*DPoSStakeRuntime) UpdateMinSelfDelegation

func (s *DPoSStakeRuntime) UpdateMinSelfDelegation(
	context protocol.TxSimContext, params map[string][]byte) ([]byte, error)

更新验证人最少抵押token数量,当提高最少抵押门槛时,原先的 validator 状态不会更新,validator 需要尽块增加抵押 UpdateMinSelfDelegation() string @params["min_self_delegation"] return string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL