Skip to content

Commit

Permalink
Add the getAccountBandwidth method to SteemJ
Browse files Browse the repository at this point in the history
  • Loading branch information
neutralleiter committed Jan 14, 2018
1 parent edf71fe commit 8ceecc4
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions core/src/main/java/eu/bittrade/libs/steemj/SteemJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package eu.bittrade.libs.steemj;

import java.math.BigInteger;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -105,6 +104,9 @@
import eu.bittrade.libs.steemj.plugins.apis.tags.models.GetActiveVotesArgs;
import eu.bittrade.libs.steemj.plugins.apis.tags.models.Tag;
import eu.bittrade.libs.steemj.plugins.apis.tags.models.VoteState;
import eu.bittrade.libs.steemj.plugins.apis.witness.WitnessApi;
import eu.bittrade.libs.steemj.plugins.apis.witness.models.AccountBandwidth;
import eu.bittrade.libs.steemj.plugins.apis.witness.models.GetAccountBandwidthArgs;
import eu.bittrade.libs.steemj.protocol.AccountName;
import eu.bittrade.libs.steemj.protocol.Asset;
import eu.bittrade.libs.steemj.protocol.BlockHeader;
Expand Down Expand Up @@ -2046,11 +2048,29 @@ public List<Tag> getTrendingTags(String firstTagPattern, int limit)
// ## WITNESS API ##########################################################
// #########################################################################

// public List<Integer> getAccountBandwidth() throws
// SteemCommunicationException, SteemResponseException {
// return WitnessApi.getAccountBandwidth(communicationHandler,
// getAccountBandwidthArgs);
// }
/**
*
* @param getAccountBandwidthArgs
* @return
* @throws SteemCommunicationException
* <ul>
* <li>If the server was not able to answer the request in the
* given time (see
* {@link eu.bittrade.libs.steemj.configuration.SteemJConfig#setResponseTimeout(int)
* setResponseTimeout}).</li>
* <li>If there is a connection problem.</li>
* </ul>
* @throws SteemResponseException
* <ul>
* <li>If the SteemJ is unable to transform the JSON response
* into a Java object.</li>
* <li>If the Server returned an error object.</li>
* </ul>
*/
public Optional<AccountBandwidth> getAccountBandwidth(GetAccountBandwidthArgs getAccountBandwidthArgs)
throws SteemCommunicationException, SteemResponseException {
return WitnessApi.getAccountBandwidth(communicationHandler, getAccountBandwidthArgs).getBandwidth();
}

// public List<Integer> getMarketHistoryBuckets() throws
// SteemCommunicationException, SteemResponseException {
Expand Down Expand Up @@ -2084,6 +2104,7 @@ public double calculateRemainingBandwidth(AccountName accountName)
throws SteemCommunicationException, SteemResponseException {
ExtendedDynamicGlobalProperties extendedDynamicGlobalProperties = CondenserApi
.getDynamicGlobalProperties(communicationHandler);
// TODO: Use getAccountBandwidth instead.
List<ExtendedAccount> extendedAccounts = CondenserApi.getAccounts(communicationHandler);

if (!extendedAccounts.contains(accountName)) {
Expand Down

0 comments on commit 8ceecc4

Please sign in to comment.