[MINOR] Fix warnings identified by static analysis. (#262)

Adrian Sutton 6 years ago committed by GitHub
parent c2e98152e0
commit c0f1168638
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/AbstractWorldUpdater.java
  2. 2
      ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/EthHashCacheFactory.java
  3. 4
      ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/EthHasher.java
  4. 6
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServer.java
  5. 2
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/PersistBlockTask.java

@ -398,7 +398,7 @@ public abstract class AbstractWorldUpdater<W extends WorldView, A extends Accoun
// may kill some of "their" updates, and our updates may review some of the account "they"
// deleted.
deletedAccounts().forEach(wrapped.updatedAccounts::remove);
updatedAccounts().forEach(a -> wrapped.deletedAccounts.remove(a.getAddressHash()));
updatedAccounts().forEach(a -> wrapped.deletedAccounts.remove(a.getAddress()));
// Then push our deletes and updates to the stacked ones.
wrapped.deletedAccounts.addAll(deletedAccounts());
@ -411,7 +411,7 @@ public abstract class AbstractWorldUpdater<W extends WorldView, A extends Accoun
existing = update.getWrappedAccount();
if (existing == null) {
// Brand new account, create our own version
existing = new UpdateTrackingAccount<A>(update.address);
existing = new UpdateTrackingAccount<>(update.address);
}
wrapped.updatedAccounts.put(existing.address, existing);
}

@ -45,7 +45,7 @@ public class EthHashCacheFactory {
Cache<Long, EthHashDescriptor> descriptorCache = CacheBuilder.newBuilder().maximumSize(5).build();
public EthHashDescriptor ethHashCacheFor(final long blockNumber) {
final Long epochIndex = EthHash.epoch(blockNumber);
final long epochIndex = EthHash.epoch(blockNumber);
try {
return descriptorCache.get(epochIndex, () -> createHashCache(epochIndex, blockNumber));
} catch (final ExecutionException ex) {

@ -75,9 +75,9 @@ public interface EthHasher {
headerHash,
datasetSize,
nonce,
(bytes, integer) -> {
(bytes, offset) -> {
try {
cacheFile.seek(integer * EthHash.HASH_BYTES);
cacheFile.seek(((long) offset) * EthHash.HASH_BYTES);
cacheFile.readFully(bytes);
} catch (final IOException ex) {
throw new IllegalStateException(ex);

@ -34,12 +34,12 @@ import tech.pegasys.pantheon.ethereum.rlp.RLPException;
import tech.pegasys.pantheon.util.bytes.BytesValue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import com.google.common.collect.Lists;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -135,8 +135,8 @@ class EthServer {
if (firstHeader == null) {
resp = Collections.emptyList();
} else {
resp = new ArrayList<>(Arrays.asList(firstHeader));
final int numberDelta = reversed ? -(skip + 1) : (skip + 1);
resp = Lists.newArrayList(firstHeader);
final long numberDelta = reversed ? -(skip + 1) : (skip + 1);
for (int i = 1; i < maxHeaders; i++) {
final long blockNumber = firstHeader.getNumber() + i * numberDelta;
if (blockNumber < BlockHeader.GENESIS_BLOCK_NUMBER) {

@ -84,7 +84,7 @@ public class PersistBlockTask<C> extends AbstractEthTask<Block> {
successfulImports,
headerValidationMode));
}
return future.thenApply((r) -> successfulImports);
return future.thenApply(r -> successfulImports);
};
}

Loading…
Cancel
Save