From c0f1168638a9322ed6cd82446eed3aea48d9d1b8 Mon Sep 17 00:00:00 2001 From: Adrian Sutton Date: Fri, 16 Nov 2018 14:20:46 +1000 Subject: [PATCH] [MINOR] Fix warnings identified by static analysis. (#262) --- .../pantheon/ethereum/core/AbstractWorldUpdater.java | 4 ++-- .../pantheon/ethereum/mainnet/EthHashCacheFactory.java | 2 +- .../tech/pegasys/pantheon/ethereum/mainnet/EthHasher.java | 4 ++-- .../pegasys/pantheon/ethereum/eth/manager/EthServer.java | 6 +++--- .../pantheon/ethereum/eth/sync/tasks/PersistBlockTask.java | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/AbstractWorldUpdater.java b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/AbstractWorldUpdater.java index cdcd11f80e..3c8946f8a4 100644 --- a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/AbstractWorldUpdater.java +++ b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/AbstractWorldUpdater.java @@ -398,7 +398,7 @@ public abstract class AbstractWorldUpdater 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(update.address); + existing = new UpdateTrackingAccount<>(update.address); } wrapped.updatedAccounts.put(existing.address, existing); } diff --git a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/EthHashCacheFactory.java b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/EthHashCacheFactory.java index 37528a7e09..d67bbf0227 100644 --- a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/EthHashCacheFactory.java +++ b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/EthHashCacheFactory.java @@ -45,7 +45,7 @@ public class EthHashCacheFactory { Cache 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) { diff --git a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/EthHasher.java b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/EthHasher.java index 4b4c47ad9e..9b92227985 100644 --- a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/EthHasher.java +++ b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/EthHasher.java @@ -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); diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServer.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServer.java index 8ca276f922..ebc2dc8619 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServer.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/EthServer.java @@ -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) { diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/PersistBlockTask.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/PersistBlockTask.java index d436b9ffbe..a6321db110 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/PersistBlockTask.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/PersistBlockTask.java @@ -84,7 +84,7 @@ public class PersistBlockTask extends AbstractEthTask { successfulImports, headerValidationMode)); } - return future.thenApply((r) -> successfulImports); + return future.thenApply(r -> successfulImports); }; }