Skip to content

Commit

Permalink
Minor change in PiecesTracker API.
Browse files Browse the repository at this point in the history
  • Loading branch information
aldenml committed Feb 4, 2015
1 parent 7fd55fd commit 94e8109
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 19 additions & 1 deletion src/com/frostwire/jlibtorrent/PiecesTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void setComplete(int pieceIndex, boolean complete) throws IllegalArgument
this.complete[pieceIndex] = complete;
}

public long getSequentialDownloaded(int fileIndex) {
public long getSequentialDownloadedBytes(int fileIndex) {
int[] pieces = files[fileIndex];

long downloaded = 0;
Expand All @@ -81,4 +81,22 @@ public long getSequentialDownloaded(int fileIndex) {

return downloaded;
}

public int getSequentialDownloadedPieces(int fileIndex) {
int[] pieces = files[fileIndex];

int count = 0;

for (int i = 0; i < pieces.length; i++) {
int pieceIndex = pieces[i];

if (complete[pieceIndex]) {
count++;
} else {
break;
}
}

return count;
}
}
2 changes: 1 addition & 1 deletion src/com/frostwire/jlibtorrent/demo/PieceMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static void main(String[] args) throws Throwable {
}

for (int i = 0; i < numFiles; i++) {
System.out.println("File index (seq)completed: " + tracker.getSequentialDownloaded(i));
System.out.println("File index (seq)completed: " + tracker.getSequentialDownloadedBytes(i));
}
}
}

0 comments on commit 94e8109

Please sign in to comment.