Upgrade GoogleJavaFormat to 1.7 (#795)

Two changes:
* Stream chains now take up less vertical lines, only breaking on
  stream operations.
* Long annotations that span multiple lines no longer have a dangling
  parentesis and indent 4 spaces.
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
Danno Ferrin 6 years ago committed by GitHub
parent 6abc4604fb
commit aaeaa59f31
  1. 4
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Clique.java
  2. 4
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Ibft.java
  3. 3
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java
  4. 4
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/cluster/Cluster.java
  5. 2
      build.gradle
  6. 4
      config/src/main/java/tech/pegasys/pantheon/config/GenesisConfigFile.java
  7. 3
      consensus/clique/src/test/java/tech/pegasys/pantheon/consensus/clique/CliqueExtraDataTest.java
  8. 5
      consensus/common/src/main/java/tech/pegasys/pantheon/consensus/common/jsonrpc/AbstractVoteProposerMethod.java
  9. 4
      consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/IntegrationTestHelpers.java
  10. 12
      consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/RoundSpecificPeers.java
  11. 3
      consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/StubValidatorMulticaster.java
  12. 4
      consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/TestContextBuilder.java
  13. 4
      consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/IbftBlockHashing.java
  14. 4
      consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockHash.java
  15. 4
      consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockNumber.java
  16. 7
      consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/network/ValidatorPeers.java
  17. 3
      consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/RoundChangeCertificate.java
  18. 3
      consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundChangeArtifacts.java
  19. 3
      consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundState.java
  20. 4
      consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/validation/NewRoundPayloadValidator.java
  21. 9
      consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/IbftBlockHashingTest.java
  22. 3
      consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/headervalidationrules/IbftCommitSealsValidationRuleTest.java
  23. 3
      consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundChangeManagerTest.java
  24. 4
      consensus/ibftlegacy/src/main/java/tech/pegasys/pantheon/consensus/ibftlegacy/IbftBlockHashing.java
  25. 3
      consensus/ibftlegacy/src/test/java/tech/pegasys/pantheon/consensus/ibftlegacy/headervalidationrules/IbftExtraDataValidationRuleTest.java
  26. 9
      errorprone-checks/src/main/java/tech/pegasys/errorpronechecks/DoNotCreateSecureRandomDirectly.java
  27. 9
      errorprone-checks/src/main/java/tech/pegasys/errorpronechecks/DoNotInvokeMessageDigestDirectly.java
  28. 9
      errorprone-checks/src/main/java/tech/pegasys/errorpronechecks/DoNotReturnNullOptionals.java
  29. 9
      errorprone-checks/src/main/java/tech/pegasys/errorpronechecks/MethodInputParametersMustBeFinal.java
  30. 4
      ethereum/core/src/integration-test/java/tech/pegasys/pantheon/ethereum/vm/TraceTransactionIntegrationTest.java
  31. 5
      ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/AbstractMessageProcessor.java
  32. 3
      ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/BlockHeaderValidator.java
  33. 4
      ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetTransactionProcessor.java
  34. 3
      ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MutableProtocolSchedule.java
  35. 4
      ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/privacy/PrivateTransactionHandler.java
  36. 3
      ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/core/TransactionPoolTest.java
  37. 3
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/BlockPropagationManager.java
  38. 3
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/fastsync/FastSyncBlockHandler.java
  39. 3
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/fastsync/PivotBlockRetriever.java
  40. 7
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/state/PendingBlocks.java
  41. 3
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/CompleteBlocksTask.java
  42. 7
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/GetReceiptsFromPeerTask.java
  43. 6
      ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/ethtaskutils/PeerMessageTaskTest.java
  44. 3
      ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/sync/fullsync/FullSyncDownloaderTest.java
  45. 3
      ethereum/jsonrpc/src/integration-test/java/tech/pegasys/pantheon/ethereum/jsonrpc/methods/EthGetFilterChangesIntegrationTest.java
  46. 11
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcHttpService.java
  47. 15
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/authentication/TomlAuth.java
  48. 4
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/filter/FilterRepository.java
  49. 3
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthProtocolVersion.java
  50. 9
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/queries/BlockchainQueries.java
  51. 16
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/results/BlockResultFactory.java
  52. 4
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/results/DebugTraceTransactionResult.java
  53. 4
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/results/PeerResult.java
  54. 4
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/results/StructLogWithError.java
  55. 8
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/subscription/SubscriptionManager.java
  56. 8
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/subscription/logs/LogsSubscriptionService.java
  57. 5
      ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcHttpServiceTest.java
  58. 10
      ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/queries/BlockchainQueriesTest.java
  59. 3
      ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/NetworkRunner.java
  60. 3
      ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryController.java
  61. 3
      ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerTable.java
  62. 3
      ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/permissioning/NodeWhitelistController.java
  63. 7
      ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java
  64. 8
      ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryBondingTest.java
  65. 7
      ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryBootstrappingTest.java
  66. 9
      ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryObserversTest.java
  67. 20
      ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryControllerTest.java
  68. 4
      ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryTableRefreshTest.java
  69. 4
      metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsHttpService.java
  70. 8
      metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusMetricsSystem.java
  71. 8
      pantheon/src/main/java/tech/pegasys/pantheon/PermissioningConfigurationBuilder.java
  72. 3
      pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java
  73. 27
      pantheon/src/main/java/tech/pegasys/pantheon/cli/BlocksSubCommand.java
  74. 5
      pantheon/src/main/java/tech/pegasys/pantheon/cli/CommandLineUtils.java
  75. 383
      pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java
  76. 7
      pantheon/src/main/java/tech/pegasys/pantheon/cli/PasswordSubCommand.java
  77. 27
      pantheon/src/main/java/tech/pegasys/pantheon/cli/PublicKeySubCommand.java
  78. 32
      pantheon/src/main/java/tech/pegasys/pantheon/cli/StandaloneCommand.java
  79. 4
      pantheon/src/main/java/tech/pegasys/pantheon/cli/TomlConfigFileDefaultProvider.java
  80. 3
      pantheon/src/main/java/tech/pegasys/pantheon/util/PermissioningConfigurationValidator.java
  81. 5
      pantheon/src/test/java/tech/pegasys/pantheon/cli/CommandLineUtilsTest.java
  82. 4
      pantheon/src/test/java/tech/pegasys/pantheon/util/StringUtilsTest.java
  83. 4
      services/kvstore/src/main/java/tech/pegasys/pantheon/services/kvstore/InMemoryKeyValueStorage.java
  84. 8
      testutil/src/main/java/tech/pegasys/orion/testutil/OrionTestHarness.java

@ -118,9 +118,7 @@ public class Clique {
public Condition build() {
final Map<Address, Boolean> proposalsAsAddress =
this.proposals
.entrySet()
.stream()
this.proposals.entrySet().stream()
.collect(Collectors.toMap(p -> p.getKey().getAddress(), Entry::getValue));
return new ExpectProposals(clique, proposalsAsAddress);
}

@ -81,9 +81,7 @@ public class Ibft {
public Condition build() {
final Map<Address, Boolean> proposalsAsAddress =
this.proposals
.entrySet()
.stream()
this.proposals.entrySet().stream()
.collect(Collectors.toMap(p -> p.getKey().getAddress(), Entry::getValue));
return new tech.pegasys.pantheon.tests.acceptance.dsl.condition.ibft.ExpectProposals(
ibft, proposalsAsAddress);

@ -320,8 +320,7 @@ public class PantheonNode implements Node, NodeConfiguration, RunnableNode, Auto
}
List<URI> bootnodes() {
return bootnodes
.stream()
return bootnodes.stream()
.filter(node -> !node.equals(this.enodeUrl()))
.map(URI::create)
.collect(Collectors.toList());

@ -113,9 +113,7 @@ public class Cluster implements AutoCloseable {
}
public void verifyOnActiveNodes(final Condition condition) {
nodes
.values()
.stream()
nodes.values().stream()
.filter(node -> pantheonNodeRunner.isActive(node.getName()))
.forEach(condition::verify);
}

@ -108,7 +108,7 @@ allprojects {
exclude '**/.gradle/**'
}
removeUnusedImports()
googleJavaFormat()
googleJavaFormat('1.7')
importOrder 'tech.pegasys', 'java', ''
trimTrailingWhitespace()
endWithNewline()

@ -64,9 +64,7 @@ public class GenesisConfigFile {
public Stream<GenesisAllocation> getAllocations() {
final JsonObject allocations = configRoot.getJsonObject("alloc");
return allocations
.fieldNames()
.stream()
return allocations.fieldNames().stream()
.map(key -> new GenesisAllocation(key, allocations.getJsonObject(key)));
}

@ -101,8 +101,7 @@ public class CliqueExtraDataTest {
}
final List<Address> addresses =
nodeKeys
.stream()
nodeKeys.stream()
.map(KeyPair::getPublicKey)
.map(Util::publicKeyToAddress)
.collect(Collectors.toList());

@ -31,10 +31,7 @@ public class AbstractVoteProposerMethod {
public JsonRpcResponse response(final JsonRpcRequest request) {
final Map<String, Boolean> proposals =
voteProposer
.getProposals()
.entrySet()
.stream()
voteProposer.getProposals().entrySet().stream()
.collect(
Collectors.toMap(
proposal -> proposal.getKey().toString(),

@ -50,9 +50,7 @@ public class IntegrationTestHelpers {
return new PreparedRoundArtifacts(
peers.getProposer().getMessageFactory().createProposal(preparedRound, block),
peers
.createSignedPreparePayloadOfNonProposing(preparedRound, block.getHash())
.stream()
peers.createSignedPreparePayloadOfNonProposing(preparedRound, block.getHash()).stream()
.map(Prepare::new)
.collect(Collectors.toList()));
}

@ -80,8 +80,7 @@ public class RoundSpecificPeers {
public List<SignedData<RoundChangePayload>> roundChangeForNonProposing(
final ConsensusRoundIdentifier targetRound) {
return nonProposingPeers
.stream()
return nonProposingPeers.stream()
.map(peer -> peer.injectRoundChange(targetRound, empty()).getSignedPayload())
.collect(Collectors.toList());
}
@ -102,16 +101,14 @@ public class RoundSpecificPeers {
public List<SignedData<RoundChangePayload>> createSignedRoundChangePayload(
final ConsensusRoundIdentifier roundId) {
return peers
.stream()
return peers.stream()
.map(p -> p.getMessageFactory().createRoundChange(roundId, empty()).getSignedPayload())
.collect(Collectors.toList());
}
public List<SignedData<RoundChangePayload>> createSignedRoundChangePayload(
final ConsensusRoundIdentifier roundId, final PreparedRoundArtifacts preparedRoundArtifacts) {
return peers
.stream()
return peers.stream()
.map(
p ->
p.getMessageFactory()
@ -130,8 +127,7 @@ public class RoundSpecificPeers {
public Collection<SignedData<PreparePayload>> createSignedPreparePayloadOfNonProposing(
final ConsensusRoundIdentifier preparedRound, final Hash hash) {
return nonProposingPeers
.stream()
return nonProposingPeers.stream()
.map(role -> role.getMessageFactory().createPrepare(preparedRound, hash).getSignedPayload())
.collect(Collectors.toList());
}

@ -38,8 +38,7 @@ public class StubValidatorMulticaster implements ValidatorMulticaster {
@Override
public void send(final MessageData message, final Collection<Address> blackList) {
validatorNodes
.stream()
validatorNodes.stream()
.filter(peer -> !blackList.contains(peer.getNodeAddress()))
.forEach(peer -> peer.handleReceivedMessage(message));
}

@ -173,9 +173,7 @@ public class TestContextBuilder {
// NOTE: the remotePeers needs to be ordered based on Address (as this is used to determine
// the proposer order which must be managed in test).
final Map<Address, ValidatorPeer> remotePeers =
networkNodes
.getRemotePeers()
.stream()
networkNodes.getRemotePeers().stream()
.collect(
Collectors.toMap(
NodeParams::getAddress,

@ -71,9 +71,7 @@ public class IbftBlockHashing {
final Hash committerHash =
IbftBlockHashing.calculateDataHashForCommittedSeal(header, ibftExtraData);
return ibftExtraData
.getSeals()
.stream()
return ibftExtraData.getSeals().stream()
.map(p -> Util.signatureToAddress(p, committerHash))
.collect(Collectors.toList());
}

@ -61,9 +61,7 @@ public class IbftGetValidatorsByBlockHash implements JsonRpcMethod {
return blockHeader
.map(
header ->
blockInterface
.validatorsInBlock(header)
.stream()
blockInterface.validatorsInBlock(header).stream()
.map(validator -> validator.toString())
.collect(Collectors.toList()))
.orElse(null);

@ -54,9 +54,7 @@ public class IbftGetValidatorsByBlockNumber extends AbstractBlockParameterMethod
return blockHeader
.map(
header ->
blockInterface
.validatorsInBlock(header)
.stream()
blockInterface.validatorsInBlock(header).stream()
.map(validator -> validator.toString())
.collect(Collectors.toList()))
.orElse(null);

@ -65,9 +65,7 @@ public class ValidatorPeers implements ValidatorMulticaster, PeerConnectionTrack
@Override
public void send(final MessageData message, final Collection<Address> blackList) {
final Collection<Address> includedValidators =
validatorProvider
.getValidators()
.stream()
validatorProvider.getValidators().stream()
.filter(a -> !blackList.contains(a))
.collect(Collectors.toSet());
sendMessageToSpecificAddresses(includedValidators, message);
@ -77,8 +75,7 @@ public class ValidatorPeers implements ValidatorMulticaster, PeerConnectionTrack
final Collection<Address> recipients, final MessageData message) {
LOG.trace(
"Sending message to peers messageCode={} recipients={}", message.getCode(), recipients);
recipients
.stream()
recipients.stream()
.map(peerConnections::get)
.filter(Objects::nonNull)
.forEach(

@ -66,8 +66,7 @@ public class RoundChangeCertificate {
public RoundChangeCertificate buildCertificate() {
return new RoundChangeCertificate(
roundChangePayloads
.stream()
roundChangePayloads.stream()
.map(RoundChange::getSignedPayload)
.collect(Collectors.toList()));
}

@ -47,8 +47,7 @@ public class RoundChangeArtifacts {
public static RoundChangeArtifacts create(final Collection<RoundChange> roundChanges) {
final Collection<SignedData<RoundChangePayload>> payloads =
roundChanges
.stream()
roundChanges.stream()
.map(roundChange -> roundChange.getSignedPayload())
.collect(Collectors.toList());

@ -121,8 +121,7 @@ public class RoundState {
}
public Collection<Signature> getCommitSeals() {
return commitMessages
.stream()
return commitMessages.stream()
.map(cp -> cp.getSignedPayload().getPayload().getCommitSeal())
.collect(Collectors.toList());
}

@ -108,9 +108,7 @@ public class NewRoundPayloadValidator {
return false;
}
if (!roundChangeCert
.getRoundChangePayloads()
.stream()
if (!roundChangeCert.getRoundChangePayloads().stream()
.allMatch(p -> p.getPayload().getRoundIdentifier().equals(expectedRound))) {
LOG.info(
"Invalid NewRound message, not all embedded RoundChange messages have a "

@ -62,8 +62,7 @@ public class IbftBlockHashingTest {
HEADER_TO_BE_HASHED, IbftExtraData.decode(HEADER_TO_BE_HASHED.getExtraData()));
List<Address> expectedCommitterAddresses =
COMMITTERS_KEY_PAIRS
.stream()
COMMITTERS_KEY_PAIRS.stream()
.map(keyPair -> Util.publicKeyToAddress(keyPair.getPublicKey()))
.collect(Collectors.toList());
@ -79,8 +78,7 @@ public class IbftBlockHashingTest {
BlockHeaderBuilder builder = setHeaderFieldsExceptForExtraData();
List<Signature> commitSeals =
COMMITTERS_KEY_PAIRS
.stream()
COMMITTERS_KEY_PAIRS.stream()
.map(keyPair -> SECP256K1.sign(dataHahsForCommittedSeal, keyPair))
.collect(Collectors.toList());
@ -151,8 +149,7 @@ public class IbftBlockHashingTest {
builder.buildBlockHeader().writeTo(rlpForHeaderFroCommittersSigning);
List<Signature> commitSeals =
COMMITTERS_KEY_PAIRS
.stream()
COMMITTERS_KEY_PAIRS.stream()
.map(
keyPair ->
SECP256K1.sign(Hash.hash(rlpForHeaderFroCommittersSigning.encoded()), keyPair))

@ -46,8 +46,7 @@ public class IbftCommitSealsValidationRuleTest {
IntStream.range(0, 2).mapToObj(i -> KeyPair.generate()).collect(Collectors.toList());
final List<Address> committerAddresses =
committerKeyPairs
.stream()
committerKeyPairs.stream()
.map(keyPair -> Util.publicKeyToAddress(keyPair.getPublicKey()))
.sorted()
.collect(Collectors.toList());

@ -143,8 +143,7 @@ public class RoundChangeManagerTest {
final Proposal proposal = messageFactory.createProposal(proposalRound, block);
final List<Prepare> preparePayloads =
prepareProviders
.stream()
prepareProviders.stream()
.map(
k -> {
final MessageFactory prepareFactory = new MessageFactory(k);

@ -107,9 +107,7 @@ public class IbftBlockHashing {
final Hash committerHash =
IbftBlockHashing.calculateDataHashForCommittedSeal(header, ibftExtraData);
return ibftExtraData
.getSeals()
.stream()
return ibftExtraData.getSeals().stream()
.map(p -> Util.signatureToAddress(p, committerHash))
.collect(Collectors.toList());
}

@ -83,8 +83,7 @@ public class IbftExtraDataValidationRuleTest {
IbftBlockHashing.calculateDataHashForCommittedSeal(header, extraDataInHeader);
final List<Signature> commitSeals =
committerKeyPairs
.stream()
committerKeyPairs.stream()
.map(keys -> SECP256K1.sign(headerHashForCommitters, keys))
.collect(Collectors.toList());

@ -29,11 +29,10 @@ import com.sun.tools.javac.code.Symbol;
@AutoService(BugChecker.class)
@BugPattern(
name = "DoNotCreateSecureRandomDirectly",
summary = "Do not create SecureRandom directly.",
category = JDK,
severity = WARNING
)
name = "DoNotCreateSecureRandomDirectly",
summary = "Do not create SecureRandom directly.",
category = JDK,
severity = WARNING)
public class DoNotCreateSecureRandomDirectly extends BugChecker
implements MethodInvocationTreeMatcher, NewClassTreeMatcher {

@ -25,11 +25,10 @@ import com.sun.source.tree.MethodInvocationTree;
@AutoService(BugChecker.class)
@BugPattern(
name = "DoNotInvokeMessageDigestDirectly",
summary = "Do not invoke MessageDigest.getInstance directly.",
category = JDK,
severity = WARNING
)
name = "DoNotInvokeMessageDigestDirectly",
summary = "Do not invoke MessageDigest.getInstance directly.",
category = JDK,
severity = WARNING)
public class DoNotInvokeMessageDigestDirectly extends BugChecker
implements MethodInvocationTreeMatcher {

@ -35,11 +35,10 @@ import com.sun.source.tree.Tree;
@AutoService(BugChecker.class) // the service descriptor
@BugPattern(
name = "DoNotReturnNullOptionals",
summary = "Do not return null optionals.",
category = JDK,
severity = SUGGESTION
)
name = "DoNotReturnNullOptionals",
summary = "Do not return null optionals.",
category = JDK,
severity = SUGGESTION)
public class DoNotReturnNullOptionals extends BugChecker implements MethodTreeMatcher {
private static class ReturnNullMatcher implements Matcher<Tree> {

@ -31,11 +31,10 @@ import com.sun.source.tree.VariableTree;
@AutoService(BugChecker.class)
@BugPattern(
name = "MethodInputParametersMustBeFinal",
summary = "Method input parameters must be final.",
category = JDK,
severity = WARNING
)
name = "MethodInputParametersMustBeFinal",
summary = "Method input parameters must be final.",
category = JDK,
severity = WARNING)
public class MethodInputParametersMustBeFinal extends BugChecker
implements MethodTreeMatcher, ClassTreeMatcher {

@ -94,9 +94,7 @@ public class TraceTransactionIntegrationTest {
blockHashLookup);
assertThat(result.isSuccessful()).isTrue();
final Account createdContract =
createTransactionUpdater
.getTouchedAccounts()
.stream()
createTransactionUpdater.getTouchedAccounts().stream()
.filter(account -> !account.getCode().isEmpty())
.findAny()
.get();

@ -82,10 +82,7 @@ public abstract class AbstractMessageProcessor {
private void clearAccumulatedStateBesidesGasAndOutput(final MessageFrame frame) {
final Collection<Address> addressesToForceCommit =
frame
.getWorldState()
.getTouchedAccounts()
.stream()
frame.getWorldState().getTouchedAccounts().stream()
.filter(a -> forceDeleteAccountsWhenEmpty.contains(a.getAddress()) && a.isEmpty())
.map(Account::getAddress)
.collect(Collectors.toCollection(ArrayList::new));

@ -82,8 +82,7 @@ public class BlockHeaderValidator<C> {
final BlockHeader parent,
final ProtocolContext<C> protocolContext,
final Predicate<Rule<C>> filter) {
return rules
.stream()
return rules.stream()
.filter(filter)
.allMatch(rule -> rule.validate(header, parent, protocolContext));
}

@ -293,9 +293,7 @@ public class MainnetTransactionProcessor implements TransactionProcessor {
}
private static void clearEmptyAccounts(final WorldUpdater worldState) {
worldState
.getTouchedAccounts()
.stream()
worldState.getTouchedAccounts().stream()
.filter(Account::isEmpty)
.forEach(a -> worldState.deleteAccount(a.getAddress()));
}

@ -62,8 +62,7 @@ public class MutableProtocolSchedule<C> implements ProtocolSchedule<C> {
}
public String listMilestones() {
return protocolSpecs
.stream()
return protocolSpecs.stream()
.sorted(Comparator.comparing(ScheduledProtocolSpec::getBlock))
.map(spec -> spec.getSpec().getName() + ": " + spec.getBlock())
.collect(Collectors.joining(", ", "[", "]"));

@ -59,9 +59,7 @@ public class PrivateTransactionHandler {
private SendRequest createSendRequest(final PrivateTransaction privateTransaction) {
final List<String> privateFor =
privateTransaction
.getPrivateFor()
.stream()
privateTransaction.getPrivateFor().stream()
.map(BytesValues::asString)
.collect(Collectors.toList());

@ -429,8 +429,7 @@ public class TransactionPoolTest {
.buildHeader(),
new BlockBody(transactionList, emptyList()));
final List<TransactionReceipt> transactionReceipts =
transactionList
.stream()
transactionList.stream()
.map(transaction -> new TransactionReceipt(1, 1, emptyList()))
.collect(toList());
blockchain.appendBlock(block, transactionReceipts);

@ -190,8 +190,7 @@ public class BlockPropagationManager<C> {
final long localChainHeight = protocolContext.getBlockchain().getChainHeadBlockNumber();
final long bestChainHeight = syncState.bestChainHeight(localChainHeight);
final List<NewBlockHash> relevantAnnouncements =
announcedBlocks
.stream()
announcedBlocks.stream()
.filter(a -> shouldImportBlockAtHeight(a.number(), localChainHeight, bestChainHeight))
.collect(Collectors.toList());

@ -82,8 +82,7 @@ public class FastSyncBlockHandler<C> implements BlockHandler<BlockWithReceipts>
private List<BlockWithReceipts> combineBlocksAndReceipts(
final List<Block> blocks, final Map<BlockHeader, List<TransactionReceipt>> receiptsByHeader) {
return blocks
.stream()
return blocks.stream()
.map(
block -> {
final List<TransactionReceipt> receipts =

@ -83,8 +83,7 @@ public class PivotBlockRetriever<C> {
.collect(Collectors.toList());
final int confirmationsRequired = peersToQuery.size() / 2 + 1;
return peersToQuery
.stream()
return peersToQuery.stream()
.map(
peer -> {
final RetryingGetHeaderFromPeerByNumberTask getHeaderTask = createGetHeaderTask(peer);

@ -76,9 +76,7 @@ public class PendingBlocks {
}
public void purgeBlocksOlderThan(final long blockNumber) {
pendingBlocks
.values()
.stream()
pendingBlocks.values().stream()
.filter(b -> b.getHeader().getNumber() < blockNumber)
.forEach(this::deregisterPendingBlock);
}
@ -92,8 +90,7 @@ public class PendingBlocks {
if (blocksByParent == null || blocksByParent.size() == 0) {
return Collections.emptyList();
}
return blocksByParent
.stream()
return blocksByParent.stream()
.map(pendingBlocks::get)
.filter(Objects::nonNull)
.collect(Collectors.toList());

@ -121,8 +121,7 @@ public class CompleteBlocksTask<C> extends AbstractRetryingPeerTask<List<Block>>
}
private List<BlockHeader> incompleteHeaders() {
return headers
.stream()
return headers.stream()
.filter(h -> blocks.get(h.getNumber()) == null)
.collect(Collectors.toList());
}

@ -74,9 +74,7 @@ public class GetReceiptsFromPeerTask
// Since we have to match up the data by receipt root, we only need to request receipts
// for one of the headers with each unique receipt root.
final List<Hash> blockHashes =
headersByReceiptsRoot
.values()
.stream()
headersByReceiptsRoot.values().stream()
.map(headers -> headers.get(0).getHash())
.collect(toList());
return peer.getReceipts(blockHashes);
@ -116,8 +114,7 @@ public class GetReceiptsFromPeerTask
@Override
protected Optional<EthPeer> findSuitablePeer() {
final long maximumRequiredBlockNumber =
blockHeaders
.stream()
blockHeaders.stream()
.mapToLong(BlockHeader::getNumber)
.max()
.orElse(BlockHeader.GENESIS_BLOCK_NUMBER);

@ -126,11 +126,7 @@ public abstract class PeerMessageTaskTest<T> extends AbstractMessageTaskTest<T,
assertThat(future.isCompletedExceptionally()).isTrue();
assertThat(
respondingEthPeer
.getEthPeer()
.timeoutCounts()
.values()
.stream()
respondingEthPeer.getEthPeer().timeoutCounts().values().stream()
.mapToInt(AtomicInteger::get)
.sum())
.isEqualTo(1);

@ -603,8 +603,7 @@ public class FullSyncDownloaderTest {
while (localBlockchain.getChainHeadBlockNumber() < bestPeerChainHead) {
// Check that any requests for checkpoint headers are only sent to the best peer
final long checkpointRequestsToOtherPeers =
otherPeers
.stream()
otherPeers.stream()
.map(RespondingEthPeer::pendingOutgoingRequests)
.flatMap(Function.identity())
.filter(m -> m.getCode() == EthPV62.GET_BLOCK_HEADERS)

@ -244,8 +244,7 @@ public class EthGetFilterChangesIntegrationTest {
.buildHeader(),
new BlockBody(transactionList, emptyList()));
final List<TransactionReceipt> transactionReceipts =
transactionList
.stream()
transactionList.stream()
.map(transaction -> new TransactionReceipt(1, 1, emptyList()))
.collect(toList());
blockchain.appendBlock(block, transactionReceipts);

@ -262,9 +262,7 @@ public class JsonRpcHttpService {
}
private boolean hostIsInWhitelist(final String hostHeader) {
return config
.getHostsWhitelist()
.stream()
return config.getHostsWhitelist().stream()
.anyMatch(whitelistEntry -> whitelistEntry.toLowerCase().equals(hostHeader.toLowerCase()));
}
@ -424,8 +422,7 @@ public class JsonRpcHttpService {
final RoutingContext routingContext, final JsonArray jsonArray) {
// Interpret json as rpc request
final List<Future> responses =
jsonArray
.stream()
jsonArray.stream()
.map(
obj -> {
if (!(obj instanceof JsonObject)) {
@ -460,9 +457,7 @@ public class JsonRpcHttpService {
return;
}
final JsonRpcResponse[] completed =
res.result()
.list()
.stream()
res.result().list().stream()
.map(JsonRpcResponse.class::cast)
.filter(this::isNonEmptyResponses)
.toArray(JsonRpcResponse[]::new);

@ -116,24 +116,15 @@ public class TomlAuth implements AuthProvider {
private TomlUser readTomlUserFromTable(final String username, final TomlTable userData) {
final String saltedAndHashedPassword = userData.getString("password", () -> "");
final List<String> groups =
userData
.getArrayOrEmpty("groups")
.toList()
.stream()
userData.getArrayOrEmpty("groups").toList().stream()
.map(Object::toString)
.collect(Collectors.toList());
final List<String> permissions =
userData
.getArrayOrEmpty("permissions")
.toList()
.stream()
userData.getArrayOrEmpty("permissions").toList().stream()
.map(Object::toString)
.collect(Collectors.toList());
final List<String> roles =
userData
.getArrayOrEmpty("roles")
.toList()
.stream()
userData.getArrayOrEmpty("roles").toList().stream()
.map(Object::toString)
.collect(Collectors.toList());

@ -31,9 +31,7 @@ public class FilterRepository {
}
<T extends Filter> Collection<T> getFiltersOfType(final Class<T> filterClass) {
return filters
.values()
.stream()
return filters.values().stream()
.flatMap(f -> getIfTypeMatches(f, filterClass).map(Stream::of).orElseGet(Stream::empty))
.collect(Collectors.toList());
}

@ -27,8 +27,7 @@ public class EthProtocolVersion implements JsonRpcMethod {
public EthProtocolVersion(final Set<Capability> supportedCapabilities) {
final OptionalInt version =
supportedCapabilities
.stream()
supportedCapabilities.stream()
.filter(cap -> EthProtocol.NAME.equals(cap.getName()))
.mapToInt(Capability::getVersion)
.max();

@ -293,8 +293,7 @@ public class BlockchainQueries {
formatTransactions(
txs, header.getNumber(), blockHeaderHash);
final List<Hash> ommers =
body.getOmmers()
.stream()
body.getOmmers().stream()
.map(BlockHeader::getHash)
.collect(Collectors.toList());
final int size = new Block(header, body).calculateSize();
@ -345,13 +344,11 @@ public class BlockchainQueries {
.map(
(td) -> {
final List<Hash> txs =
body.getTransactions()
.stream()
body.getTransactions().stream()
.map(Transaction::hash)
.collect(Collectors.toList());
final List<Hash> ommers =
body.getOmmers()
.stream()
body.getOmmers().stream()
.map(BlockHeader::getHash)
.collect(Collectors.toList());
final int size = new Block(header, body).calculateSize();

@ -27,15 +27,11 @@ public class BlockResultFactory {
public BlockResult transactionComplete(
final BlockWithMetadata<TransactionWithMetadata, Hash> blockWithMetadata) {
final List<TransactionResult> txs =
blockWithMetadata
.getTransactions()
.stream()
blockWithMetadata.getTransactions().stream()
.map(TransactionCompleteResult::new)
.collect(Collectors.toList());
final List<JsonNode> ommers =
blockWithMetadata
.getOmmers()
.stream()
blockWithMetadata.getOmmers().stream()
.map(Hash::toString)
.map(TextNode::new)
.collect(Collectors.toList());
@ -49,16 +45,12 @@ public class BlockResultFactory {
public BlockResult transactionHash(final BlockWithMetadata<Hash, Hash> blockWithMetadata) {
final List<TransactionResult> txs =
blockWithMetadata
.getTransactions()
.stream()
blockWithMetadata.getTransactions().stream()
.map(Hash::toString)
.map(TransactionHashResult::new)
.collect(Collectors.toList());
final List<JsonNode> ommers =
blockWithMetadata
.getOmmers()
.stream()
blockWithMetadata.getOmmers().stream()
.map(Hash::toString)
.map(TextNode::new)
.collect(Collectors.toList());

@ -33,9 +33,7 @@ public class DebugTraceTransactionResult {
gas = transactionTrace.getGas();
returnValue = transactionTrace.getResult().getOutput().toString().substring(2);
structLogs =
transactionTrace
.getTraceFrames()
.stream()
transactionTrace.getTraceFrames().stream()
.map(DebugTraceTransactionResult::createStructLog)
.collect(Collectors.toList());
failed = !transactionTrace.getResult().isSuccessful();

@ -37,9 +37,7 @@ public class PeerResult {
this.version = Quantity.create(peer.getPeer().getVersion());
this.name = peer.getPeer().getClientId();
this.caps =
peer.getPeer()
.getCapabilities()
.stream()
peer.getPeer().getCapabilities().stream()
.map(Capability::toString)
.map(TextNode::new)
.collect(Collectors.toList());

@ -26,9 +26,7 @@ public class StructLogWithError extends StructLog {
error =
traceFrame.getExceptionalHaltReasons().isEmpty()
? null
: traceFrame
.getExceptionalHaltReasons()
.stream()
: traceFrame.getExceptionalHaltReasons().stream()
.map(ExceptionalHaltReason::name)
.toArray(String[]::new);
}

@ -152,9 +152,7 @@ public class SubscriptionManager extends AbstractVerticle {
}
public <T> List<T> subscriptionsOfType(final SubscriptionType type, final Class<T> clazz) {
return subscriptions
.entrySet()
.stream()
return subscriptions.entrySet().stream()
.map(Entry::getValue)
.filter(subscription -> subscription.isType(type))
.map(subscriptionBuilder.mapToSubscriptionClass(clazz))
@ -164,9 +162,7 @@ public class SubscriptionManager extends AbstractVerticle {
public void sendMessage(final Long subscriptionId, final JsonRpcResult msg) {
final SubscriptionResponse response = new SubscriptionResponse(subscriptionId, msg);
connectionSubscriptionsMap
.entrySet()
.stream()
connectionSubscriptionsMap.entrySet().stream()
.filter(e -> e.getValue().contains(subscriptionId))
.map(Entry::getKey)
.findFirst()

@ -46,9 +46,7 @@ public class LogsSubscriptionService implements BlockAddedObserver {
return;
}
event
.getAddedTransactions()
.stream()
event.getAddedTransactions().stream()
.map(tx -> blockchainQueries.transactionReceiptByTransactionHash(tx.hash()))
.filter(Optional::isPresent)
.map(Optional::get)
@ -58,9 +56,7 @@ public class LogsSubscriptionService implements BlockAddedObserver {
sendLogsToMatchingSubscriptions(logs, logsSubscriptions, receiptWithMetadata, false);
});
event
.getRemovedTransactions()
.stream()
event.getRemovedTransactions().stream()
.map(tx -> blockchainQueries.transactionReceiptByTransactionHash(tx.hash()))
.filter(Optional::isPresent)
.map(Optional::get)

@ -1824,10 +1824,7 @@ public class JsonRpcHttpServiceTest {
final int size = block.calculateSize();
final List<Hash> txs =
block
.getBody()
.getTransactions()
.stream()
block.getBody().getTransactions().stream()
.map(Transaction::hash)
.collect(Collectors.toList());
final List<Hash> ommers =

@ -485,10 +485,7 @@ public class BlockchainQueriesTest {
final Block targetBlock, final BlockWithMetadata<TransactionWithMetadata, Hash> result) {
assertEquals(targetBlock.getHeader(), result.getHeader());
final List<Hash> expectedOmmers =
targetBlock
.getBody()
.getOmmers()
.stream()
targetBlock.getBody().getOmmers().stream()
.map(BlockHeader::getHash)
.collect(Collectors.toList());
assertEquals(expectedOmmers, result.getOmmers());
@ -507,10 +504,7 @@ public class BlockchainQueriesTest {
final Block targetBlock, final BlockWithMetadata<Hash, Hash> result) {
assertEquals(targetBlock.getHeader(), result.getHeader());
final List<Hash> expectedOmmers =
targetBlock
.getBody()
.getOmmers()
.stream()
targetBlock.getBody().getOmmers().stream()
.map(BlockHeader::getHash)
.collect(Collectors.toList());
assertEquals(expectedOmmers, result.getOmmers());

@ -196,8 +196,7 @@ public class NetworkRunner implements AutoCloseable {
subProtocolMap.put(subProtocol.getName(), subProtocol);
}
final List<Capability> caps =
protocolManagers
.stream()
protocolManagers.stream()
.flatMap(p -> p.getSupportedCapabilities().stream())
.collect(Collectors.toList());
for (final Capability cap : caps) {

@ -153,8 +153,7 @@ public class PeerDiscoveryController {
throw new IllegalStateException("The peer table had already been started");
}
bootstrapNodes
.stream()
bootstrapNodes.stream()
.filter(node -> peerTable.tryAdd(node).getOutcome() == Outcome.ADDED)
.filter(node -> whitelistIfPresentIsNodePermitted(node))
.forEach(node -> bond(node, true));

@ -179,8 +179,7 @@ public class PeerTable {
*/
public List<DiscoveryPeer> nearestPeers(final BytesValue target, final int limit) {
final BytesValue keccak256 = Hash.keccak256(target);
return getAllPeers()
.stream()
return getAllPeers().stream()
.filter(p -> p.getStatus() == PeerDiscoveryStatus.BONDED)
.sorted(comparingInt((peer) -> distance(peer.keccak256(), keccak256)))
.limit(limit)

@ -99,8 +99,7 @@ public class NodeWhitelistController {
}
public boolean isPermitted(final Peer node) {
return nodesWhitelist
.stream()
return nodesWhitelist.stream()
.anyMatch(
p -> {
boolean idsMatch = node.getId().equals(p.getId());

@ -64,8 +64,7 @@ public class PeerDiscoveryAgentTest {
final List<MockPeerDiscoveryAgent> otherAgents =
helper.startDiscoveryAgents(20, Collections.emptyList());
final List<DiscoveryPeer> otherPeers =
otherAgents
.stream()
otherAgents.stream()
.map(MockPeerDiscoveryAgent::getAdvertisedPeer)
.collect(Collectors.toList());
@ -91,9 +90,7 @@ public class PeerDiscoveryAgentTest {
// Check response packet
List<IncomingPacket> incomingPackets =
testAgent
.getIncomingPackets()
.stream()
testAgent.getIncomingPackets().stream()
.filter(p -> p.packet.getType().equals(PacketType.NEIGHBORS))
.collect(Collectors.toList());
assertThat(incomingPackets.size()).isEqualTo(1);

@ -43,9 +43,7 @@ public class PeerDiscoveryBondingTest {
helper.sendMessageBetweenAgents(otherAgent, agent, ping);
final List<IncomingPacket> otherAgentIncomingPongs =
otherAgent
.getIncomingPackets()
.stream()
otherAgent.getIncomingPackets().stream()
.filter(p -> p.packet.getType().equals(PacketType.PONG))
.collect(Collectors.toList());
assertThat(otherAgentIncomingPongs.size()).isEqualTo(1);
@ -82,9 +80,7 @@ public class PeerDiscoveryBondingTest {
// Now we received a PONG.
final List<IncomingPacket> incomingPongs =
otherNode
.getIncomingPackets()
.stream()
otherNode.getIncomingPackets().stream()
.filter(p -> p.packet.getType().equals(PacketType.PONG))
.collect(Collectors.toList());
assertThat(incomingPongs.size()).isEqualTo(1);

@ -42,9 +42,7 @@ public class PeerDiscoveryBootstrappingTest {
final PeerDiscoveryAgent agent = helper.startDiscoveryAgent(testAgent.getAdvertisedPeer());
final List<IncomingPacket> incomingPackets =
testAgent
.getIncomingPackets()
.stream()
testAgent.getIncomingPackets().stream()
.filter(p -> p.packet.getType().equals(PacketType.PING))
.collect(toList());
assertThat(incomingPackets.size()).isEqualTo(1);
@ -78,8 +76,7 @@ public class PeerDiscoveryBootstrappingTest {
final List<BytesValue> senderIds =
packets.stream().map(Packet::getNodeId).distinct().collect(toList());
final List<BytesValue> agentIds =
agents
.stream()
agents.stream()
.map(PeerDiscoveryAgent::getAdvertisedPeer)
.map(Peer::getId)
.distinct()

@ -85,16 +85,14 @@ public class PeerDiscoveryObserversTest {
final List<MockPeerDiscoveryAgent> others1 =
helper.startDiscoveryAgents(3, Collections.emptyList());
final List<DiscoveryPeer> peers1 =
others1
.stream()
others1.stream()
.map(MockPeerDiscoveryAgent::getAdvertisedPeer)
.collect(Collectors.toList());
// Create two discovery agents pointing to the above as bootstrap peers.
final List<MockPeerDiscoveryAgent> others2 = helper.startDiscoveryAgents(2, peers1);
final List<DiscoveryPeer> peers2 =
others2
.stream()
others2.stream()
.map(MockPeerDiscoveryAgent::getAdvertisedPeer)
.collect(Collectors.toList());
@ -112,8 +110,7 @@ public class PeerDiscoveryObserversTest {
final HashSet<BytesValue> seenPeers = new HashSet<>();
List<DiscoveryPeer> discoveredPeers =
events
.stream()
events.stream()
.map(PeerDiscoveryEvent::getPeer)
// We emit some duplicate events when the tcp port differs (in terms of presence) for a
// peer,

@ -221,9 +221,7 @@ public class PeerDiscoveryControllerTest {
controller.start();
assertThat(
controller
.getPeers()
.stream()
controller.getPeers().stream()
.filter(p -> p.getStatus() == PeerDiscoveryStatus.BONDING))
.hasSize(3);
@ -242,9 +240,7 @@ public class PeerDiscoveryControllerTest {
.send(eq(peers.get(0)), matchPacketOfType(PacketType.FIND_NEIGHBORS));
assertThat(
controller
.getPeers()
.stream()
controller.getPeers().stream()
.filter(p -> p.getStatus() == PeerDiscoveryStatus.BONDING))
.hasSize(2);
assertThat(
@ -274,9 +270,7 @@ public class PeerDiscoveryControllerTest {
controller.start();
assertThat(
controller
.getPeers()
.stream()
controller.getPeers().stream()
.filter(p -> p.getStatus() == PeerDiscoveryStatus.BONDING))
.hasSize(3);
@ -291,9 +285,7 @@ public class PeerDiscoveryControllerTest {
.send(eq(peers.get(1)), matchPacketOfType(PacketType.FIND_NEIGHBORS));
assertThat(
controller
.getPeers()
.stream()
controller.getPeers().stream()
.filter(p -> p.getStatus() == PeerDiscoveryStatus.BONDING))
.hasSize(3);
}
@ -338,9 +330,7 @@ public class PeerDiscoveryControllerTest {
final ArgumentCaptor<Packet> captor = ArgumentCaptor.forClass(Packet.class);
verify(outboundMessageHandler, atLeast(1)).send(eq(peers.get(0)), captor.capture());
List<Packet> neighborsPackets =
captor
.getAllValues()
.stream()
captor.getAllValues().stream()
.filter(p -> p.getType().equals(PacketType.FIND_NEIGHBORS))
.collect(Collectors.toList());
assertThat(neighborsPackets.size()).isEqualTo(1);

@ -86,9 +86,7 @@ public class PeerDiscoveryTableRefreshTest {
}
verify(outboundMessageHandler, atLeast(5)).send(eq(peers.get(1)), captor.capture());
List<Packet> capturedFindNeighborsPackets =
captor
.getAllValues()
.stream()
captor.getAllValues().stream()
.filter(p -> p.getType().equals(PacketType.FIND_NEIGHBORS))
.collect(Collectors.toList());
assertThat(capturedFindNeighborsPackets.size()).isEqualTo(5);

@ -157,9 +157,7 @@ class MetricsHttpService implements MetricsService {
}
private boolean hostIsInWhitelist(final String hostHeader) {
return config
.getHostsWhitelist()
.stream()
return config.getHostsWhitelist().stream()
.anyMatch(whitelistEntry -> whitelistEntry.toLowerCase().equals(hostHeader.toLowerCase()));
}

@ -120,18 +120,14 @@ public class PrometheusMetricsSystem implements MetricsSystem {
@Override
public Stream<Observation> getMetrics(final MetricCategory category) {
return collectors
.getOrDefault(category, Collections.emptySet())
.stream()
return collectors.getOrDefault(category, Collections.emptySet()).stream()
.flatMap(collector -> collector.collect().stream())
.flatMap(familySamples -> convertSamplesToObservations(category, familySamples));
}
private Stream<Observation> convertSamplesToObservations(
final MetricCategory category, final MetricFamilySamples familySamples) {
return familySamples
.samples
.stream()
return familySamples.samples.stream()
.map(sample -> createObservationFromSample(category, sample, familySamples));
}

@ -70,9 +70,7 @@ public class PermissioningConfigurationBuilder {
if (permissionedAccountEnabled) {
if (accountWhitelistTomlArray != null) {
List<String> accountsWhitelistToml =
accountWhitelistTomlArray
.toList()
.stream()
accountWhitelistTomlArray.toList().stream()
.map(Object::toString)
.collect(Collectors.toList());
permissioningConfiguration.setAccountWhitelist(accountsWhitelistToml);
@ -84,9 +82,7 @@ public class PermissioningConfigurationBuilder {
if (permissionedNodeEnabled) {
if (nodeWhitelistTomlArray != null) {
List<URI> nodesWhitelistToml =
nodeWhitelistTomlArray
.toList()
.stream()
nodeWhitelistTomlArray.toList().stream()
.map(Object::toString)
.map(EnodeToURIPropertyConverter::convertToURI)
.collect(Collectors.toList());

@ -198,8 +198,7 @@ public class RunnerBuilder {
final List<SubProtocol> subProtocols = subProtocolConfiguration.getSubProtocols();
final List<ProtocolManager> protocolManagers = subProtocolConfiguration.getProtocolManagers();
final Set<Capability> supportedCapabilities =
protocolManagers
.stream()
protocolManagers.stream()
.flatMap(protocolManager -> protocolManager.getSupportedCapabilities().stream())
.collect(Collectors.toSet());

@ -41,11 +41,10 @@ import picocli.CommandLine.Spec;
/** Blocks related sub-command */
@Command(
name = COMMAND_NAME,
description = "This command provides blocks related actions.",
mixinStandardHelpOptions = true,
subcommands = {ImportSubCommand.class}
)
name = COMMAND_NAME,
description = "This command provides blocks related actions.",
mixinStandardHelpOptions = true,
subcommands = {ImportSubCommand.class})
class BlocksSubCommand implements Runnable {
private static final Logger LOG = LogManager.getLogger();
@ -78,22 +77,20 @@ class BlocksSubCommand implements Runnable {
* <p>Imports blocks from a file into the database
*/
@Command(
name = "import",
description = "This command imports blocks from a file into the database.",
mixinStandardHelpOptions = true
)
name = "import",
description = "This command imports blocks from a file into the database.",
mixinStandardHelpOptions = true)
static class ImportSubCommand implements Runnable {
@SuppressWarnings("unused")
@ParentCommand
private BlocksSubCommand parentCommand; // Picocli injects reference to parent command
@Option(
names = "--from",
required = true,
paramLabel = MANDATORY_FILE_FORMAT_HELP,
description = "File containing blocks to import",
arity = "1..1"
)
names = "--from",
required = true,
paramLabel = MANDATORY_FILE_FORMAT_HELP,
description = "File containing blocks to import",
arity = "1..1")
private final File blocksImportFile = null;
@Override

@ -47,10 +47,7 @@ class CommandLineUtils {
final List<String> dependentOptionsNames) {
if (isMainOptionCondition) {
String affectedOptions =
commandLine
.getCommandSpec()
.options()
.stream()
commandLine.getCommandSpec().options().stream()
.filter(
option ->
Arrays.stream(option.names()).anyMatch(dependentOptionsNames::contains)

@ -86,18 +86,17 @@ import picocli.CommandLine.ParameterException;
@SuppressWarnings("FieldCanBeLocal") // because Picocli injected fields report false positives
@Command(
description = "This command runs the Pantheon Ethereum client full node.",
abbreviateSynopsis = true,
name = "pantheon",
mixinStandardHelpOptions = true,
versionProvider = VersionProvider.class,
header = "Usage:",
synopsisHeading = "%n",
descriptionHeading = "%nDescription:%n%n",
optionListHeading = "%nOptions:%n",
footerHeading = "%n",
footer = "Pantheon is licensed under the Apache License 2.0"
)
description = "This command runs the Pantheon Ethereum client full node.",
abbreviateSynopsis = true,
name = "pantheon",
mixinStandardHelpOptions = true,
versionProvider = VersionProvider.class,
header = "Usage:",
synopsisHeading = "%n",
descriptionHeading = "%nDescription:%n%n",
optionListHeading = "%nOptions:%n",
footerHeading = "%n",
footer = "Pantheon is licensed under the Apache License 2.0")
public class PantheonCommand implements DefaultCommandValues, Runnable {
private final Logger logger;
@ -146,10 +145,9 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
// Completely disables p2p within Pantheon.
@Option(
names = {"--p2p-enabled"},
description = "Enable/disable all p2p functionality (default: ${DEFAULT-VALUE})",
arity = "1"
)
names = {"--p2p-enabled"},
description = "Enable/disable all p2p functionality (default: ${DEFAULT-VALUE})",
arity = "1")
private final Boolean p2pEnabled = true;
// Boolean option to indicate if peers should NOT be discovered, default to false indicates that
@ -162,170 +160,153 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
// Also many other software use the same negative option scheme for false defaults
// meaning that it's probably the right way to handle disabling options.
@Option(
names = {"--discovery-enabled"},
description = "Enable p2p peer discovery (default: ${DEFAULT-VALUE})",
arity = "1"
)
names = {"--discovery-enabled"},
description = "Enable p2p peer discovery (default: ${DEFAULT-VALUE})",
arity = "1")
private final Boolean peerDiscoveryEnabled = true;
// A list of bootstrap nodes can be passed
// and a hardcoded list will be used otherwise by the Runner.
// NOTE: we have no control over default value here.
@Option(
names = {"--bootnodes"},
paramLabel = "<enode://id@host:port>",
description =
"Comma separated enode URLs for P2P discovery bootstrap. "
+ "Default is a predefined list.",
split = ",",
arity = "0..*",
converter = EnodeToURIPropertyConverter.class
)
names = {"--bootnodes"},
paramLabel = "<enode://id@host:port>",
description =
"Comma separated enode URLs for P2P discovery bootstrap. "
+ "Default is a predefined list.",
split = ",",
arity = "0..*",
converter = EnodeToURIPropertyConverter.class)
private final Collection<URI> bootNodes = null;
@Option(
names = {"--max-peers"},
paramLabel = MANDATORY_INTEGER_FORMAT_HELP,
description = "Maximum p2p peer connections that can be established (default: ${DEFAULT-VALUE})"
)
names = {"--max-peers"},
paramLabel = MANDATORY_INTEGER_FORMAT_HELP,
description =
"Maximum p2p peer connections that can be established (default: ${DEFAULT-VALUE})")
private final Integer maxPeers = DEFAULT_MAX_PEERS;
@Option(
names = {"--banned-node-ids", "--banned-node-id"},
paramLabel = MANDATORY_NODE_ID_FORMAT_HELP,
description = "A list of node IDs to ban from the p2p network.",
split = ",",
arity = "1..*"
)
names = {"--banned-node-ids", "--banned-node-id"},
paramLabel = MANDATORY_NODE_ID_FORMAT_HELP,
description = "A list of node IDs to ban from the p2p network.",
split = ",",
arity = "1..*")
private final Collection<String> bannedNodeIds = new ArrayList<>();
@Option(
hidden = true,
names = {"--sync-mode"},
paramLabel = MANDATORY_MODE_FORMAT_HELP,
description =
"Synchronization mode (Value can be one of ${COMPLETION-CANDIDATES}, default: ${DEFAULT-VALUE})"
)
hidden = true,
names = {"--sync-mode"},
paramLabel = MANDATORY_MODE_FORMAT_HELP,
description =
"Synchronization mode (Value can be one of ${COMPLETION-CANDIDATES}, default: ${DEFAULT-VALUE})")
private final SyncMode syncMode = DEFAULT_SYNC_MODE;
@Option(
names = {"--network"},
paramLabel = MANDATORY_NETWORK_FORMAT_HELP,
description =
"Synchronize against the indicated network, possible values are ${COMPLETION-CANDIDATES}."
+ " (default: MAINNET)"
)
names = {"--network"},
paramLabel = MANDATORY_NETWORK_FORMAT_HELP,
description =
"Synchronize against the indicated network, possible values are ${COMPLETION-CANDIDATES}."
+ " (default: MAINNET)")
private final NetworkName network = null;
@Option(
names = {"--p2p-host"},
paramLabel = MANDATORY_HOST_FORMAT_HELP,
description = "Host for p2p peers discovery to listen on (default: ${DEFAULT-VALUE})",
arity = "1"
)
names = {"--p2p-host"},
paramLabel = MANDATORY_HOST_FORMAT_HELP,
description = "Host for p2p peers discovery to listen on (default: ${DEFAULT-VALUE})",
arity = "1")
private String p2pHost = autoDiscoverDefaultIP().getHostAddress();
@Option(
names = {"--p2p-port"},
paramLabel = MANDATORY_PORT_FORMAT_HELP,
description = "Port for p2p peers discovery to listen on (default: ${DEFAULT-VALUE})",
arity = "1"
)
names = {"--p2p-port"},
paramLabel = MANDATORY_PORT_FORMAT_HELP,
description = "Port for p2p peers discovery to listen on (default: ${DEFAULT-VALUE})",
arity = "1")
private final Integer p2pPort = DEFAULT_PORT;
@Option(
names = {"--network-id"},
paramLabel = MANDATORY_INTEGER_FORMAT_HELP,
description =
"P2P network identifier. (default: the selected network chain ID or custom genesis chain ID)",
arity = "1"
)
names = {"--network-id"},
paramLabel = MANDATORY_INTEGER_FORMAT_HELP,
description =
"P2P network identifier. (default: the selected network chain ID or custom genesis chain ID)",
arity = "1")
private final Integer networkId = null;
@Option(
names = {"--rpc-http-enabled"},
description = "Set if the JSON-RPC service should be started (default: ${DEFAULT-VALUE})"
)
names = {"--rpc-http-enabled"},
description = "Set if the JSON-RPC service should be started (default: ${DEFAULT-VALUE})")
private final Boolean isRpcHttpEnabled = false;
@Option(
names = {"--rpc-http-host"},
paramLabel = MANDATORY_HOST_FORMAT_HELP,
description = "Host for HTTP JSON-RPC to listen on (default: ${DEFAULT-VALUE})",
arity = "1"
)
names = {"--rpc-http-host"},
paramLabel = MANDATORY_HOST_FORMAT_HELP,
description = "Host for HTTP JSON-RPC to listen on (default: ${DEFAULT-VALUE})",
arity = "1")
private String rpcHttpHost = autoDiscoverDefaultIP().getHostAddress();
@Option(
names = {"--rpc-http-port"},
paramLabel = MANDATORY_PORT_FORMAT_HELP,
description = "Port for HTTP JSON-RPC to listen on (default: ${DEFAULT-VALUE})",
arity = "1"
)
names = {"--rpc-http-port"},
paramLabel = MANDATORY_PORT_FORMAT_HELP,
description = "Port for HTTP JSON-RPC to listen on (default: ${DEFAULT-VALUE})",
arity = "1")
private final Integer rpcHttpPort = DEFAULT_JSON_RPC_PORT;
// A list of origins URLs that are accepted by the JsonRpcHttpServer (CORS)
@Option(
names = {"--rpc-http-cors-origins"},
description = "Comma separated origin domain URLs for CORS validation (default: none)"
)
names = {"--rpc-http-cors-origins"},
description = "Comma separated origin domain URLs for CORS validation (default: none)")
private final CorsAllowedOriginsProperty rpcHttpCorsAllowedOrigins =
new CorsAllowedOriginsProperty();
@Option(
names = {"--rpc-http-api", "--rpc-http-apis"},
paramLabel = "<api name>",
split = ",",
arity = "1..*",
converter = RpcApisConverter.class,
description = "Comma separated APIs to enable on JSON-RPC channel. default: ${DEFAULT-VALUE}"
)
names = {"--rpc-http-api", "--rpc-http-apis"},
paramLabel = "<api name>",
split = ",",
arity = "1..*",
converter = RpcApisConverter.class,
description = "Comma separated APIs to enable on JSON-RPC channel. default: ${DEFAULT-VALUE}")
private final Collection<RpcApi> rpcHttpApis = DEFAULT_JSON_RPC_APIS;
@Option(
names = {"--rpc-ws-enabled"},
description =
"Set if the WS-RPC (WebSocket) service should be started (default: ${DEFAULT-VALUE})"
)
names = {"--rpc-ws-enabled"},
description =
"Set if the WS-RPC (WebSocket) service should be started (default: ${DEFAULT-VALUE})")
private final Boolean isRpcWsEnabled = false;
@Option(
names = {"--rpc-ws-host"},
paramLabel = MANDATORY_HOST_FORMAT_HELP,
description = "Host for WebSocket JSON-RPC to listen on (default: ${DEFAULT-VALUE})",
arity = "1"
)
names = {"--rpc-ws-host"},
paramLabel = MANDATORY_HOST_FORMAT_HELP,
description = "Host for WebSocket JSON-RPC to listen on (default: ${DEFAULT-VALUE})",
arity = "1")
private String rpcWsHost = autoDiscoverDefaultIP().getHostAddress();
@Option(
names = {"--rpc-ws-port"},
paramLabel = MANDATORY_PORT_FORMAT_HELP,
description = "Port for WebSocket JSON-RPC to listen on (default: ${DEFAULT-VALUE})",
arity = "1"
)
names = {"--rpc-ws-port"},
paramLabel = MANDATORY_PORT_FORMAT_HELP,
description = "Port for WebSocket JSON-RPC to listen on (default: ${DEFAULT-VALUE})",
arity = "1")
private final Integer rpcWsPort = DEFAULT_WEBSOCKET_PORT;
@Option(
names = {"--rpc-ws-api", "--rpc-ws-apis"},
paramLabel = "<api name>",
split = ",",
arity = "1..*",
converter = RpcApisConverter.class,
description = "Comma separated APIs to enable on WebSocket channel. default: ${DEFAULT-VALUE}"
)
names = {"--rpc-ws-api", "--rpc-ws-apis"},
paramLabel = "<api name>",
split = ",",
arity = "1..*",
converter = RpcApisConverter.class,
description =
"Comma separated APIs to enable on WebSocket channel. default: ${DEFAULT-VALUE}")
private final Collection<RpcApi> rpcWsApis = DEFAULT_JSON_RPC_APIS;
private Long rpcWsRefreshDelay;
@Option(
names = {"--rpc-ws-refresh-delay"},
paramLabel = "<refresh delay>",
arity = "1",
description =
"Refresh delay of websocket subscription sync in milliseconds. "
+ "default: ${DEFAULT-VALUE}",
defaultValue = "" + DEFAULT_WEBSOCKET_REFRESH_DELAY
)
names = {"--rpc-ws-refresh-delay"},
paramLabel = "<refresh delay>",
arity = "1",
description =
"Refresh delay of websocket subscription sync in milliseconds. "
+ "default: ${DEFAULT-VALUE}",
defaultValue = "" + DEFAULT_WEBSOCKET_REFRESH_DELAY)
private Long configureRefreshDelay(final Long refreshDelay) {
if (refreshDelay < DEFAULT_MIN_REFRESH_DELAY || refreshDelay > DEFAULT_MAX_REFRESH_DELAY) {
throw new ParameterException(
@ -340,158 +321,138 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
}
@Option(
names = {"--metrics-enabled"},
description = "Set if the metrics exporter should be started (default: ${DEFAULT-VALUE})"
)
names = {"--metrics-enabled"},
description = "Set if the metrics exporter should be started (default: ${DEFAULT-VALUE})")
private final Boolean isMetricsEnabled = false;
@Option(
names = {"--metrics-host"},
paramLabel = MANDATORY_HOST_FORMAT_HELP,
description = "Host for the metrics exporter to listen on (default: ${DEFAULT-VALUE})",
arity = "1"
)
names = {"--metrics-host"},
paramLabel = MANDATORY_HOST_FORMAT_HELP,
description = "Host for the metrics exporter to listen on (default: ${DEFAULT-VALUE})",
arity = "1")
private String metricsHost = autoDiscoverDefaultIP().getHostAddress();
@Option(
names = {"--metrics-port"},
paramLabel = MANDATORY_PORT_FORMAT_HELP,
description = "Port for the metrics exporter to listen on (default: ${DEFAULT-VALUE})",
arity = "1"
)
names = {"--metrics-port"},
paramLabel = MANDATORY_PORT_FORMAT_HELP,
description = "Port for the metrics exporter to listen on (default: ${DEFAULT-VALUE})",
arity = "1")
private final Integer metricsPort = DEFAULT_METRICS_PORT;
@Option(
names = {"--metrics-push-enabled"},
description =
"Set if the metrics push gateway integration should be started (default: ${DEFAULT-VALUE})"
)
names = {"--metrics-push-enabled"},
description =
"Set if the metrics push gateway integration should be started (default: ${DEFAULT-VALUE})")
private final Boolean isMetricsPushEnabled = false;
@Option(
names = {"--metrics-push-host"},
paramLabel = MANDATORY_HOST_FORMAT_HELP,
description = "Host of the Prometheus Push Gateway for push mode (default: ${DEFAULT-VALUE})",
arity = "1"
)
names = {"--metrics-push-host"},
paramLabel = MANDATORY_HOST_FORMAT_HELP,
description = "Host of the Prometheus Push Gateway for push mode (default: ${DEFAULT-VALUE})",
arity = "1")
private String metricsPushHost = autoDiscoverDefaultIP().getHostAddress();
@Option(
names = {"--metrics-push-port"},
paramLabel = MANDATORY_PORT_FORMAT_HELP,
description = "Port of the Prometheus Push Gateway for push mode (default: ${DEFAULT-VALUE})",
arity = "1"
)
names = {"--metrics-push-port"},
paramLabel = MANDATORY_PORT_FORMAT_HELP,
description = "Port of the Prometheus Push Gateway for push mode (default: ${DEFAULT-VALUE})",
arity = "1")
private final Integer metricsPushPort = DEFAULT_METRICS_PUSH_PORT;
@Option(
names = {"--metrics-push-interval"},
paramLabel = MANDATORY_INTEGER_FORMAT_HELP,
description =
"Interval in seconds to push metrics when in push mode (default: ${DEFAULT-VALUE})",
arity = "1"
)
names = {"--metrics-push-interval"},
paramLabel = MANDATORY_INTEGER_FORMAT_HELP,
description =
"Interval in seconds to push metrics when in push mode (default: ${DEFAULT-VALUE})",
arity = "1")
private final Integer metricsPushInterval = 15;
@Option(
names = {"--metrics-push-prometheus-job"},
description = "Job name to use when in push mode (default: ${DEFAULT-VALUE})",
arity = "1"
)
names = {"--metrics-push-prometheus-job"},
description = "Job name to use when in push mode (default: ${DEFAULT-VALUE})",
arity = "1")
private String metricsPrometheusJob = "pantheon-client";
@Option(
names = {"--host-whitelist"},
paramLabel = "<hostname>[,<hostname>...]... or * or all",
description =
"Comma separated list of hostnames to whitelist for RPC access or * or all to accept any host. default: ${DEFAULT-VALUE}",
defaultValue = "localhost"
)
names = {"--host-whitelist"},
paramLabel = "<hostname>[,<hostname>...]... or * or all",
description =
"Comma separated list of hostnames to whitelist for RPC access or * or all to accept any host. default: ${DEFAULT-VALUE}",
defaultValue = "localhost")
private final JsonRPCWhitelistHostsProperty hostsWhitelist = new JsonRPCWhitelistHostsProperty();
@Option(
names = {"--logging", "-l"},
paramLabel = "<LOG VERBOSITY LEVEL>",
description =
"Logging verbosity levels: OFF, FATAL, WARN, INFO, DEBUG, TRACE, ALL (default: INFO)."
)
names = {"--logging", "-l"},
paramLabel = "<LOG VERBOSITY LEVEL>",
description =
"Logging verbosity levels: OFF, FATAL, WARN, INFO, DEBUG, TRACE, ALL (default: INFO).")
private final Level logLevel = null;
@Option(
names = {"--miner-enabled"},
description = "set if node should perform mining (default: ${DEFAULT-VALUE})"
)
names = {"--miner-enabled"},
description = "set if node should perform mining (default: ${DEFAULT-VALUE})")
private final Boolean isMiningEnabled = false;
@Option(
names = {"--miner-coinbase"},
description =
"account to which mining rewards are paid. You must specify a valid coinbase if "
+ "mining is enabled using --miner-enabled option.",
arity = "1"
)
names = {"--miner-coinbase"},
description =
"account to which mining rewards are paid. You must specify a valid coinbase if "
+ "mining is enabled using --miner-enabled option.",
arity = "1")
private final Address coinbase = null;
@Option(
names = {"--min-gas-price"},
description =
"the minimum price (in Wei) offered by a transaction for it to be included in a mined "
+ "block (default: ${DEFAULT-VALUE}).",
arity = "1"
)
names = {"--min-gas-price"},
description =
"the minimum price (in Wei) offered by a transaction for it to be included in a mined "
+ "block (default: ${DEFAULT-VALUE}).",
arity = "1")
private final Wei minTransactionGasPrice = DEFAULT_MIN_TRANSACTION_GAS_PRICE;
@Option(
names = {"--miner-extra-data"},
description =
"a hex string representing the (32) bytes to be included in the extra data "
+ "field of a mined block. (default: ${DEFAULT-VALUE}).",
arity = "1"
)
names = {"--miner-extra-data"},
description =
"a hex string representing the (32) bytes to be included in the extra data "
+ "field of a mined block. (default: ${DEFAULT-VALUE}).",
arity = "1")
private final BytesValue extraData = DEFAULT_EXTRA_DATA;
@Option(
names = {"--permissions-nodes-enabled"},
description = "Set if node level permissions should be enabled (default: ${DEFAULT-VALUE})"
)
names = {"--permissions-nodes-enabled"},
description = "Set if node level permissions should be enabled (default: ${DEFAULT-VALUE})")
private final Boolean permissionsNodesEnabled = false;
@Option(
names = {"--permissions-accounts-enabled"},
description = "Set if account level permissions should be enabled (default: ${DEFAULT-VALUE})"
)
names = {"--permissions-accounts-enabled"},
description =
"Set if account level permissions should be enabled (default: ${DEFAULT-VALUE})")
private final Boolean permissionsAccountsEnabled = false;
@Option(
names = {"--permissions-config-path"},
description =
"Path to permissions config TOML file (default: a file named \"permissions_config.toml\" in the Pantheon data folder)"
)
names = {"--permissions-config-path"},
description =
"Path to permissions config TOML file (default: a file named \"permissions_config.toml\" in the Pantheon data folder)")
private String permissionsConfigPath = null;
@Option(
names = {"--privacy-enabled"},
description = "Set if private transaction should be enabled (default: ${DEFAULT-VALUE})"
)
names = {"--privacy-enabled"},
description = "Set if private transaction should be enabled (default: ${DEFAULT-VALUE})")
private final Boolean privacyEnabled = false;
@Option(
names = {"--privacy-url"},
description = "The URL on which enclave is running "
)
names = {"--privacy-url"},
description = "The URL on which enclave is running ")
private final URI privacyUrl = PrivacyParameters.DEFAULT_ENCLAVE_URL;
@Option(
names = {"--privacy-public-key-file"},
description = "the path to the enclave's public key "
)
names = {"--privacy-public-key-file"},
description = "the path to the enclave's public key ")
private final File privacyPublicKeyFile = null;
@Option(
names = {"--privacy-precompiled-address"},
description =
"The address to which the privacy pre-compiled contract will be mapped to (default: ${DEFAULT-VALUE})"
)
names = {"--privacy-precompiled-address"},
description =
"The address to which the privacy pre-compiled contract will be mapped to (default: ${DEFAULT-VALUE})")
private final Integer privacyPrecompiledAddress = Address.PRIVACY;
public PantheonCommand(

@ -24,10 +24,9 @@ import picocli.CommandLine.ParentCommand;
import picocli.CommandLine.Spec;
@Command(
name = COMMAND_NAME,
description = "This command generates the hash of a given password.",
mixinStandardHelpOptions = true
)
name = COMMAND_NAME,
description = "This command generates the hash of a given password.",
mixinStandardHelpOptions = true)
class PasswordSubCommand implements Runnable {
static final String COMMAND_NAME = "password-hash";

@ -38,11 +38,10 @@ import picocli.CommandLine.Spec;
/** Node's public key related sub-command */
@Command(
name = COMMAND_NAME,
description = "This command provides node public key related actions.",
mixinStandardHelpOptions = true,
subcommands = {ExportSubCommand.class}
)
name = COMMAND_NAME,
description = "This command provides node public key related actions.",
mixinStandardHelpOptions = true,
subcommands = {ExportSubCommand.class})
class PublicKeySubCommand implements Runnable {
private static final Logger LOG = LogManager.getLogger();
@ -75,19 +74,17 @@ class PublicKeySubCommand implements Runnable {
* value to be polluted by other information like logs that are in KeyPairUtil that is inevitable.
*/
@Command(
name = "export",
description = "This command exports the node public key to a file.",
mixinStandardHelpOptions = true
)
name = "export",
description = "This command exports the node public key to a file.",
mixinStandardHelpOptions = true)
static class ExportSubCommand implements Runnable {
@Option(
names = "--to",
required = true,
paramLabel = MANDATORY_FILE_FORMAT_HELP,
description = "File to write public key to",
arity = "1..1"
)
names = "--to",
required = true,
paramLabel = MANDATORY_FILE_FORMAT_HELP,
description = "File to write public key to",
arity = "1..1")
private final File publicKeyExportFile = null;
@SuppressWarnings("unused")

@ -22,17 +22,15 @@ import picocli.CommandLine;
class StandaloneCommand implements DefaultCommandValues {
@CommandLine.Option(
names = {CONFIG_FILE_OPTION_NAME},
paramLabel = MANDATORY_FILE_FORMAT_HELP,
description = "TOML config file (default: none)"
)
names = {CONFIG_FILE_OPTION_NAME},
paramLabel = MANDATORY_FILE_FORMAT_HELP,
description = "TOML config file (default: none)")
private final File configFile = null;
@CommandLine.Option(
names = {"--data-path"},
paramLabel = MANDATORY_PATH_FORMAT_HELP,
description = "The path to Pantheon data directory (default: ${DEFAULT-VALUE})"
)
names = {"--data-path"},
paramLabel = MANDATORY_PATH_FORMAT_HELP,
description = "The path to Pantheon data directory (default: ${DEFAULT-VALUE})")
final Path dataPath = getDefaultPantheonDataPath(this);
// Genesis file path with null default option if the option
@ -41,18 +39,16 @@ class StandaloneCommand implements DefaultCommandValues {
// default network option
// Then we have no control over genesis default value here.
@CommandLine.Option(
names = {"--genesis-file"},
paramLabel = MANDATORY_FILE_FORMAT_HELP,
description =
"The path to genesis file. Setting this option makes --network option ignored and requires --network-id to be set."
)
names = {"--genesis-file"},
paramLabel = MANDATORY_FILE_FORMAT_HELP,
description =
"The path to genesis file. Setting this option makes --network option ignored and requires --network-id to be set.")
final File genesisFile = null;
@CommandLine.Option(
names = {"--node-private-key-file"},
paramLabel = MANDATORY_PATH_FORMAT_HELP,
description =
"the path to the node's private key file (default: a file named \"key\" in the Pantheon data folder)"
)
names = {"--node-private-key-file"},
paramLabel = MANDATORY_PATH_FORMAT_HELP,
description =
"the path to the node's private key file (default: a file named \"key\" in the Pantheon data folder)")
final File nodePrivateKeyFile = null;
}

@ -118,9 +118,7 @@ public class TomlConfigFileDefaultProvider implements IDefaultValueProvider {
if (result.hasErrors()) {
final String errors =
result
.errors()
.stream()
result.errors().stream()
.map(TomlParseError::toString)
.collect(Collectors.joining("%n"));
;

@ -35,8 +35,7 @@ public class PermissioningConfigurationValidator {
ethNetworkConfig.getBootNodes());
if (permissioningConfiguration.isNodeWhitelistEnabled() && bootnodes != null) {
bootnodesNotInWhitelist =
bootnodes
.stream()
bootnodes.stream()
.filter(
node ->
!permissioningConfiguration

@ -48,9 +48,8 @@ public class CommandLineUtilsTest {
// Completely disables p2p within Pantheon.
@Option(
names = {"--option-enabled"},
arity = "1"
)
names = {"--option-enabled"},
arity = "1")
final Boolean optionEnabled = true;
@Option(names = {"--option2"})

@ -35,9 +35,7 @@ public class StringUtilsTest {
for (Entry<List<String>, String> entry : testCases.entrySet()) {
String joinedResult =
entry
.getKey()
.stream()
entry.getKey().stream()
.collect(
Collectors.collectingAndThen(
Collectors.toList(), StringUtils.joiningWithLastDelimiter(", ", " and ")));

@ -52,9 +52,7 @@ public class InMemoryKeyValueStorage implements KeyValueStorage {
lock.lock();
try {
// Ensure we have collected all entries before releasing the lock and returning
return hashValueStore
.entrySet()
.stream()
return hashValueStore.entrySet().stream()
.map(e -> Entry.create(e.getKey(), e.getValue()))
.collect(Collectors.toSet())
.stream();

@ -86,17 +86,13 @@ public class OrionTestHarness {
}
public List<String> getPublicKeys() {
return config
.publicKeys()
.stream()
return config.publicKeys().stream()
.map(OrionTestHarness::readFile)
.collect(Collectors.toList());
}
public List<String> getPrivateKeys() {
return config
.privateKeys()
.stream()
return config.privateKeys().stream()
.map(OrionTestHarness::readFile)
.collect(Collectors.toList());
}

Loading…
Cancel
Save