Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Commit

Permalink
Make getHeaders() nonull
Browse files Browse the repository at this point in the history
  • Loading branch information
Nashatyrev committed Nov 8, 2018
1 parent 392f29c commit 1166301
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ private boolean validateAndAddHeaders(List<BlockHeader> headers, byte[] nodeId)
SyncQueueIfc.ValidatedHeaders res;
synchronized (this) {
res = syncQueue.addHeadersAndValidate(wrappers);
if (res.isValid() && res.getHeaders() != null && !res.getHeaders().isEmpty()) {
if (res.isValid() && !res.getHeaders().isEmpty()) {
pushHeaders(res.getHeaders());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.ethereum.core.BlockHeader;
import org.ethereum.core.BlockHeaderWrapper;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -67,7 +68,7 @@ interface BlocksRequest {
* Otherwise, the list contains invalid headers.
*/
class ValidatedHeaders {
public static final ValidatedHeaders Empty = new ValidatedHeaders(null, true);
public static final ValidatedHeaders Empty = new ValidatedHeaders(Collections.emptyList(), true);

private final List<BlockHeaderWrapper> headers;
private final boolean valid;
Expand All @@ -87,6 +88,7 @@ public boolean isValid() {
return valid;
}

@Nonnull
public List<BlockHeaderWrapper> getHeaders() {
return headers;
}
Expand All @@ -97,13 +99,13 @@ public String getReason() {

@Nullable
public byte[] getNodeId() {
if (headers == null || headers.isEmpty()) return null;
if (headers.isEmpty()) return null;
return headers.get(0).getNodeId();
}

@Nullable
public BlockHeader getHeader() {
if (headers == null || headers.isEmpty()) return null;
if (headers.isEmpty()) return null;
return headers.get(0).getHeader();
}
}
Expand Down

0 comments on commit 1166301

Please sign in to comment.