SteemJ Dev Diary #2 (02.01.2018) - Increased code quality

in utopian-io •  7 years ago  (edited)

SteemJ Dev Diary #2 (02.01.2018) - Increased code quality.


SteemJV2Logo


Latest SteemJ 0.4.x releases: 0.4.3 v0.4.2 v0.4.2pr1 v0.4.1 v0.4.0

SteemJ Dev Diary #2 (02.01.2018) - Increased code quality


Hello Steemians and welcome back to day #2 of the SteemJ HF 0.20 Dev Diary!

This series has been introduced to collect feedback from you and to motivate myself to finalize the next SteemJ version as soon as possible. If this is the first part of this series you read, you may want to checkout Day #1 which explains the motivation behind this diary in detail and also provides a first overview of the API changes that come with HF 0.20.

Changes during day #2

Sadly, the Steem Node(s) behind the Steem Dev API Endoint https://api.steemitdev.com have been changed and the new API calls (using the '_args' and '_return' objects) are not working today. This made it quite hard to test my changes on the API calls.

Anyway, I tried to use the time as good as possible and started to cleanup the "AccountHistoryApi" today. In total I was able to more or less finalize the JavaDoc of all '_args' and '_return' objects related to the "AccountHistoryApi", made sure that default values are applied and that required fields have to be provided. Beside that I've added additional Unit tests to verify that those validations are working properly.

The following commits are related to those changes:

  • b2141bf Verify that required fields are set (#177)
  • a938d93 Add additional JavaDoc (#177)
  • 86fad4f Fix #193

In addition I had a look at Issue #183 - Use of double for Asset values can cause incorrect trades to be placed. reported by @muksihs . As you may know, it is a pretty bad practice to use 'Double' or 'Float' when working with currencies and sadly, I totally forgot about this when I was implementing the Asset class. In commit cd851c the implementation has been changed from 'Double' to 'BigDecimal' and I am currently waiting for @muksihs feedback about this change.

The last change I want to point out for today is commit 7e43f6b, which includes additional test cases for some 'SteemJUtils' methods.

A list of all commits made after the last release can be found here: https://github.com/marvin-we/steem-java-api-wrapper/compare/v0.4.3...master

(A prove that the commits have been made by me can be found here)

General information

What is SteemJ?

SteemJ is a project that allows you to communicate with a Steem node using Java. So far, the project supports most of the API calls and is also able to broadcast most of the common operation types. Further information can be found on GitHub.

https://github.com/marvin-we/steem-java-api-wrapper

Quick Start Guide

Add SteemJ to your project

SteemJ binaries are pushed into the maven central repository and can be integrated with a bunch of build management tools like Maven. The Wiki provides a lot of examples for the most common build tools. If you do not use a build management tool you can download the binaries as described here.

To add this release to your project paste the following snippet into your 'pom.xml'

<dependency>
    <groupId>eu.bittrade.libs</groupId>
    <artifactId>steemj-core</artifactId>
    <version>0.4.3</version>
</dependency>

Start posting

SteemJConfig myConfig = SteemJConfig.getInstance();

myConfig.setDefaultAccount(new AccountName("YOUR-ACCOUNT"));

List<ImmutablePair<PrivateKeyType, String>> privateKeys = new ArrayList<>();
privateKeys.add(new ImmutablePair<>(PrivateKeyType.POSTING, "YOUR-PRIVATE-POSTING-KEY"));

myConfig.getPrivateKeyStorage().addAccount(myConfig.getDefaultAccount(), privateKeys);

steemJ.createComment(new AccountName("steemj"), new Permlink("testofsteemj040"), "Example comment without no link but with a @user .", new String[] { "test" });

Further information

The sample module of the SteemJ project provides showcases for the most common acitivies and operations users want to perform.

Beside that you can find a lot of snippets and examples in the different Wiki sections.

Contribute

The project became quite big and there is still a lot to do. If you want to support the project simply clone the git repository and submit a pull request. I would really appreciate it =).

git clone https://github.com/marvin-we/steem-java-api-wrapper.git

Get in touch!

Most of my projects are pretty time consuming and I always try to provide some useful stuff to the community. What keeps me going for that is your feedback and your support. For that reason I would love to get some Feedback from you <3. Just contact me here on Steemit or ping me on GitHub.



Posted on Utopian.io - Rewarding Open Source Contributors

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Thank you @kit.andres ! =)

@dez1337 thanks for your hard work.

I'll take a look as soon as an opportunity arises.... especially as I am actively using the market code. (And have discovered that market trades count against your bandwidth....)

Great to hear that :)

(And have discovered that market trades count against your bandwidth....)

Funny - I had to do a small reasearch about the bandwith in general yesterday. From what I have read all operations you perform cost some bandwidth, so even collecting your rewards costs some bandwidth :)

So.... how does one calculate available bandwidth... as I've been going negative/positive/negative/negative/more negative all morning with no trades and only one post.... if available bandwidth is too low, really don't want to do trading... way too easy get stuck with very bad positions that way, I'm doing that well enough all by myself without help.

So from what I've understood yesterday the available bandwidth depends on your SteemPower .. the more you have the heigher your bandwidth is.

You can manually check your bandwidth using tools like Steemd: https://steemd.com/@muksihs

Or by using the

public List<ExtendedAccount> getAccounts(List<AccountName> accountNames)

method of SteemJ.

I've been logging getExtendedAccount().getAverageBandwidth() and getExtendedAccount().getAverageMarketBandwidth(), and there seems to be a formula needed with some other value unknown to me to figure our their relationship to determining available bandwidth.

(muksihs bandwidth limit exceeded. Please wait to transact or power up STEEM. this error message indicating that you should power up when you can't without bandwidth is annoying and frustrating)

This tutorial provided by @jfollas looks pretty good: https://steemit.com/steemdev/@jfollas/write-a-steemit-web-app-part-7-bandwidth-availability

You may could create a GitHub issue for SteemJ and request this functionallity? Or even better - If you have the time provide it as a pull request if you implement it for your image library? =)

Hard work with clear concept but need little bit better. In a day it will solve. Go ahead. Best of luck.

Thank you @zinia :)

Thank you too @dez1337

Hey @dez1337 I am @utopian-io. I have just upvoted you!

Achievements

  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x