Documentation ¶
Index ¶
- Constants
- Variables
- func AccuVerifiers(blockHash common.Hash, proposalID common.Hash, verifierList []discover.NodeID) error
- func AddActiveNode(blockHash common.Hash, proposalID common.Hash, nodeID discover.NodeID) error
- func AddActiveVersion(activeVersion uint32, activeBlock uint64, state xcom.StateDB) error
- func AddPIPID(pipID string, state xcom.StateDB) error
- func AddVoteValue(proposalID common.Hash, voter discover.NodeID, option VoteOption, ...) error
- func AddVotingProposalID(blockHash common.Hash, proposalID common.Hash) error
- func ClearAccuVerifiers(blockHash common.Hash, proposalID common.Hash) error
- func ClearActiveNodes(blockHash common.Hash, proposalID common.Hash) error
- func ClearProcessingProposals(blockHash common.Hash, state xcom.StateDB) error
- func ClearVoteValue(proposalID common.Hash, blockHash common.Hash) error
- func DeclareVersion(from common.Address, declaredNodeID discover.NodeID, declaredVersion uint32, ...) error
- func GetActiveNodeList(blockHash common.Hash, proposalID common.Hash) ([]discover.NodeID, error)
- func GetCurrentActiveVersion(state xcom.StateDB) uint32
- func GetGovernParamValue(module, name string, blockNumber uint64, blockHash common.Hash) (string, error)
- func GetMaxEndVotingBlock(nodeID discover.NodeID, blockHash common.Hash, state xcom.StateDB) (uint64, error)
- func GetPreActiveProposalID(blockHash common.Hash) (common.Hash, error)
- func GetPreActiveVersion(blockHash common.Hash) uint32
- func GetVersionForStaking(blockHash common.Hash, state xcom.StateDB) uint32
- func GetVotedVerifierMap(proposalID common.Hash, blockHash common.Hash) (map[discover.NodeID]struct{}, error)
- func GovernDuplicateSignReportReward(blockNumber uint64, blockHash common.Hash) (uint32, error)
- func GovernIncreaseIssuanceRatio(blockNumber uint64, blockHash common.Hash) (uint16, error)
- func GovernMaxBlockGasLimit(blockNumber uint64, blockHash common.Hash) (int, error)
- func GovernMaxEvidenceAge(blockNumber uint64, blockHash common.Hash) (uint32, error)
- func GovernMaxValidators(blockNumber uint64, blockHash common.Hash) (uint64, error)
- func GovernOperatingThreshold(blockNumber uint64, blockHash common.Hash) (*big.Int, error)
- func GovernRestrictingMinimumAmount(blockNumber uint64, blockHash common.Hash) (*big.Int, error)
- func GovernRewardPerChangeInterval(blockNumber uint64, blockHash common.Hash) (uint16, error)
- func GovernRewardPerMaxChangeRange(blockNumber uint64, blockHash common.Hash) (uint16, error)
- func GovernSlashBlocksReward(blockNumber uint64, blockHash common.Hash) (uint32, error)
- func GovernSlashFractionDuplicateSign(blockNumber uint64, blockHash common.Hash) (uint32, error)
- func GovernStakeThreshold(blockNumber uint64, blockHash common.Hash) (*big.Int, error)
- func GovernUnDelegateFreezeDuration(blockNumber uint64, blockHash common.Hash) (uint64, error)
- func GovernUnStakeFreezeDuration(blockNumber uint64, blockHash common.Hash) (uint64, error)
- func GovernZeroProduceCumulativeTime(blockNumber uint64, blockHash common.Hash) (uint16, error)
- func GovernZeroProduceFreezeDuration(blockNumber uint64, blockHash common.Hash) (uint64, error)
- func GovernZeroProduceNumberThreshold(blockNumber uint64, blockHash common.Hash) (uint16, error)
- func Gte110Version(version uint32) bool
- func Gte110VersionState(state xcom.StateDB) bool
- func Gte120Version(version uint32) bool
- func Gte120VersionState(state xcom.StateDB) bool
- func Gte130Version(version uint32) bool
- func Gte130VersionState(state xcom.StateDB) bool
- func Gte140Version(version uint32) bool
- func Gte140VersionState(state xcom.StateDB) bool
- func InitGenesisGovernParam(prevHash common.Hash, snapDB snapshotdb.BaseDB, genesisVersion uint32) (common.Hash, error)
- func KeyAccuVerifier(proposalID common.Hash) []byte
- func KeyActiveNodes(proposalID common.Hash) []byte
- func KeyActiveVersions() []byte
- func KeyEndProposals() []byte
- func KeyGovernHASHKey() []byte
- func KeyPIPIDs() []byte
- func KeyParamItems() []byte
- func KeyParamValue(module, name string) []byte
- func KeyPreActiveProposal() []byte
- func KeyPreActiveVersion() []byte
- func KeyProposal(proposalID common.Hash) []byte
- func KeyTallyResult(proposalID common.Hash) []byte
- func KeyVote(proposalID common.Hash) []byte
- func KeyVotingProposals() []byte
- func ListAccuVerifier(blockHash common.Hash, proposalID common.Hash) ([]discover.NodeID, error)
- func ListEndProposalID(blockHash common.Hash) ([]common.Hash, error)
- func ListPIPID(state xcom.StateDB) ([]string, error)
- func ListVotingProposal(blockHash common.Hash) ([]common.Hash, error)
- func ListVotingProposalID(blockHash common.Hash) ([]common.Hash, error)
- func MovePreActiveProposalIDToEnd(blockHash common.Hash, proposalID common.Hash) error
- func MoveVotingProposalIDToEnd(proposalID common.Hash, blockHash common.Hash) error
- func MoveVotingProposalIDToPreActive(blockHash common.Hash, proposalID common.Hash, preactiveVersion uint32) error
- func NotifyPunishedVerifiers(blockHash common.Hash, punishedVerifierMap map[discover.NodeID]struct{}, ...) error
- func RegGovernParamVerifier(module, name string, callback ParamVerifier)
- func RegisterGovernParamVerifiers()
- func Set130Param(blockNumber uint64, hash common.Hash, db snapshotdb.DB, chainDB ethdb.Writer) error
- func SetEcParametersHash(state xcom.StateDB, rlpData []byte)
- func SetGovernParam(module, name, desc, initValue string, activeBlockNumber uint64, ...) error
- func SetPreActiveVersion(blockHash common.Hash, preActiveVersion uint32) error
- func SetProposal(proposal Proposal, state xcom.StateDB) error
- func SetTallyResult(tallyResult TallyResult, state xcom.StateDB) error
- func Submit(from common.Address, proposal Proposal, blockHash common.Hash, ...) error
- func TallyVoteValue(proposalID common.Hash, blockHash common.Hash) (yeas, nays, abstentions uint64, e error)
- func UpdateGovernParamValue(module, name string, newValue string, activeBlock uint64, ...) error
- func UpdateVoteValue(proposalID common.Hash, voteValueList []VoteValue, blockHash common.Hash) error
- func Vote(from common.Address, vote VoteInfo, blockHash common.Hash, blockNumber uint64, ...) error
- func WriteEcHash130(state xcom.StateDB) error
- type ActiveVersionValue
- type CancelProposal
- func (cp *CancelProposal) GetEndVotingBlock() uint64
- func (cp *CancelProposal) GetPIPID() string
- func (cp *CancelProposal) GetProposalID() common.Hash
- func (cp *CancelProposal) GetProposalType() ProposalType
- func (cp *CancelProposal) GetProposer() discover.NodeID
- func (cp *CancelProposal) GetSubmitBlock() uint64
- func (cp *CancelProposal) GetTallyResult() TallyResult
- func (cp *CancelProposal) String() string
- func (cp *CancelProposal) Verify(submitBlock uint64, blockHash common.Hash, state xcom.StateDB) error
- type GovernParam
- type ParamItem
- type ParamProposal
- func (pp *ParamProposal) GetEndVotingBlock() uint64
- func (pp *ParamProposal) GetPIPID() string
- func (pp *ParamProposal) GetProposalID() common.Hash
- func (pp *ParamProposal) GetProposalType() ProposalType
- func (pp *ParamProposal) GetProposer() discover.NodeID
- func (pp *ParamProposal) GetSubmitBlock() uint64
- func (pp *ParamProposal) GetTallyResult() TallyResult
- func (pp *ParamProposal) String() string
- func (pp *ParamProposal) Verify(submitBlock uint64, blockHash common.Hash, state xcom.StateDB) error
- type ParamValue
- type ParamVerifier
- type Proposal
- func FindVotingProposal(blockHash common.Hash, state xcom.StateDB, proposalTypes ...ProposalType) (Proposal, error)
- func GetExistProposal(proposalID common.Hash, state xcom.StateDB) (Proposal, error)
- func GetProposal(proposalID common.Hash, state xcom.StateDB) (Proposal, error)
- func GetProposalList(blockHash common.Hash, state xcom.StateDB) ([]Proposal, error)
- func ListProposal(blockHash common.Hash, state xcom.StateDB) ([]Proposal, error)
- type ProposalStatus
- type ProposalType
- type Staking
- type TallyResult
- type TextProposal
- func (tp *TextProposal) GetEndVotingBlock() uint64
- func (tp *TextProposal) GetPIPID() string
- func (tp *TextProposal) GetProposalID() common.Hash
- func (tp *TextProposal) GetProposalType() ProposalType
- func (tp *TextProposal) GetProposer() discover.NodeID
- func (tp *TextProposal) GetSubmitBlock() uint64
- func (tp *TextProposal) GetTallyResult() TallyResult
- func (tp *TextProposal) String() string
- func (tp *TextProposal) Verify(submitBlock uint64, blockHash common.Hash, state xcom.StateDB) error
- type VersionProposal
- func (vp *VersionProposal) GetActiveBlock() uint64
- func (vp *VersionProposal) GetEndVotingBlock() uint64
- func (vp *VersionProposal) GetNewVersion() uint32
- func (vp *VersionProposal) GetPIPID() string
- func (vp *VersionProposal) GetProposalID() common.Hash
- func (vp *VersionProposal) GetProposalType() ProposalType
- func (vp *VersionProposal) GetProposer() discover.NodeID
- func (vp *VersionProposal) GetSubmitBlock() uint64
- func (vp *VersionProposal) GetTallyResult() TallyResult
- func (vp *VersionProposal) String() string
- func (vp *VersionProposal) Verify(submitBlock uint64, blockHash common.Hash, state xcom.StateDB) error
- type VoteInfo
- type VoteOption
- type VoteValue
Constants ¶
const ( ModuleStaking = "staking" ModuleSlashing = "slashing" ModuleBlock = "block" ModuleTxPool = "txPool" ModuleReward = "reward" ModuleRestricting = "restricting" )
const ( KeyStakeThreshold = "stakeThreshold" KeyOperatingThreshold = "operatingThreshold" KeyMaxValidators = "maxValidators" KeyUnStakeFreezeDuration = "unStakeFreezeDuration" KeySlashFractionDuplicateSign = "slashFractionDuplicateSign" KeyDuplicateSignReportReward = "duplicateSignReportReward" KeyMaxEvidenceAge = "maxEvidenceAge" KeySlashBlocksReward = "slashBlocksReward" KeyMaxBlockGasLimit = "maxBlockGasLimit" KeyMaxTxDataLimit = "maxTxDataLimit" KeyZeroProduceNumberThreshold = "zeroProduceNumberThreshold" KeyZeroProduceCumulativeTime = "zeroProduceCumulativeTime" KeyRewardPerMaxChangeRange = "rewardPerMaxChangeRange" KeyRewardPerChangeInterval = "rewardPerChangeInterval" KeyIncreaseIssuanceRatio = "increaseIssuanceRatio" KeyZeroProduceFreezeDuration = "zeroProduceFreezeDuration" KeyRestrictingMinimumAmount = "minimumRelease" KeyUnDelegateFreezeDuration = "unDelegateFreezeDuration" )
const RateCoefficient = uint64(10000)
in genesis.json, the config value of the supportRate( and voteRate...) is the real value * 10000. the RateCoefficient is used to calculate the supportRate (and voteRate) of a proposal correctly.
Variables ¶
var ( ActiveVersionError = common.NewBizError(302001, "Current active version not found") VoteOptionError = common.NewBizError(302002, "Illegal voting option") ProposalTypeError = common.NewBizError(302003, "Illegal proposal type") ProposalIDEmpty = common.NewBizError(302004, "Proposal ID is null") ProposalIDExist = common.NewBizError(302005, "Proposal ID already existed") ProposalNotFound = common.NewBizError(302006, "Proposal not found") PIPIDEmpty = common.NewBizError(302007, "PIPID is null") PIPIDExist = common.NewBizError(302008, "PIPID already existed") EndVotingRoundsTooSmall = common.NewBizError(302009, "EndVotingRounds is too small") EndVotingRoundsTooLarge = common.NewBizError(302010, "EndVotingRounds is too large") NewVersionError = common.NewBizError(302011, "NewVersion should larger than current active version") VotingVersionProposalExist = common.NewBizError(302012, "Another version proposal already existed at voting stage") PreActiveVersionProposalExist = common.NewBizError(302013, "Another version proposal already existed at pre-active stage") VotingCancelProposalExist = common.NewBizError(302014, "Another cancel proposal already existed at voting stage") TobeCanceledProposalNotFound = common.NewBizError(302015, "The proposal to be canceled is not found") TobeCanceledProposalTypeError = common.NewBizError(302016, "The proposal to be canceled proposal has an illegal version type") TobeCanceledProposalNotAtVoting = common.NewBizError(302017, "The proposal to be canceled is not at voting stage") ProposerEmpty = common.NewBizError(302018, "The proposer is null") VerifierInfoNotFound = common.NewBizError(302019, "Detailed verifier information is not found") VerifierStatusInvalid = common.NewBizError(302020, "The verifier status is invalid") TxSenderDifferFromStaking = common.NewBizError(302021, "Transaction account is inconsistent with the staking account") TxSenderIsNotVerifier = common.NewBizError(302022, "Transaction node is not the validator") TxSenderIsNotCandidate = common.NewBizError(302023, "Transaction node is not the candidate") VersionSignError = common.NewBizError(302024, "Invalid version signature") VerifierNotUpgraded = common.NewBizError(302025, "Verifier does not upgraded to the latest version") ProposalNotAtVoting = common.NewBizError(302026, "The proposal is not at voting stage") VoteDuplicated = common.NewBizError(302027, "Duplicated votes found") DeclareVersionError = common.NewBizError(302028, "Declared version is invalid") NotifyStakingDeclaredVersionError = common.NewBizError(302029, "Error is found when notifying staking for the declared version") TallyResultNotFound = common.NewBizError(302030, "The result of proposal is not found") UnsupportedGovernParam = common.NewBizError(302031, "Unsupported governent parameter") VotingParamProposalExist = common.NewBizError(302032, "Another parameter proposal already existed at voting stage") GovernParamValueError = common.NewBizError(302033, "Govern parameter value error") ParamProposalIsSameValue = common.NewBizError(302034, "The new value of the parameter proposal is the same as the old one") )
var (
KeyDelimiter = []byte(":")
)
var ParamVerifierMap = make(map[string]ParamVerifier)
var UnDelegateFreezeDurationVerifier = func(blockNumber uint64, blockHash common.Hash, value string) error { num, err := strconv.Atoi(value) if nil != err { return fmt.Errorf("Parsed UnDelegateFreezeDuration is failed: %v", err) } Duration, err := GovernUnStakeFreezeDuration(blockNumber, blockHash) if nil != err { return err } if err := xcom.CheckUnDelegateFreezeDuration(num, int(Duration)); nil != err { return err } return nil }
var (
ValueDelimiter = []byte(":")
)
Functions ¶
func AccuVerifiers ¶
func AccuVerifiers(blockHash common.Hash, proposalID common.Hash, verifierList []discover.NodeID) error
AccuVerifiers accumulates all distinct verifiers those can vote this proposal ID
func AddActiveNode ¶
Add the node that has made a new version declare or vote during voting period
func AddActiveVersion ¶
Set active version record
func AddVoteValue ¶ added in v0.7.3
func AddVoteValue(proposalID common.Hash, voter discover.NodeID, option VoteOption, blockHash common.Hash) error
Add the Vote detail
func AddVotingProposalID ¶
func ClearAccuVerifiers ¶ added in v0.7.5
func ClearActiveNodes ¶
Clear the version declaration records after upgrade
func ClearProcessingProposals ¶ added in v0.7.5
func ClearVoteValue ¶ added in v0.7.4
func DeclareVersion ¶
func DeclareVersion(from common.Address, declaredNodeID discover.NodeID, declaredVersion uint32, programVersionSign common.VersionSign, blockHash common.Hash, blockNumber uint64, stk Staking, state xcom.StateDB) error
node declares it's version
func GetActiveNodeList ¶
Get the node list that have made a new version declare or vote during voting period
func GetCurrentActiveVersion ¶
Get current active version record
func GetGovernParamValue ¶ added in v0.7.4
func GetMaxEndVotingBlock ¶
func GetMaxEndVotingBlock(nodeID discover.NodeID, blockHash common.Hash, state xcom.StateDB) (uint64, error)
GetMaxEndVotingBlock returns the max endVotingBlock of proposals those are at voting stage, and the nodeID has voted for those proposals. or returns 0 if there's no proposal at voting stage, or nodeID didn't voted for any proposal. if any error happened, return 0 and the error
func GetPreActiveProposalID ¶
func GetPreActiveVersion ¶
Get pre-active version
func GetVersionForStaking ¶
func GetVotedVerifierMap ¶ added in v0.7.3
func GovernDuplicateSignReportReward ¶ added in v0.7.4
func GovernIncreaseIssuanceRatio ¶ added in v1.0.0
func GovernMaxBlockGasLimit ¶ added in v0.7.4
func GovernMaxEvidenceAge ¶ added in v0.7.4
func GovernMaxValidators ¶ added in v0.7.4
func GovernOperatingThreshold ¶ added in v0.7.4
func GovernRestrictingMinimumAmount ¶ added in v1.0.0
func GovernRewardPerChangeInterval ¶ added in v1.0.0
func GovernRewardPerMaxChangeRange ¶ added in v1.0.0
func GovernSlashBlocksReward ¶ added in v0.7.4
func GovernSlashFractionDuplicateSign ¶ added in v0.7.4
func GovernStakeThreshold ¶ added in v0.7.4
func GovernUnDelegateFreezeDuration ¶ added in v1.3.0
func GovernUnStakeFreezeDuration ¶ added in v0.7.4
func GovernZeroProduceCumulativeTime ¶ added in v1.0.0
func GovernZeroProduceFreezeDuration ¶ added in v1.0.0
func GovernZeroProduceNumberThreshold ¶ added in v1.0.0
func Gte110Version ¶ added in v1.1.0
func Gte110VersionState ¶ added in v1.1.0
func Gte120Version ¶ added in v1.2.0
func Gte120VersionState ¶ added in v1.2.0
func Gte130Version ¶ added in v1.3.0
func Gte130VersionState ¶ added in v1.3.0
func Gte140Version ¶ added in v1.3.2
func Gte140VersionState ¶ added in v1.3.2
func InitGenesisGovernParam ¶ added in v0.7.4
func KeyAccuVerifier ¶
func KeyActiveNodes ¶
func KeyActiveVersions ¶
func KeyActiveVersions() []byte
func KeyEndProposals ¶
func KeyEndProposals() []byte
func KeyGovernHASHKey ¶ added in v1.0.0
func KeyGovernHASHKey() []byte
func KeyParamItems ¶ added in v0.7.4
func KeyParamItems() []byte
func KeyParamValue ¶ added in v0.7.4
func KeyPreActiveProposal ¶
func KeyPreActiveProposal() []byte
func KeyPreActiveVersion ¶
func KeyPreActiveVersion() []byte
func KeyProposal ¶
func KeyTallyResult ¶
func KeyVotingProposals ¶
func KeyVotingProposals() []byte
func ListAccuVerifier ¶
Get the total number of all voting verifiers
func ListVotingProposal ¶
Get voting proposal
func ListVotingProposalID ¶
list all proposal IDs at voting stage
func NotifyPunishedVerifiers ¶
func NotifyPunishedVerifiers(blockHash common.Hash, punishedVerifierMap map[discover.NodeID]struct{}, state xcom.StateDB) error
NotifyPunishedVerifiers receives punished verifies notification from Staking
func RegGovernParamVerifier ¶ added in v0.7.4
func RegGovernParamVerifier(module, name string, callback ParamVerifier)
func RegisterGovernParamVerifiers ¶ added in v0.7.4
func RegisterGovernParamVerifiers()
func Set130Param ¶ added in v1.3.0
func SetEcParametersHash ¶ added in v1.3.0
func SetGovernParam ¶ added in v0.7.4
func SetPreActiveVersion ¶
Set pre-active version
func SetTallyResult ¶
func SetTallyResult(tallyResult TallyResult, state xcom.StateDB) error
func Submit ¶
func Submit(from common.Address, proposal Proposal, blockHash common.Hash, blockNumber uint64, stk Staking, state xcom.StateDB, chainID *big.Int) error
submit a proposal
func TallyVoteValue ¶
func TallyVoteValue(proposalID common.Hash, blockHash common.Hash) (yeas, nays, abstentions uint64, e error)
TallyVoteValue statistics vote option for a proposal
func UpdateGovernParamValue ¶ added in v0.7.4
func UpdateVoteValue ¶ added in v0.7.3
func Vote ¶
func Vote(from common.Address, vote VoteInfo, blockHash common.Hash, blockNumber uint64, programVersion uint32, programVersionSign common.VersionSign, stk Staking, state xcom.StateDB) error
vote for a proposal
func WriteEcHash130 ¶ added in v1.3.0
Types ¶
type ActiveVersionValue ¶
type ActiveVersionValue struct { ActiveVersion uint32 `json:"ActiveVersion"` ActiveBlock uint64 `json:"ActiveBlock"` }
func ListActiveVersion ¶
func ListActiveVersion(state xcom.StateDB) ([]ActiveVersionValue, error)
type CancelProposal ¶
type CancelProposal struct { ProposalID common.Hash ProposalType ProposalType PIPID string SubmitBlock uint64 EndVotingRounds uint64 EndVotingBlock uint64 Proposer discover.NodeID TobeCanceled common.Hash Result TallyResult `json:"-"` }
func (*CancelProposal) GetEndVotingBlock ¶
func (cp *CancelProposal) GetEndVotingBlock() uint64
func (*CancelProposal) GetPIPID ¶
func (cp *CancelProposal) GetPIPID() string
func (*CancelProposal) GetProposalID ¶
func (cp *CancelProposal) GetProposalID() common.Hash
func (*CancelProposal) GetProposalType ¶
func (cp *CancelProposal) GetProposalType() ProposalType
func (*CancelProposal) GetProposer ¶
func (cp *CancelProposal) GetProposer() discover.NodeID
func (*CancelProposal) GetSubmitBlock ¶
func (cp *CancelProposal) GetSubmitBlock() uint64
func (*CancelProposal) GetTallyResult ¶
func (cp *CancelProposal) GetTallyResult() TallyResult
func (*CancelProposal) String ¶
func (cp *CancelProposal) String() string
type GovernParam ¶ added in v0.7.4
type GovernParam struct { ParamItem *ParamItem ParamValue *ParamValue ParamVerifier ParamVerifier `json:"-"` }
func FindGovernParam ¶ added in v0.7.4
func FindGovernParam(module, name string, blockHash common.Hash) (*GovernParam, error)
func ListGovernParam ¶ added in v0.7.4
func ListGovernParam(module string, blockHash common.Hash) ([]*GovernParam, error)
type ParamProposal ¶ added in v0.7.4
type ParamProposal struct { ProposalID common.Hash ProposalType ProposalType PIPID string SubmitBlock uint64 EndVotingBlock uint64 Proposer discover.NodeID Result TallyResult `json:"-"` Module string Name string NewValue string }
func (*ParamProposal) GetEndVotingBlock ¶ added in v0.7.4
func (pp *ParamProposal) GetEndVotingBlock() uint64
func (*ParamProposal) GetPIPID ¶ added in v0.7.4
func (pp *ParamProposal) GetPIPID() string
func (*ParamProposal) GetProposalID ¶ added in v0.7.4
func (pp *ParamProposal) GetProposalID() common.Hash
func (*ParamProposal) GetProposalType ¶ added in v0.7.4
func (pp *ParamProposal) GetProposalType() ProposalType
func (*ParamProposal) GetProposer ¶ added in v0.7.4
func (pp *ParamProposal) GetProposer() discover.NodeID
func (*ParamProposal) GetSubmitBlock ¶ added in v0.7.4
func (pp *ParamProposal) GetSubmitBlock() uint64
func (*ParamProposal) GetTallyResult ¶ added in v0.7.4
func (pp *ParamProposal) GetTallyResult() TallyResult
func (*ParamProposal) String ¶ added in v0.7.4
func (pp *ParamProposal) String() string
type ParamValue ¶
type ParamVerifier ¶ added in v0.7.4
type Proposal ¶
type Proposal interface { GetProposalID() common.Hash GetProposalType() ProposalType GetPIPID() string GetSubmitBlock() uint64 GetEndVotingBlock() uint64 GetProposer() discover.NodeID GetTallyResult() TallyResult Verify(blockNumber uint64, blockHash common.Hash, state xcom.StateDB) error String() string }
func FindVotingProposal ¶ added in v0.7.4
func FindVotingProposal(blockHash common.Hash, state xcom.StateDB, proposalTypes ...ProposalType) (Proposal, error)
find a proposal at voting stage
func GetExistProposal ¶
func GetProposalList ¶
Select proposal id list from snapshot database ,then get proposal detail from statedb one by one
type ProposalStatus ¶
type ProposalStatus uint8
const ( Voting ProposalStatus = 0x01 Pass ProposalStatus = 0x02 Failed ProposalStatus = 0x03 PreActive ProposalStatus = 0x04 Active ProposalStatus = 0x05 Canceled ProposalStatus = 0x06 )
func (ProposalStatus) ToString ¶
func (status ProposalStatus) ToString() string
type ProposalType ¶
type ProposalType uint8
const ( Text ProposalType = 0x01 Version ProposalType = 0x02 Param ProposalType = 0x03 Cancel ProposalType = 0x04 )
type Staking ¶
type Staking interface { GetVerifierList(blockHash common.Hash, blockNumber uint64, isCommit bool) (staking.ValidatorExQueue, error) ListVerifierNodeID(blockHash common.Hash, blockNumber uint64) ([]discover.NodeID, error) GetCanBaseList(blockHash common.Hash, blockNumber uint64) (staking.CandidateBaseQueue, error) GetCandidateInfo(blockHash common.Hash, addr common.NodeAddress) (*staking.Candidate, error) GetCanBase(blockHash common.Hash, addr common.NodeAddress) (*staking.CandidateBase, error) GetCanMutable(blockHash common.Hash, addr common.NodeAddress) (*staking.CandidateMutable, error) DeclarePromoteNotify(blockHash common.Hash, blockNumber uint64, nodeId discover.NodeID, programVersion uint32) error }
type TallyResult ¶
type TallyResult struct { ProposalID common.Hash `json:"proposalID"` Yeas uint64 `json:"yeas"` Nays uint64 `json:"nays"` Abstentions uint64 `json:"abstentions"` AccuVerifiers uint64 `json:"accuVerifiers"` Status ProposalStatus `json:"status"` CanceledBy common.Hash `json:"canceledBy"` }
func GetTallyResult ¶
type TextProposal ¶
type TextProposal struct { ProposalID common.Hash ProposalType ProposalType PIPID string SubmitBlock uint64 EndVotingBlock uint64 Proposer discover.NodeID Result TallyResult `json:"-"` }
func (*TextProposal) GetEndVotingBlock ¶
func (tp *TextProposal) GetEndVotingBlock() uint64
func (*TextProposal) GetPIPID ¶
func (tp *TextProposal) GetPIPID() string
func (*TextProposal) GetProposalID ¶
func (tp *TextProposal) GetProposalID() common.Hash
func (*TextProposal) GetProposalType ¶
func (tp *TextProposal) GetProposalType() ProposalType
func (*TextProposal) GetProposer ¶
func (tp *TextProposal) GetProposer() discover.NodeID
func (*TextProposal) GetSubmitBlock ¶
func (tp *TextProposal) GetSubmitBlock() uint64
func (*TextProposal) GetTallyResult ¶
func (tp *TextProposal) GetTallyResult() TallyResult
func (*TextProposal) String ¶
func (tp *TextProposal) String() string
type VersionProposal ¶
type VersionProposal struct { ProposalID common.Hash ProposalType ProposalType PIPID string SubmitBlock uint64 EndVotingRounds uint64 EndVotingBlock uint64 Proposer discover.NodeID Result TallyResult `json:"-"` NewVersion uint32 ActiveBlock uint64 }
func (*VersionProposal) GetActiveBlock ¶
func (vp *VersionProposal) GetActiveBlock() uint64
func (*VersionProposal) GetEndVotingBlock ¶
func (vp *VersionProposal) GetEndVotingBlock() uint64
func (*VersionProposal) GetNewVersion ¶
func (vp *VersionProposal) GetNewVersion() uint32
func (*VersionProposal) GetPIPID ¶
func (vp *VersionProposal) GetPIPID() string
func (*VersionProposal) GetProposalID ¶
func (vp *VersionProposal) GetProposalID() common.Hash
func (*VersionProposal) GetProposalType ¶
func (vp *VersionProposal) GetProposalType() ProposalType
func (*VersionProposal) GetProposer ¶
func (vp *VersionProposal) GetProposer() discover.NodeID
func (*VersionProposal) GetSubmitBlock ¶
func (vp *VersionProposal) GetSubmitBlock() uint64
func (*VersionProposal) GetTallyResult ¶
func (vp *VersionProposal) GetTallyResult() TallyResult
func (*VersionProposal) String ¶
func (vp *VersionProposal) String() string
type VoteInfo ¶
type VoteInfo struct { ProposalID common.Hash `json:"proposalID"` VoteNodeID discover.NodeID `json:"voteNodeID"` VoteOption VoteOption `json:"voteOption"` }
type VoteOption ¶
type VoteOption uint8
const ( Yes VoteOption = 0x01 No VoteOption = 0x02 Abstention VoteOption = 0x03 )
func ParseVoteOption ¶
func ParseVoteOption(option uint8) VoteOption