Find RC Percentage in Javascript | RC小于50%就不跟随点赞了~

in #programming4 years ago (edited)

I have a trail for both voting and downvoting. These are controlled by myself - i.e. a NodeJs application managed by PM2.

For Javascript, there is only 1 library which is the steem-js. The latest version is 0.7.7: https://github.com/steemit/steem-js/releases/tag/v0.7.7

And, there is no easy way to get the RC by using the library. Luckily I found @anyx who provides a few RESTFUL APIs on his full Node.

image.png
// to see the ping time for other nodes, please visit https://steemyy.com

And the API is: https://anyx.io/v1/rc_api/find_rc_accounts?accounts=justyy (replace the ID)

JSON response, nice.

{
  "rc_accounts": [
    {
      "account": "justyy",
      "max_rc": "166759220940074",
      "max_rc_creation_adjustment": {
        "amount": "2020748973",
        "nai": "@@000000037",
        "precision": 6
      },
      "rc_manabar": {
        "current_mana": "166759220940074",
        "last_update_time": 1584150960
      }
    }
  ]
}

Then, we can easily compute the percentage by using the current_mana/max_rc. To wrap this up in a function:

function getPercentageRC(id) {
    const url = "https://anyx.io/v1/rc_api/find_rc_accounts?accounts=" + id;
    return new Promise((resolve, reject) => {
        fetch(url).then(data => {
            data.json().then(json => {
                const max_rc = json.rc_accounts[0].max_rc;
                const cur_rc = json.rc_accounts[0].rc_manabar.current_mana;
                resolve(cur_rc / max_rc);
            });
        });    
    });
}

Then you can use this like this:

async function test() {
  const PerRC = await getPercentageRC('justyy');
  //.. do something with PerRC
}

Or like this:

getPercentageRC('justyy').then(rc => {
    // do something with rc.
});

--------------- 以下是中文------------------------------

很久很久之前忽悠了些亲朋好友加入了“足球队”,也就是把 posting_key 放心交给行长,好处是:行长帮你收取收益 (claim rewards), 然后还有就是加入行长的点赞团队。

鱼老板的几个号玩游戏玩到 没有RC了,于是需要判断RC,如果低于50%就不参于点赞了。

其它库比如 beem, dsteem 都有相应的获得 RC 的方法,而 steem-js 却没有相应的API,找了一下,发现 anyx 有提供一个 restful api.

代码见上面英文的。加入后,点赞团如果RC小于50%就啥也不错。

image.png

如果你有些小号,不发贴,不想管理 可以把 post key 发给我哈(微信)


I hope this helps!

Steem On!~


If you like my work, please consider voting for me, thanks!
https://steemit.com/~witnesses type in justyy and click VOTE



Alternatively, you could proxy to me if you are too lazy to vote!

Also: you can vote me at the tool I made: https://steemyy.com/witness-voting/?witness=justyy

Sort:  

Dear @justyy

I've been reading latest post by ausbitbank and I've noticed his comments. Words like "I don't give a shit about your denials. I want to know what you got for selling us all out." should never be said by one of witnesses. By someone who is selected to represent us - all those who voted on him and other 20W.

Sorry about his behaviour
Yours, Piotr

Thanks for your understanding. Much appreciated.

I'm glad to see how responsive you are @justyy

ps. does website buymeacoffee.com belong to you? Just curious.

Also I was wondering - are you Chinese perhaps Malaysian Chinese (I used to live in Malaysia and I've learned how huge is chinese population in this country).

Yours, Piotr

Hah, no, buymeacoffee is not mine - it is like a paypal donation.

I am mainline Chinese who is now living in UK. I speak Madrain, and Minlan dialect - which is spoken by lots of Malaysia Chinese I think.

As one of the top witnesses on Steem now- Can you tell me how you feel about these changes to the terms of service? Some open and honest communication would help during these trying times.

Do you agree with these changes? Were you consulted at all before they were changed? Do you really believe people need written permission to promote each other? Am I seriously not allowed to promote anything that isn't Steemit?

If you can't answer these questions that isn't a good look for the future of steem...

User Conduct

14.1. When accessing or using the Services, you agree that you will not commit any unlawful act, and that you are solely responsible for your conduct while using our Services. Without limiting the generality of the foregoing, you agree that you will not:

14.1.7. Use our services to promote third-party platforms or to promote each other without our written permission.

这个有水平啪啪啪啪啪

行长现在收到大代理了,点赞算法怎么修改的?

Posted using Partiko Android

FLAGGED FOR EXCESSIVE UP-VOTES...
ATTENTION @steemflagrewards and @steevc...
March 17, 2020... 23.4 Hollywood Time...

Coin Marketplace

STEEM 0.30
TRX 0.12
JST 0.034
BTC 64231.88
ETH 3128.59
USDT 1.00
SBD 3.95