Forum for discussion of mid, final term and final project

Gas consumption with feedback tuple in COBrA DAPP

Gas consumption with feedback tuple in COBrA DAPP

by ALDO D'AQUINO -
Number of replies: 1

"Content feedback is expressed as a numerical tuple where each element corresponds to the score chosen by the customer to rate the content in a given category."

According to this statement the feedback of an user about a content must be saved in an array, and that means that each time I want to know the rating of a content we must calculate it iterating all the elements. This is not a problem if the function is a view (it is just a burden for the user) but could be a problem for example when we have to pay the author, because of its high gas consumption.

Another possible way could be to save the sum of all the ratings and the number of votes and calculate the average as sum/numVotes. This will consume less gas and has seemingly the same result. Can we implement this solution? 

In reply to ALDO D'AQUINO

Re: Gas consumption with feedback tuple in COBrA DAPP

by DAMIANO DI FRANCESCO MAESA -

Yes, remembering all the single feedbacks can quickly become an unbereble burden (depending on the implementation). Depending on your implementation, saving the current average of all feedbacks (or sum) and number of them is a fine solution (as long as the single values are not needed).

Do note that to allow the user to choose y in

"GetMostRated(x,y): returns the content with highest rating for feedback category y (or highest average of all ratings if y is not specified)."

you do need more than one global feedback average.

cleardot.gif