DeepSteem - Increased robustness and some minor features

in #utopian-io7 years ago (edited)

Before adding new features, I decided to improve the robustness of the current code base. Failed requests are now repeated up to five times and I use alternative nodes instead of relying on https://api.steemit.com only. For the rare case, that there a still connection failures, I added flash messages to provide some feedback for the user.

I also added the current market price of SBD to the dashboard and added code the hide the STEEM column if there are no payouts in STEEM (when the SBD print rate is 100%).

What is DeepSteem

DeepSteem is a dashboard for the STEEM blockchain written as frontend only Angular application. A live version is available at http://deepsteem.com. Some of its features are:

  • Estimation of incoming curation rewards
  • Accurate estimation of incoming author rewards
  • Cumulative voting power of all followers

New Features

A steemjs wrapper with retries and basic node management

At first, I decided to extend one API call with a fixed number of retries in the case of an error to have a prototype. This is the wrapper for getContent, that follows a very common pattern for retries with Promises:

async getContent(author, permlink, num_try = 5): Promise<any> {
  return new Promise((resolve, reject) => {
    steem.api.getContent(author, permlink, (err, post) => {
      if (err)
        if (num_try == 0) return reject(err);
        else {
          return resolve(this.getContent(author, permlink, num_try - 1));
        }
      resolve(post);
    });
  });
}

Corresponding commit: GitHub

Although this works, I'd have had to add a wrapper function for every STEEM API call used in DeepSteem. Hence I decided to come up with a more generic solution:

I added the wrapper steem-api.ts for steemjs, that automatically generates a function for every API request in steem.api. For the sake of simplicity, I assume that I can enumerate all available API calls in steem.api by taking all functions with the suffix Async. Looping over the list of these functions, a wrapper is created for each of them, with the following additional functionality:

  • Retry of the request in case of an error
  • Switching to another node in case of an error
  • Automatically returning a Promise if called without callback (rendering the distinction between Async and non Async functions unnecessary)

Due to the asynchronous nature of JavaScript, the current node is only changed, if it is the node that was used for a failed request.

The beauty of this wrapper is, that I just had to change the steem.api prefix of all request to SteemApi.api to use it for all calls in DeepSteem. steem-api.ts is now the only source file that includes steemjs.

With this change, I also switched to a list of alternative nodes, using WebSocket nodes on default. Before that, DeepSteem only relied on https://api.steemit.com.

Corresponding commit: GitHub

Flash messages for connection errors

Finally, for the case that the five retries aren't enough and there are still errors, I added feedback in the form of flash messages, which are implemented with the angular2-flash-messages package.

Bildschirmfoto 2018-04-24 um 21.51.18.png

Corresponding commit: GitHub

Current market price of SBD

DeepSteem already retrieved and displayed the current market price of STEEM from Coinmarketcap. I made this a little more generic and added the current market price of SBD to the dashboard, as well.

Bildschirmfoto 2018-04-24 um 22.21.26.png

Corresponding commit: GitHub

Don't show the STEEM column if SBD print rate is 100%

DeepSteem estimates author payouts very closely to the code in the STEEM blockchain. A share of the rewards is credited in STEEM, if the SBD print rate is below 100%. The column containing this value is now displayed only, if the SBD print rate is below 100%, because otherwise it is only a column with zeros in every row.

Bildschirmfoto 2018-04-24 um 22.21.41.png

Corresponding commit: GitHub

How to contribute

If you want to fix bugs or add a feature to DeepSteem, submit an issue or open a pull request on GitHub.



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thanks for the contribution. It has been approved.


Need help? Write a ticket on https://support.utopian.io.
Chat with us on Discord.

[utopian-moderator]

Hey @nafestw! Thank you for the great work you've done!

We're already looking forward to your next contribution!

Fully Decentralized Rewards

We hope you will take the time to share your expertise and knowledge by rating contributions made by others on Utopian.io to help us reward the best contributions together.

Utopian Witness!

Vote for Utopian Witness! We are made of developers, system administrators, entrepreneurs, artists, content creators, thinkers. We embrace every nationality, mindset and belief.

Want to chat? Join us on Discord https://discord.me/utopian-io

Hello i just contributed about us to your project. Please approve

Coin Marketplace

STEEM 0.25
TRX 0.21
JST 0.036
BTC 98157.20
ETH 3401.01
USDT 1.00
SBD 3.42