steem icon indicating copy to clipboard operation
steem copied to clipboard

Invalid net_votes value returned by condenser_api.get_content

Open VIM-Arcange opened this issue 6 years ago • 1 comments

condenser_api.get_content return an invalid value for net_votes when there are "weight": 0 votes on a post/comment.

Here is an example: author = 'conformity' permlink = 'award-winning-cgi-3d-animated-short-film-le-gouffre-by-lightning-boy-studio-cgmeetup'

Calling get_content() returns:

{
  "id": 67448821,
  "author": "conformity",
  "permlink": "award-winning-cgi-3d-animated-short-film-le-gouffre-by-lightning-boy-studio-cgmeetup",
  ...
  "net_votes": -374,
   ...
}

If you check the "active_votes" array returned, you will notice there are exactly 374 upvotes with "weight": 0 value.

VIM-Arcange avatar Jan 21 '19 14:01 VIM-Arcange

This issue has existed since HF20. And I think it may be caused by "Vote Dust Threshold" which be removed in HF20. There are following codes in /libraries/chain/steem_evaluator.cpp

void hf20_vote_evaluator( const vote_operation& o, database& _db )`
{
....
      _db.modify( comment, [&]( comment_object& c )
      {
         c.net_rshares += rshares;
         c.abs_rshares += abs_rshares;
         if( rshares > 0 )
            c.vote_rshares += rshares;
         if( rshares > 0 )
            c.net_votes++;
         else
            c.net_votes--;
      });
...
}

There is not a issue before HF20, because before HF20 rshares is always greater than 0(upvote) or less than 0(downvote).

But after HF20, due to the removal of "Vote Dust Threshold", rshares can be zero.

   abs_rshares -= STEEM_VOTE_DUST_THRESHOLD;
   abs_rshares = std::max( int64_t(0), abs_rshares );

so right codes should be:

         if( rshares > 0 )
            c.net_votes++;
         else if ( rshares < 0 )
            c.net_votes--;

😀

oflyhigh avatar Jan 25 '19 07:01 oflyhigh