// Return back the votes with their tallies calculated.
Return back the votes with their tallies calculated.
// Return back the votes with their tallies calculated .
func calculateTallies(accounts *Accounts, responses []Vote) []Vote {
	votes := make(map[VoteID]Vote, len(responses))
	for _, res := range responses {
		if _, exists := votes[res.ID()]; !exists {
			votes[res.ID()] = res
		}
		votes[res.ID()].SetTally(votes[res.ID()].Tally() + 1.0/float64(len(responses)))
	}
	for id, weight := range Normalize(WeighByTransactions(responses)) {
		votes[id].SetTally(votes[id].Tally() * weight)
	}
	for id, weight := range Normalize(WeighByStake(accounts, responses)) {
		votes[id].SetTally(votes[id].Tally() * weight)
	}
	total := float64(0)
	for _, vote := range votes {
		total += vote.Tally()
	}
	tallies := make([]Vote, 0, len(votes))
	for _, vote := range votes {
		vote.SetTally(vote.Tally() / total)
		tallies = append(tallies, vote)
	}
	return tallies
}
func calculateTallies ( accounts * Accounts , responses [ ] Vote ) [ ] Vote { votes := make ( map [ VoteID ] Vote , len ( responses ) ) for _ , res := range responses { if _ , exists := votes [ res . ID ( ) ] ; ! exists { votes [ res . ID ( ) ] = res } votes [ res . ID ( ) ] . SetTally ( votes [ res . ID ( ) ] . Tally ( ) + 1.0 / float64 ( len ( responses ) ) ) } for id , weight := range Normalize ( WeighByTransactions ( responses ) ) { votes [ id ] . SetTally ( votes [ id ] . Tally ( ) * weight ) } for id , weight := range Normalize ( WeighByStake ( accounts , responses ) ) { votes [ id ] . SetTally ( votes [ id ] . Tally ( ) * weight ) } total := float64 ( 0 ) for _ , vote := range votes { total += vote . Tally ( ) } tallies := make ( [ ] Vote , 0 , len ( votes ) ) for _ , vote := range votes { vote . SetTally ( vote . Tally ( ) / total ) tallies = append ( tallies , vote ) } return tallies }
Return back the votes with their tallies calculated.
Return back the votes with their tallies calculated .