2016-07-29 28 views

回答

0

在霧中轉到您的合同並運行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; 
     } 
    } 
} 

注意霧重命名/進行消毒的功能名稱,它可以被命名爲Winning Proposalwinning 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 
} 
相關問題