![](/img/trans.png)
[英]How is the blockchain system(for instance ethereum) if i can change the code of the node and run it usually?
[英]How can I run the voting code on Ethereum and get the result?
在雾中转到你的合同并运行winningProposal()
函数。 这计算了考虑所有先前投票的获胜提议。
/// @dev Computes the winning proposal taking all
/// previous votes into account.
function winningProposal() constant
returns (uint winningProposal)
{
uint winningVoteCount = 0;
for (uint p = 0; p < proposals.length; p++) {
if (proposals[p].voteCount > winningVoteCount) {
winningVoteCount = proposals[p].voteCount;
winningProposal = p;
}
}
}
请注意,mist重命名/清理函数名称,它可以命名为Winning Proposal
或winning proposal
。 你可以不加任何参数调用它。
它将返回投票最多的提案的ID。 查看proposals
结构:
// This is a type for a single proposal.
struct Proposal
{
bytes32 name; // short name (up to 32 bytes)
uint voteCount; // number of accumulated votes
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.