Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
Edge case handling for when Report.ixi operates on Ict 0.5.
Browse files Browse the repository at this point in the history
  • Loading branch information
ixuz committed Mar 4, 2019
1 parent a58bd07 commit de399bd
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/main/java/org/iota/ict/ixi/ReportIxi.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,22 @@ public void syncIctNeighbors() {

final JSONArray statsArray = ictNeighbor.getJSONArray("stats");

if (statsArray.length() > 0) {
final JSONObject stats = statsArray.getJSONObject(statsArray.length() - 1);
JSONObject stats = null;
if (getReportIxiContext().getIctVersion().equals("0.5")) {
// If this version of Report.ixi is operated on Ict 0.5, it will always try to get
// the last metrics/stats record from Ict api.
if (statsArray.length() > 0) {
stats = statsArray.getJSONObject(statsArray.length() - 1);
}
} else {
// If this version of Report.ixi is on any newer version than Ict 0.5, it will always
// try to get the second to last metrics/stats record from Ict api.
if (statsArray.length() > 1) {
stats = statsArray.getJSONObject(statsArray.length() - 2);
}
}

if (stats != null) {
addressesAndStatsToSync.add(new AddressAndStats(
address,
new Stats(
Expand Down

0 comments on commit de399bd

Please sign in to comment.