How to get results by running the voting code on Ethereum?

0 votes

I executed the code posted here on the MIST Ethereum Wallet, the problem is I can't find how to "stop" the voting and get the final result. Can someone help me?

Sep 18, 2018 in Blockchain by slayer
• 29,050 points
26 views

1 answer to this question.

0 votes

In mist go to your contract and run the winningProposal() function. This computes the winning proposal taking all previous votes into account.

/// @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;
        }
    }
}

It will return the ID of the proposal with the most votes. See proposals struct:

// This is a type for a single proposal.
struct Proposal
{
    bytes32 name;   // short name (up to 32 bytes)
    uint voteCount; // number of accumulated votes
}
answered Sep 18, 2018 by digger
• 27,620 points

Related Questions In Blockchain

+1 vote
1 answer

How does a miner get to know that a transaction is verified by all the nodes?

Contrary to the popular belief, it is ...READ MORE

answered Mar 26, 2018 in Blockchain by Johnathon
• 9,070 points
54 views
0 votes
1 answer

How to get notified when an event triggers on ethereum smart contract?

Here's a simple example for web3js 1.0.0.beta*: function handler ...READ MORE

answered Jun 8, 2018 in Blockchain by ariaholic
• 7,320 points
283 views
0 votes
1 answer

How to get account with ethers by default in ethereum private network?

Have you created an account before allocating ...READ MORE

answered Jan 9 in Blockchain by Omkar
• 67,120 points
28 views
0 votes
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured by TLS encryption in hashgraph architecture-hashgraph, ...READ MORE

answered Aug 6, 2018 in Blockchain by ariaholic
• 7,320 points
56 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
104 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to connect to already running go ethereum client using mist Ubuntu

Hey, you can solve the issue by using sudo ...READ MORE

answered Sep 18, 2018 in Blockchain by digger
• 27,620 points
40 views