mirror of
https://github.com/sparrowwallet/hummingbird.git
synced 2024-12-26 01:56:45 +00:00
avoid npe when no parts have been processed
This commit is contained in:
parent
7527a37e8f
commit
3ae733b416
1 changed files with 5 additions and 1 deletions
|
@ -30,7 +30,7 @@ public class FountainDecoder {
|
|||
private final List<Part> queuedParts = new ArrayList<>();
|
||||
|
||||
public int getExpectedPartCount() {
|
||||
return expectedPartIndexes.size();
|
||||
return expectedPartIndexes == null ? 0 : expectedPartIndexes.size();
|
||||
}
|
||||
|
||||
public Set<Integer> getRecievedPartIndexes() {
|
||||
|
@ -46,6 +46,10 @@ public class FountainDecoder {
|
|||
}
|
||||
|
||||
public double getEstimatedPercentComplete() {
|
||||
if(processedPartsCount == 0) {
|
||||
return 0d;
|
||||
}
|
||||
|
||||
double estimatedInputParts = (double)getExpectedPartCount() * 1.75;
|
||||
return Math.min(0.99, (double)processedPartsCount / estimatedInputParts);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue