contracts

package
v0.0.3-tmp Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2018 License: GPL-3.0 Imports: 9 Imported by: 5

Documentation

Index

Constants

View Source
const (
	MethodNameRegister           = "Register"
	MethodNameCancelRegister     = "CancelRegister"
	MethodNameReward             = "Reward"
	MethodNameUpdateRegistration = "UpdateRegistration"
	VariableNameRegistration     = "registration"

	MethodNameVote         = "Vote"
	MethodNameCancelVote   = "CancelVote"
	VariableNameVoteStatus = "voteStatus"

	MethodNamePledge             = "Pledge"
	MethodNameCancelPledge       = "CancelPledge"
	VariableNamePledgeInfo       = "pledgeInfo"
	VariableNamePledgeBeneficial = "pledgeBeneficial"

	MethodNameCreateConsensusGroup        = "CreateConsensusGroup"
	MethodNameCancelConsensusGroup        = "CancelConsensusGroup"
	MethodNameReCreateConsensusGroup      = "ReCreateConsensusGroup"
	VariableNameConsensusGroupInfo        = "consensusGroupInfo"
	VariableNameConditionRegisterOfPledge = "registerOfPledge"
	VariableNameConditionVoteOfBalance    = "voteOfKeepToken"

	MethodNameMintage             = "Mintage"
	MethodNameMintageCancelPledge = "CancelPledge"
	VariableNameMintage           = "mintage"
)

Variables

View Source
var (
	ABIRegister, _       = abi.JSONToABIContract(strings.NewReader(jsonRegister))
	ABIVote, _           = abi.JSONToABIContract(strings.NewReader(jsonVote))
	ABIPledge, _         = abi.JSONToABIContract(strings.NewReader(jsonPledge))
	ABIConsensusGroup, _ = abi.JSONToABIContract(strings.NewReader(jsonConsensusGroup))
	ABIMintage, _        = abi.JSONToABIContract(strings.NewReader(jsonMintage))
)
View Source
var (
	AddressRegister, _       = types.BytesToAddress([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1})
	AddressVote, _           = types.BytesToAddress([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2})
	AddressPledge, _         = types.BytesToAddress([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3})
	AddressConsensusGroup, _ = types.BytesToAddress([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4})
	AddressMintage, _        = types.BytesToAddress([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5})
)

Functions

func GetAddrFromVoteKey

func GetAddrFromVoteKey(key []byte) types.Address

func GetBeneficialFromPledgeKey

func GetBeneficialFromPledgeKey(key []byte) types.Address

func GetConsensusGroupKey

func GetConsensusGroupKey(gid types.Gid) []byte

func GetGidFromConsensusGroupKey

func GetGidFromConsensusGroupKey(key []byte) types.Gid

func GetGidFromCreateContractData

func GetGidFromCreateContractData(data []byte) types.Gid

func GetMintageKey

func GetMintageKey(tokenId types.TokenTypeId) []byte

func GetPledgeBeneficialAmount

func GetPledgeBeneficialAmount(db StorageDatabase, beneficial types.Address) *big.Int

func GetPledgeBeneficialKey

func GetPledgeBeneficialKey(beneficial types.Address) []byte

func GetPledgeKey

func GetPledgeKey(addr types.Address, pledgeBeneficialKey []byte) []byte

func GetRegisterKey

func GetRegisterKey(name string, gid types.Gid) []byte

func GetTokenIdFromMintageKey

func GetTokenIdFromMintageKey(key []byte) types.TokenTypeId

func GetTokenMap

func GetTokenMap(db StorageDatabase) map[types.TokenTypeId]*TokenInfo

func GetVoteKey

func GetVoteKey(addr types.Address, gid types.Gid) []byte

func IsPledgeKey

func IsPledgeKey(key []byte) bool

func NewContractAddress

func NewContractAddress(accountAddress types.Address, accountBlockHeight uint64, prevBlockHash types.Hash, snapshotHash types.Hash) types.Address

func NewGid

func NewGid(accountAddress types.Address, accountBlockHeight uint64, prevBlockHash types.Hash, snapshotHash types.Hash) types.Gid

func NewTokenId

func NewTokenId(accountAddress types.Address, accountBlockHeight uint64, prevBlockHash types.Hash, snapshotHash types.Hash) types.TokenTypeId

func PackConsensusGroupConditionParam

func PackConsensusGroupConditionParam(conditionIdPrefix ConditionCode, conditionId uint8, params ...interface{}) ([]byte, error)

pack consensus group condition params by condition id

func PackMethodParam

func PackMethodParam(contractsAddr types.Address, methodName string, params ...interface{}) ([]byte, error)

pack method params to byte slice

Types

type ConditionCode

type ConditionCode uint8
const (
	RegisterConditionPrefix   ConditionCode = 10
	VoteConditionPrefix       ConditionCode = 20
	RegisterConditionOfPledge ConditionCode = 11
	VoteConditionOfDefault    ConditionCode = 21
	VoteConditionOfBalance    ConditionCode = 22
)

type ConsensusGroupInfo

type ConsensusGroupInfo struct {
	Gid                    types.Gid         // Consensus group id
	NodeCount              uint8             // Active miner count
	Interval               int64             // Timestamp gap between two continuous block
	PerCount               int64             // Continuous block generation interval count
	RandCount              uint8             // Random miner count
	RandRank               uint8             // Chose random miner with a rank limit of vote
	CountingTokenId        types.TokenTypeId // Token id for selecting miner through vote
	RegisterConditionId    uint8
	RegisterConditionParam []byte
	VoteConditionId        uint8
	VoteConditionParam     []byte
	Owner                  types.Address
	PledgeAmount           *big.Int
	WithdrawHeight         uint64
}

func GetActiveConsensusGroupList

func GetActiveConsensusGroupList(db StorageDatabase) []*ConsensusGroupInfo

func GetConsensusGroup

func GetConsensusGroup(db StorageDatabase, gid types.Gid) *ConsensusGroupInfo

func (*ConsensusGroupInfo) IsActive

func (groupInfo *ConsensusGroupInfo) IsActive() bool

type ParamCancelPledge

type ParamCancelPledge struct {
	Beneficial types.Address
	Amount     *big.Int
}

type ParamCancelRegister

type ParamCancelRegister struct {
	Gid  types.Gid
	Name string
}

type ParamMintage

type ParamMintage struct {
	TokenId     types.TokenTypeId
	TokenName   string
	TokenSymbol string
	TotalSupply *big.Int
	Decimals    uint8
}

type ParamRegister

type ParamRegister struct {
	Gid            types.Gid
	Name           string
	NodeAddr       types.Address
	BeneficialAddr types.Address
}

type ParamReward

type ParamReward struct {
	Gid         types.Gid
	Name        string
	EndHeight   uint64
	StartHeight uint64
	Amount      *big.Int
}

type ParamVote

type ParamVote struct {
	Gid      types.Gid
	NodeName string
}

type PledgeInfo

type PledgeInfo struct {
	Amount         *big.Int
	WithdrawHeight uint64
	BeneficialAddr types.Address
}

func GetPledgeAmount

func GetPledgeAmount(db StorageDatabase, addr types.Address) []*PledgeInfo

type Registration

type Registration struct {
	Name           string
	NodeAddr       types.Address
	PledgeAddr     types.Address
	BeneficialAddr types.Address
	Amount         *big.Int
	PledgeHeight   uint64
	RewardHeight   uint64
	CancelHeight   uint64
}

func GetRegisterList

func GetRegisterList(db StorageDatabase, gid types.Gid) []*Registration

func (*Registration) IsActive

func (r *Registration) IsActive() bool

type StorageDatabase

type StorageDatabase interface {
	GetStorage(addr *types.Address, key []byte) []byte
	NewStorageIterator(prefix []byte) vmctxt_interface.StorageIterator
}

type TokenInfo

type TokenInfo struct {
	TokenName      string
	TokenSymbol    string
	TotalSupply    *big.Int
	Decimals       uint8
	Owner          types.Address
	PledgeAmount   *big.Int
	WithdrawHeight uint64
}

func GetTokenById

func GetTokenById(db StorageDatabase, tokenId types.TokenTypeId) *TokenInfo

type VariableConditionRegisterOfPledge

type VariableConditionRegisterOfPledge struct {
	PledgeAmount *big.Int
	PledgeToken  types.TokenTypeId
	PledgeHeight uint64
}

type VariableConditionVoteOfKeepToken

type VariableConditionVoteOfKeepToken struct {
	KeepAmount *big.Int
	KeepToken  types.TokenTypeId
}

type VariablePledgeBeneficial

type VariablePledgeBeneficial struct {
	Amount *big.Int
}

type VoteInfo

type VoteInfo struct {
	VoterAddr types.Address
	NodeName  string
}

func GetVoteList

func GetVoteList(db StorageDatabase, gid types.Gid) []*VoteInfo

Jump to

Keyboard shortcuts

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