文章得票数的问题

in #cn5 years ago

今天注意到steem的github上有人问文章得票数不对的问题,简单地来讲,某种情况下一篇文章有100个人投票,但是API查询查询到的得票数会少于100,极端情况下甚至会是-100票。


(图源 :pixabay)

这个问题我以前在微信群里解答过,我隐约记得当时参与讨论的成员要去把这个问题发乌托邦,也不知道她发了没有。

造成这个问题的原因我猜测是因为HF20中移除了Vote Dust Threshold的限制,HF20之前,STEEM系统中有个尘埃投票阈值,也就是说如果你投票的效果低于这个阈值,那么是不允许你投票的,会出现一个投票失败的提示。

而HF20之后,为了改善用户体验,移除了这个限制,也就是说,SP少或者使用超低比例投票,都没问题(除了RC限制),尽管这样的投票对文章收益的影响为零。

但是新的问题来了,HF20之前的系统中,把Upvote记为正票,把Downvote记为负票,举例说一个文章得到10票upvote,得到10票downvote,那么这篇文章的净得票为零。

大致代码如下所示:

在上述代码中,把rshares为零的票计入到Downvote逻辑中,这在HF20之前并没有啥大问题,因为rshares为零的票并不存在。

而在HF20后,代码中增加了如下逻辑:

这样一来投票影响力落在STEEM_VOTE_DUST_THRESHOLD-STEEM_VOTE_DUST_THRESHOLD区间内的投票,rshares都为零。

这样继续使用上述代码:

就会把rshares为零的票统计为负票,就会出现文章开头描述的问题。

至于如何修复?如果是HF20尚未开启时,只需把代码改为如下形式即可:

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

不过HF20已经跑起来并且跑了这么久,如果这么改有没有什么问题我就不得而知了,比如是否需要HF,是否需要replay等等。

毕竟我是菜鸟,另外,文章得票数错了就错了,其实也没啥影响,哈哈。


Vote For Me As Witness
https://steemit.com/~witnesses type in oflyhigh and click VOTE

Vote @oflyhigh via Steemconnect
Thank you!

Sort:  

Thank you so much for participating the Partiko Delegation Plan Round 1! We really appreciate your support! As part of the delegation benefits, we just gave you a 3.00% upvote! Together, let’s change the world!

这个貌似也就对强迫症有点难受。🤣

Posted using Partiko Android

Your progeny will soon die due to the great approaching annihilation brought by the black Hitler. The black Hitler will be a fearsome and ruthless individual, who will emerge from the growing black middle class in several developed countries, centuries of racial hatred will finally materialized into an incarnation of fearsome proportions, your only hope will be the reincarnation of Napoleon in a lesbian girl , who will fight against the black Hitler, the lesbian Napoleon is not Jewish, but will be controlled by the Jews like the black Hitler, the story is simple, Jews against Gentiles, that will be the last book of the Bible and not the apocalypse, finally the Muslim prophet will annihilate the Jews, because the mad Arab, the great sorcerer of the middle ages never died after finding the remains of Hermes Trismegistus in an alien ship, https://steemit.com/cunnilingus/@medicina/the-black-hitler-part-i

Coin Marketplace

STEEM 0.20
TRX 0.14
JST 0.030
BTC 64170.07
ETH 3425.12
USDT 1.00
SBD 2.59