Skip to content

Commit

Permalink
Updated the function 'Vote()'.
Browse files Browse the repository at this point in the history
  • Loading branch information
yurigabrich committed Mar 14, 2020
1 parent 4c484e9 commit ca712de
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions neo-dapp/microgrid-dapp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -464,14 +464,14 @@ public static object Summary( object id, string opt = "" )
public static bool Vote( string id, byte[] member, bool answer )
{
// Increases the number of votes.
BigInteger temp = GetRef(id,"Num of Votes").AsBigInteger();
UpRef(id, "Num of Votes", temp++);
BigInteger temp = (BigInteger)GetRef(id,"Num of Votes");
UpRef(id, "Num of Votes", temp+1);

if (answer)
{
// Increases the number of "trues".
temp = GetRef(id,"Count True").AsBigInteger();
UpRef(id, "Count True", temp++);
temp = (BigInteger)GetRef(id,"Count True");
UpRef(id, "Count True", temp+1);
}

// Publishes the vote.
Expand Down Expand Up @@ -1379,11 +1379,11 @@ private static object GetRef( string id, string opt = "hasresult" )

// --> update
// It is only possible to internally change the 'MoneyRaised', the 'NumOfVotes', the 'CountTrue', the 'HasResult' and the 'Outcome'.
private static void UpRef( byte[] id, string opt, BigInteger val )
private static void UpRef( string id, string opt, BigInteger val )
{
if ((opt == "numofvotes") || (opt == "moneyraised") || (opt == "counttrue") || (opt == "hasresult") )
{
BigInteger orig = GetRef(id, opt).AsBigInteger();
BigInteger orig = (BigInteger)GetRef(id, opt);

if (orig == val)
{
Expand All @@ -1408,9 +1408,9 @@ private static void UpRef( byte[] id, string opt, BigInteger val )
}
}

private static void UpRef( byte[] id, bool val )
private static void UpRef( string id, bool val )
{
bool orig = Str2Bool( GetRef(id, "outcome").AsString() );
bool orig = Str2Bool( (string)GetRef(id, "outcome") );

if ( orig == val )
{
Expand Down

0 comments on commit ca712de

Please sign in to comment.