[英]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.