The Python Function to Retrieve the Producer Reward for Witness

As you know, the witness is rewarded for produce a block. The TOP 20 gets to produce the blocks more frequently than the backup witnesses, but the reward for each block is different: currently 484 VESTS for TOP 20 while around 2425 VESTS for others on the steem blockchain.

How do we get the reward given a block number? Unfortunately, it is not through the get_block api. Instead, we need to use get_ops_in_block which is provided by account_plugin_history

curl -s –data ‘{“jsonrpc”:”2.0”, “method”:”condenser_api.get_ops_in_block”, “params”:[43880000,true], “id”:1}’ https://api.steemit.com

This returns like:

{“jsonrpc”:”2.0”,”result”:[{“trx_id”:”0000000000000000000000000000000000000000”,”block”:43880000,”trx_in_block”:4294967295,”op_in_trx”:0,”virtual_op”:1,”timestamp”:”2020-
06-01T17:49:18”,”op”:[“producer_reward”,{“producer”:”hinomaru-jp”,”vesting_shares”:”481.663694 VESTS”}]}],”id”:1}

Then, we can wrap it up in a Python function (please note that we need to scan the transactions array and look for the producer_reward ops.

1
2
3
4
5
6
7
8
def getReward(block):
data={"jsonrpc":"2.0", "method":"condenser_api.get_ops_in_block", "params":[block, True], "id":1}
result = requests.post(url="https://api.steemit.com", json = data)
jsonData = result.json()
for tx in jsonData:
if tx['op'][0] == 'producer_reward':
return tx['op'][1]['vesting_shares']
return None

Every little helps! I hope this helps!

Steem On!~

Reposted to Blog

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

Visit me at: https://steemyy.com


This page is synchronized from the post: ‘The Python Function to Retrieve the Producer Reward for Witness’

Some thoughts on the Steem RPC Node Infrastructure

As you know, I provide a RPC Node https://api.justyy.com however, recent network power loss made me thinking how zero resilient this node is. It is just a single node - that suffers single point of failure. In particular, it lacks of the following:

Load Balancer

A Load Balancer (LB) servers as the first point of contact to users. Based on scheduling algorithms (such as Round-robin, IP hashing or based on the least load), it re-routes the requests to different servers.

image.png

The Load Balancers can also be a single point of failure. When it goes down (less likely), we can recover this by using a master-master or master-slave solution. Once master LB is down, the backup or slave LB will automatically take over.

Nowadays, you don’t actually need to set up LB. You can just pay extra, make some configurations, and you will have a LB set up and working for you.

CDN / Reverse Proxy

The CDN helps to cache the contents in edge nodes, which is closer geographically to your users. When you use Reverse Proxy - you can hide your IP or original server and set up a Firewall to protect you from malicious users e.g. DDOS attacks.

Kudos to @steemitblog as I think the official Node api.steemit.com is quite stable and very resilient.


Every little helps! 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

Visit me at: https://steemyy.com


This page is synchronized from the post: ‘Some thoughts on the Steem RPC Node Infrastructure’

Witness Update: Witness & RPC/Seed Node recovered: The Node Auto-Switch Works!

Yesterday, there was a major network issue with my network provider. And the RPC/Seed Node and the Main Witness Node lost power. Here is the update from the network provider:

We regret to inform you, that due to emergency situation in our data center, there may be interruption of service which we are trying to fix with upmost urgency. This already is a top-priority for us and our engineers are currently working actively to resolve the situation as soon as possible. More on this matter, and latest status is regularly posted on our status page at the link below.

Please also kindly be advised, that due to this emergency maintenance, we experience a large number of login attempts at the Customer Control Panel, due to which you may face delay or issues logging in your Customer Control Panel. We deeply apologize for these issues and kindly ask you to try again later.

We kindly ask for your patience and understanding while we work to have this issue resolved as soon as possible.

Unfortnately, my node fails to generate 3 blocks in a row -and fortnately the script automatically switched to another node right on time - and notify me immediately.

https://github.com/DoctorLai/SteemWitnessAutoSwitch

image.png

image.png

The Seed/RPC Node cannot be connected.

image.png

// https://steemyy.com/node-status.php

image.png

And as I mentioned a few days ago with CloudFlare Health Check:

image.png

I have now recovered the RPC/Seed Node and the Witness Node. Everything goes back to normal!


Every little helps! 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

Visit me at: https://steemyy.com


This page is synchronized from the post: ‘Witness Update: Witness & RPC/Seed Node recovered: The Node Auto-Switch Works!’

The Importance of a Unit Test (Making Another Attempt to Fix the Reputation)

A few days ago, my PR was finally merged after more than two years (thank you @ety001). It is a good sign that the new SteemIt team is better as they review and care the contributions from the community.

However, when I wrote the implementation in PHP, I noticed that the Reputation needs to be returning 25 when 0 is given.

I checked the previous implementation (version 0.7.7): the reputation will return 25 when 0 is given: https://github.com/steemit/steem-js/releases/tag/v0.7.7

Run Code on SteemJs Editor

image.png

However, the PR introduced a different behaviour - when 0 is fed into the function, it will return NaN due to Log10. Unfortunately, when there were no relevant unit tests, I couldn’t spot this difference.

Thus, I have made another PR, which fixes this inconsistence and adds a few unit tests to ensure the behaviour stays the same.

https://github.com/steemit/steem-js/pull/479/files


Every little helps! 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

Visit me at: https://steemyy.com


This page is synchronized from the post: ‘The Importance of a Unit Test (Making Another Attempt to Fix the Reputation)’

Adding Reputation to Witness Ranking Table

I thought it would be a good idea to add the column “reputation” to the witness ranking table.

https://steemyy.com/witness-ranking/

image.png

The reputation is just an indicator but nothing more. For instance. the reputation 25 usually means the steemian has just recently newly joined.

The reputation is formatted in such a way that below 25 is marked as red. The reputation data is also integrated in the API under the account_data section.

Finally the PHP function to format the reputation is given here.


Every little helps! 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

Visit me at: https://steemyy.com


This page is synchronized from the post: ‘Adding Reputation to Witness Ranking Table’

Leetcode Biweekly Contest 29

I have recently started to attend the online coding contest. Leetcode has held weekly contests on Sunday early mornings - which isn’t ideal for coders living in Europe.

However, they have biweekly contests, which is run the Sat 3:30 to 5:30 (BST) every two weeks.

Today’s contest: https://leetcode.com/contest/biweekly-contest-29

I have finished the four puzzles using around 1 hour.

The programming language I choose is C++. I have 1 Wrong Answer submission for Problem 2 and 4 - which adds total 10 minutes time penalization

image.png

Average Salary Excluding the Minimum and Maximum Salary

https://leetcode.com/contest/biweekly-contest-29/problems/average-salary-excluding-the-minimum-and-maximum-salary
Simple - use std::accumulate to get sum, min_element and max_element to get the min and max value, then compute the average without them

The kth Factor of n

https://leetcode.com/contest/biweekly-contest-29/problems/the-kth-factor-of-n
Again, easy, straightforward.

Longest Subarray of 1’s After Deleting One Element

https://leetcode.com/contest/biweekly-contest-29/problems/longest-subarray-of-1s-after-deleting-one-element
Use two arrays to hold the maximum continuous 1’s in the left and right direction. The answer is thus max(left[i] + right[i])

Parallel Courses II

https://leetcode.com/contest/biweekly-contest-29/problems/parallel-courses-ii/
Topology sorting? Greedy… I use DFS.

I’ll share the solutions on the blog in more details soon.

Although the contest has ended, you can try to participate on the virtual contest.


Every little helps! 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

Visit me at: https://steemyy.com


This page is synchronized from the post: ‘Leetcode Biweekly Contest 29’

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×