Remove map from Proposal struct
This commit is contained in:
parent
02435bb1f8
commit
38975ac695
|
@ -40,7 +40,6 @@ type Proposal struct {
|
||||||
VotingStartBlock int64 // Height of the block where MinDeposit was reached. -1 if MinDeposit is not reached
|
VotingStartBlock int64 // Height of the block where MinDeposit was reached. -1 if MinDeposit is not reached
|
||||||
InitTotalVotingPower int64 // Total voting power when proposal enters voting period (default 0)
|
InitTotalVotingPower int64 // Total voting power when proposal enters voting period (default 0)
|
||||||
InitProcedureNumber int16 // Procedure number of the active procedure when proposal enters voting period (default -1)
|
InitProcedureNumber int16 // Procedure number of the active procedure when proposal enters voting period (default -1)
|
||||||
Votes map[string]int64 // Votes for each option (Yes, No, NoWithVeto, Abstain)
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -61,6 +60,7 @@ type ValidatorGovInfo struct {
|
||||||
`ProcedureNumber`. First ever procedure is found at index '1'. Index '0' is reserved for parameter `ActiveProcedureNumber` which returns the number of the current procedure.
|
`ProcedureNumber`. First ever procedure is found at index '1'. Index '0' is reserved for parameter `ActiveProcedureNumber` which returns the number of the current procedure.
|
||||||
* `Proposals`: A mapping `map[int64]Proposal` of proposals indexed by their
|
* `Proposals`: A mapping `map[int64]Proposal` of proposals indexed by their
|
||||||
`proposalID`
|
`proposalID`
|
||||||
|
* `Votes`: A mapping `map[[]byte]int64` of votes indexed by `<proposalID>:<option>` as `[]byte`. Given a `proposalID` and an `option`, returns votes for that option.
|
||||||
* `Deposits`: A mapping `map[[]byte]int64` of deposits indexed by
|
* `Deposits`: A mapping `map[[]byte]int64` of deposits indexed by
|
||||||
`<proposalID>:<depositorPubKey>` as `[]byte`. Given a `proposalID` and a
|
`<proposalID>:<depositorPubKey>` as `[]byte`. Given a `proposalID` and a
|
||||||
`PubKey`, returns deposit (`nil` if `PubKey` has not deposited on the
|
`PubKey`, returns deposit (`nil` if `PubKey` has not deposited on the
|
||||||
|
@ -110,8 +110,9 @@ And the pseudocode for the `ProposalProcessingQueue`:
|
||||||
proposalID = ProposalProcessingQueue.Peek()
|
proposalID = ProposalProcessingQueue.Peek()
|
||||||
proposal = load(Proposals, proposalID)
|
proposal = load(Proposals, proposalID)
|
||||||
initProcedure = load(Procedures, proposal.InitProcedureNumber)
|
initProcedure = load(Procedures, proposal.InitProcedureNumber)
|
||||||
|
yesVotes = load(Votes, <proposalID>:<'Yes'>)
|
||||||
|
|
||||||
if (proposal.Votes['Yes']/proposal.InitTotalVotingPower >= 2/3)
|
if (yesVotes/proposal.InitTotalVotingPower >= 2/3)
|
||||||
|
|
||||||
// proposal was urgent and accepted under the special condition
|
// proposal was urgent and accepted under the special condition
|
||||||
// no punishment
|
// no punishment
|
||||||
|
|
|
@ -264,8 +264,11 @@ And the associated pseudocode.
|
||||||
// Vote started
|
// Vote started
|
||||||
|
|
||||||
initProcedure = load(Procedures, proposal.InitProcedureNumber)
|
initProcedure = load(Procedures, proposal.InitProcedureNumber)
|
||||||
|
yesVotes = load(Votes, <txGovClaimDeposi.ProposalIDt>:<'Yes'>)
|
||||||
|
noVotes = load(Votes, <txGovClaimDeposit.ProposalID>:<'No'>)
|
||||||
|
noWithVetoVotes = load(Votes, <txGovClaimDeposit.ProposalID>:<'NoWithVeto'>)
|
||||||
|
|
||||||
if (proposal.Votes['Yes']/proposal.InitTotalVotingPower >= 2/3) OR ((CurrentBlock > proposal.VotingStartBlock + initProcedure.VotingPeriod) AND (proposal.Votes['NoWithVeto']/(proposal.Votes['Yes']+proposal.Votes['No']+proposal.Votes['NoWithVeto']) < 1/3) AND (proposal.Votes['Yes']/(proposal.Votes['Yes']+proposal.Votes['No']+proposal.Votes['NoWithVeto']) > 1/2)) then
|
if (yesVotes/proposal.InitTotalVotingPower >= 2/3) OR ((CurrentBlock > proposal.VotingStartBlock + initProcedure.VotingPeriod) AND (noWithVetoVotes/(yesVotes+noVotes+noWithVetoVotes)) < 1/3) AND (yesVotes/(yesVotes+noVotes+noWithVetoVotes)) > 1/2)) then
|
||||||
|
|
||||||
// Proposal was accepted either because
|
// Proposal was accepted either because
|
||||||
// pecial condition was met OR
|
// pecial condition was met OR
|
||||||
|
@ -293,10 +296,10 @@ vote on the proposal.
|
||||||
* If sender is not a validator and validator has not voted, initialize or
|
* If sender is not a validator and validator has not voted, initialize or
|
||||||
increase minus of validator by sender's `voting power`
|
increase minus of validator by sender's `voting power`
|
||||||
* If sender is not a validator and validator has voted, decrease
|
* If sender is not a validator and validator has voted, decrease
|
||||||
`proposal.Votes['validatorOption']` by sender's `voting power`
|
`Votes['validatorOption']` by sender's `voting power`
|
||||||
* If sender is not a validator, increase `[proposal.Votes['txGovVote.Option']`
|
* If sender is not a validator, increase `Votes['txGovVote.Option']`
|
||||||
by sender's `voting power`
|
by sender's `voting power`
|
||||||
* If sender is a validator, increase `proposal.Votes['txGovVote.Option']` by
|
* If sender is a validator, increase `Votes['txGovVote.Option']` by
|
||||||
validator's `InitialVotingPower - minus` (`minus` can be equal to 0)
|
validator's `InitialVotingPower - minus` (`minus` can be equal to 0)
|
||||||
|
|
||||||
Votes need to be tied to a validator in order to compute validator's voting
|
Votes need to be tied to a validator in order to compute validator's voting
|
||||||
|
@ -348,11 +351,13 @@ handled:
|
||||||
throw
|
throw
|
||||||
|
|
||||||
else
|
else
|
||||||
|
yesVotes = load(Votes, <txGovVote.ProposalID>:<'Yes'>)
|
||||||
|
|
||||||
if (proposal.VotingStartBlock < 0) OR
|
if (proposal.VotingStartBlock < 0) OR
|
||||||
(CurrentBlock > proposal.VotingStartBlock + initProcedure.VotingPeriod) OR
|
(CurrentBlock > proposal.VotingStartBlock + initProcedure.VotingPeriod) OR
|
||||||
(proposal.VotingStartBlock < lastBondingBlock(sender, txGovVote.ValidatorPubKey) OR
|
(proposal.VotingStartBlock < lastBondingBlock(sender, txGovVote.ValidatorPubKey) OR
|
||||||
(proposal.VotingStartBlock < lastUnbondingBlock(sender, txGovVote.ValidatorPubKey) OR
|
(proposal.VotingStartBlock < lastUnbondingBlock(sender, txGovVote.ValidatorPubKey) OR
|
||||||
(proposal.Votes['Yes']/proposal.InitTotalVotingPower >= 2/3) then
|
(yesVotes/proposal.InitTotalVotingPower >= 2/3) then
|
||||||
|
|
||||||
// Throws if
|
// Throws if
|
||||||
// Vote has not started OR if
|
// Vote has not started OR if
|
||||||
|
@ -397,14 +402,18 @@ handled:
|
||||||
// Validator has already voted
|
// Validator has already voted
|
||||||
// Reduce votes of option chosen by validator by sender's bonded Amount
|
// Reduce votes of option chosen by validator by sender's bonded Amount
|
||||||
|
|
||||||
proposal.Votes['validatorOption'] -= sender.bondedAmountTo(txGovVote.ValidatorPubKey)
|
validatorVotes = load(Votes, <txGovVote.ProposalID>:<'validatorOption'>)
|
||||||
|
store(Votes, <txGovVote.ProposalID>:<'validatorOption'>, validatorVotes - sender.bondedAmountTo(txGovVote.ValidatorPubKey))
|
||||||
|
|
||||||
// increase votes of option chosen by sender by bonded Amount
|
// increase votes of option chosen by sender by bonded Amount
|
||||||
proposal.Votes['txGovVote.Option'] += sender.bondedAmountTo(txGovVote.ValidatorPubKey)
|
optionVotes = load(Votes, <txGovVote.ProposalID>:<txGovVote.Option>)
|
||||||
|
store(Votes,<txGovVote.ProposalID>:<txGovVote.Option>, optionVotes + sender.bondedAmountTo(txGovVote.ValidatorPubKey))
|
||||||
|
|
||||||
|
|
||||||
else
|
else
|
||||||
// sender is the Governance PubKey of the validator whose main PubKey is txGovVote.ValidatorPubKey
|
// sender is the Governance PubKey of the validator whose main PubKey is txGovVote.ValidatorPubKey
|
||||||
// i.e. sender == validator
|
// i.e. sender == validator
|
||||||
|
|
||||||
proposal.Votes['txGovVote.Option'] += (validatorGovInfo.InitVotingPower - validatorGovInfo.Minus)
|
optionVotes = load(Votes, <txGovVote.ProposalID>:<txGovVote.Option>)
|
||||||
|
store(Votes,<txGovVote.ProposalID>:<txGovVote.Option>, optionVotes + (validatorGovInfo.InitVotingPower - validatorGovInfo.Minus))
|
||||||
```
|
```
|
Loading…
Reference in New Issue