diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Clique.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Clique.java index 39d04f1e31..be39656ffe 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Clique.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Clique.java @@ -118,9 +118,7 @@ public ProposalsConfig removeProposal(final PantheonNode node) { public Condition build() { final Map proposalsAsAddress = - this.proposals - .entrySet() - .stream() + this.proposals.entrySet().stream() .collect(Collectors.toMap(p -> p.getKey().getAddress(), Entry::getValue)); return new ExpectProposals(clique, proposalsAsAddress); } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Ibft.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Ibft.java index 37c9bbbaaa..450ffe5137 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Ibft.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Ibft.java @@ -81,9 +81,7 @@ public PendingVotesConfig removeProposal(final PantheonNode node) { public Condition build() { final Map 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); diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java index 477c6f75c2..b05181240e 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java @@ -320,8 +320,7 @@ String p2pListenAddress() { } List bootnodes() { - return bootnodes - .stream() + return bootnodes.stream() .filter(node -> !node.equals(this.enodeUrl())) .map(URI::create) .collect(Collectors.toList()); diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/cluster/Cluster.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/cluster/Cluster.java index cd1b42ae04..7e64ef3acb 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/cluster/Cluster.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/cluster/Cluster.java @@ -113,9 +113,7 @@ public void verify(final Condition expected) { } public void verifyOnActiveNodes(final Condition condition) { - nodes - .values() - .stream() + nodes.values().stream() .filter(node -> pantheonNodeRunner.isActive(node.getName())) .forEach(condition::verify); } diff --git a/build.gradle b/build.gradle index 89d9c45054..b92b2d6197 100644 --- a/build.gradle +++ b/build.gradle @@ -108,7 +108,7 @@ allprojects { exclude '**/.gradle/**' } removeUnusedImports() - googleJavaFormat() + googleJavaFormat('1.7') importOrder 'tech.pegasys', 'java', '' trimTrailingWhitespace() endWithNewline() diff --git a/config/src/main/java/tech/pegasys/pantheon/config/GenesisConfigFile.java b/config/src/main/java/tech/pegasys/pantheon/config/GenesisConfigFile.java index 3ea6e3aee6..985f12bafd 100644 --- a/config/src/main/java/tech/pegasys/pantheon/config/GenesisConfigFile.java +++ b/config/src/main/java/tech/pegasys/pantheon/config/GenesisConfigFile.java @@ -64,9 +64,7 @@ public GenesisConfigOptions getConfigOptions() { public Stream getAllocations() { final JsonObject allocations = configRoot.getJsonObject("alloc"); - return allocations - .fieldNames() - .stream() + return allocations.fieldNames().stream() .map(key -> new GenesisAllocation(key, allocations.getJsonObject(key))); } diff --git a/consensus/clique/src/test/java/tech/pegasys/pantheon/consensus/clique/CliqueExtraDataTest.java b/consensus/clique/src/test/java/tech/pegasys/pantheon/consensus/clique/CliqueExtraDataTest.java index 388aded68b..4024be5c0f 100644 --- a/consensus/clique/src/test/java/tech/pegasys/pantheon/consensus/clique/CliqueExtraDataTest.java +++ b/consensus/clique/src/test/java/tech/pegasys/pantheon/consensus/clique/CliqueExtraDataTest.java @@ -101,8 +101,7 @@ public void addressToExtraDataString() { } final List
addresses = - nodeKeys - .stream() + nodeKeys.stream() .map(KeyPair::getPublicKey) .map(Util::publicKeyToAddress) .collect(Collectors.toList()); diff --git a/consensus/common/src/main/java/tech/pegasys/pantheon/consensus/common/jsonrpc/AbstractVoteProposerMethod.java b/consensus/common/src/main/java/tech/pegasys/pantheon/consensus/common/jsonrpc/AbstractVoteProposerMethod.java index 96d0e5fa22..0b65c3fe22 100644 --- a/consensus/common/src/main/java/tech/pegasys/pantheon/consensus/common/jsonrpc/AbstractVoteProposerMethod.java +++ b/consensus/common/src/main/java/tech/pegasys/pantheon/consensus/common/jsonrpc/AbstractVoteProposerMethod.java @@ -31,10 +31,7 @@ public AbstractVoteProposerMethod(final VoteProposer voteProposer) { public JsonRpcResponse response(final JsonRpcRequest request) { final Map proposals = - voteProposer - .getProposals() - .entrySet() - .stream() + voteProposer.getProposals().entrySet().stream() .collect( Collectors.toMap( proposal -> proposal.getKey().toString(), diff --git a/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/IntegrationTestHelpers.java b/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/IntegrationTestHelpers.java index 0956ed01b4..336df86b08 100644 --- a/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/IntegrationTestHelpers.java +++ b/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/IntegrationTestHelpers.java @@ -50,9 +50,7 @@ public static PreparedRoundArtifacts createValidPreparedRoundArtifacts( 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())); } diff --git a/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/RoundSpecificPeers.java b/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/RoundSpecificPeers.java index a2e3b43ec9..f904e72956 100644 --- a/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/RoundSpecificPeers.java +++ b/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/RoundSpecificPeers.java @@ -80,8 +80,7 @@ public ValidatorPeer getNonProposing(final int index) { public List> 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 List> roundChange(final ConsensusRoundIden public List> createSignedRoundChangePayload( final ConsensusRoundIdentifier roundId) { - return peers - .stream() + return peers.stream() .map(p -> p.getMessageFactory().createRoundChange(roundId, empty()).getSignedPayload()) .collect(Collectors.toList()); } public List> createSignedRoundChangePayload( final ConsensusRoundIdentifier roundId, final PreparedRoundArtifacts preparedRoundArtifacts) { - return peers - .stream() + return peers.stream() .map( p -> p.getMessageFactory() @@ -130,8 +127,7 @@ public void commitForNonProposing(final ConsensusRoundIdentifier roundId, final public Collection> createSignedPreparePayloadOfNonProposing( final ConsensusRoundIdentifier preparedRound, final Hash hash) { - return nonProposingPeers - .stream() + return nonProposingPeers.stream() .map(role -> role.getMessageFactory().createPrepare(preparedRound, hash).getSignedPayload()) .collect(Collectors.toList()); } diff --git a/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/StubValidatorMulticaster.java b/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/StubValidatorMulticaster.java index d02e0be58f..c2b820f274 100644 --- a/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/StubValidatorMulticaster.java +++ b/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/StubValidatorMulticaster.java @@ -38,8 +38,7 @@ public void send(final MessageData message) { @Override public void send(final MessageData message, final Collection
blackList) { - validatorNodes - .stream() + validatorNodes.stream() .filter(peer -> !blackList.contains(peer.getNodeAddress())) .forEach(peer -> peer.handleReceivedMessage(message)); } diff --git a/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/TestContextBuilder.java b/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/TestContextBuilder.java index 090cdbbdcd..366e15de0b 100644 --- a/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/TestContextBuilder.java +++ b/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/TestContextBuilder.java @@ -173,9 +173,7 @@ public TestContext build() { // 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 remotePeers = - networkNodes - .getRemotePeers() - .stream() + networkNodes.getRemotePeers().stream() .collect( Collectors.toMap( NodeParams::getAddress, diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/IbftBlockHashing.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/IbftBlockHashing.java index 4e8d880c1b..5c92f950ef 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/IbftBlockHashing.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/IbftBlockHashing.java @@ -71,9 +71,7 @@ public static List
recoverCommitterAddresses( final Hash committerHash = IbftBlockHashing.calculateDataHashForCommittedSeal(header, ibftExtraData); - return ibftExtraData - .getSeals() - .stream() + return ibftExtraData.getSeals().stream() .map(p -> Util.signatureToAddress(p, committerHash)) .collect(Collectors.toList()); } diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockHash.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockHash.java index dccc43b211..031d5ea8b9 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockHash.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockHash.java @@ -61,9 +61,7 @@ private Object blockResult(final JsonRpcRequest request) { return blockHeader .map( header -> - blockInterface - .validatorsInBlock(header) - .stream() + blockInterface.validatorsInBlock(header).stream() .map(validator -> validator.toString()) .collect(Collectors.toList())) .orElse(null); diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockNumber.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockNumber.java index f07ce98a21..c922593f09 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockNumber.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockNumber.java @@ -54,9 +54,7 @@ protected Object resultByBlockNumber(final JsonRpcRequest request, final long bl return blockHeader .map( header -> - blockInterface - .validatorsInBlock(header) - .stream() + blockInterface.validatorsInBlock(header).stream() .map(validator -> validator.toString()) .collect(Collectors.toList())) .orElse(null); diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/network/ValidatorPeers.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/network/ValidatorPeers.java index d15929fe10..ae90e3cd49 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/network/ValidatorPeers.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/network/ValidatorPeers.java @@ -65,9 +65,7 @@ public void send(final MessageData message) { @Override public void send(final MessageData message, final Collection
blackList) { final Collection
includedValidators = - validatorProvider - .getValidators() - .stream() + validatorProvider.getValidators().stream() .filter(a -> !blackList.contains(a)) .collect(Collectors.toSet()); sendMessageToSpecificAddresses(includedValidators, message); @@ -77,8 +75,7 @@ private void sendMessageToSpecificAddresses( final Collection
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( diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/RoundChangeCertificate.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/RoundChangeCertificate.java index 0adb333448..6f887b4493 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/RoundChangeCertificate.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/RoundChangeCertificate.java @@ -66,8 +66,7 @@ public void appendRoundChangeMessage(final RoundChange msg) { public RoundChangeCertificate buildCertificate() { return new RoundChangeCertificate( - roundChangePayloads - .stream() + roundChangePayloads.stream() .map(RoundChange::getSignedPayload) .collect(Collectors.toList())); } diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundChangeArtifacts.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundChangeArtifacts.java index 53ad83ce1c..1a8a8960be 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundChangeArtifacts.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundChangeArtifacts.java @@ -47,8 +47,7 @@ public RoundChangeCertificate getRoundChangeCertificate() { public static RoundChangeArtifacts create(final Collection roundChanges) { final Collection> payloads = - roundChanges - .stream() + roundChanges.stream() .map(roundChange -> roundChange.getSignedPayload()) .collect(Collectors.toList()); diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundState.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundState.java index f787ffa6e0..469d0765b1 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundState.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundState.java @@ -121,8 +121,7 @@ public boolean isCommitted() { } public Collection getCommitSeals() { - return commitMessages - .stream() + return commitMessages.stream() .map(cp -> cp.getSignedPayload().getPayload().getCommitSeal()) .collect(Collectors.toList()); } diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/validation/NewRoundPayloadValidator.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/validation/NewRoundPayloadValidator.java index 50c975696a..5fe6b70c81 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/validation/NewRoundPayloadValidator.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/validation/NewRoundPayloadValidator.java @@ -108,9 +108,7 @@ private boolean validateRoundChangeMessagesAndEnsureTargetRoundMatchesRoot( 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 " diff --git a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/IbftBlockHashingTest.java b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/IbftBlockHashingTest.java index 90b7cd90ad..0f5b97cd5d 100644 --- a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/IbftBlockHashingTest.java +++ b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/IbftBlockHashingTest.java @@ -62,8 +62,7 @@ public void testRecoverCommitterAddresses() { HEADER_TO_BE_HASHED, IbftExtraData.decode(HEADER_TO_BE_HASHED.getExtraData())); List
expectedCommitterAddresses = - COMMITTERS_KEY_PAIRS - .stream() + COMMITTERS_KEY_PAIRS.stream() .map(keyPair -> Util.publicKeyToAddress(keyPair.getPublicKey())) .collect(Collectors.toList()); @@ -79,8 +78,7 @@ public void testCalculateDataHashForCommittedSeal() { BlockHeaderBuilder builder = setHeaderFieldsExceptForExtraData(); List commitSeals = - COMMITTERS_KEY_PAIRS - .stream() + COMMITTERS_KEY_PAIRS.stream() .map(keyPair -> SECP256K1.sign(dataHahsForCommittedSeal, keyPair)) .collect(Collectors.toList()); @@ -151,8 +149,7 @@ private static BlockHeader headerToBeHashed() { builder.buildBlockHeader().writeTo(rlpForHeaderFroCommittersSigning); List commitSeals = - COMMITTERS_KEY_PAIRS - .stream() + COMMITTERS_KEY_PAIRS.stream() .map( keyPair -> SECP256K1.sign(Hash.hash(rlpForHeaderFroCommittersSigning.encoded()), keyPair)) diff --git a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/headervalidationrules/IbftCommitSealsValidationRuleTest.java b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/headervalidationrules/IbftCommitSealsValidationRuleTest.java index cd42effbb6..b06b849a62 100644 --- a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/headervalidationrules/IbftCommitSealsValidationRuleTest.java +++ b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/headervalidationrules/IbftCommitSealsValidationRuleTest.java @@ -46,8 +46,7 @@ public void correctlyConstructedHeaderPassesValidation() { IntStream.range(0, 2).mapToObj(i -> KeyPair.generate()).collect(Collectors.toList()); final List
committerAddresses = - committerKeyPairs - .stream() + committerKeyPairs.stream() .map(keyPair -> Util.publicKeyToAddress(keyPair.getPublicKey())) .sorted() .collect(Collectors.toList()); diff --git a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundChangeManagerTest.java b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundChangeManagerTest.java index 36c55388e8..369991a03f 100644 --- a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundChangeManagerTest.java +++ b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundChangeManagerTest.java @@ -143,8 +143,7 @@ private RoundChange makeRoundChangeMessageWithPreparedCert( final Proposal proposal = messageFactory.createProposal(proposalRound, block); final List preparePayloads = - prepareProviders - .stream() + prepareProviders.stream() .map( k -> { final MessageFactory prepareFactory = new MessageFactory(k); diff --git a/consensus/ibftlegacy/src/main/java/tech/pegasys/pantheon/consensus/ibftlegacy/IbftBlockHashing.java b/consensus/ibftlegacy/src/main/java/tech/pegasys/pantheon/consensus/ibftlegacy/IbftBlockHashing.java index 737f6343ae..8383cd8ac3 100644 --- a/consensus/ibftlegacy/src/main/java/tech/pegasys/pantheon/consensus/ibftlegacy/IbftBlockHashing.java +++ b/consensus/ibftlegacy/src/main/java/tech/pegasys/pantheon/consensus/ibftlegacy/IbftBlockHashing.java @@ -107,9 +107,7 @@ public static List
recoverCommitterAddresses( final Hash committerHash = IbftBlockHashing.calculateDataHashForCommittedSeal(header, ibftExtraData); - return ibftExtraData - .getSeals() - .stream() + return ibftExtraData.getSeals().stream() .map(p -> Util.signatureToAddress(p, committerHash)) .collect(Collectors.toList()); } diff --git a/consensus/ibftlegacy/src/test/java/tech/pegasys/pantheon/consensus/ibftlegacy/headervalidationrules/IbftExtraDataValidationRuleTest.java b/consensus/ibftlegacy/src/test/java/tech/pegasys/pantheon/consensus/ibftlegacy/headervalidationrules/IbftExtraDataValidationRuleTest.java index b01e1a0409..40c657ed8b 100644 --- a/consensus/ibftlegacy/src/test/java/tech/pegasys/pantheon/consensus/ibftlegacy/headervalidationrules/IbftExtraDataValidationRuleTest.java +++ b/consensus/ibftlegacy/src/test/java/tech/pegasys/pantheon/consensus/ibftlegacy/headervalidationrules/IbftExtraDataValidationRuleTest.java @@ -83,8 +83,7 @@ private IbftExtraData createExtraDataWithCommitSeals( IbftBlockHashing.calculateDataHashForCommittedSeal(header, extraDataInHeader); final List commitSeals = - committerKeyPairs - .stream() + committerKeyPairs.stream() .map(keys -> SECP256K1.sign(headerHashForCommitters, keys)) .collect(Collectors.toList()); diff --git a/errorprone-checks/src/main/java/tech/pegasys/errorpronechecks/DoNotCreateSecureRandomDirectly.java b/errorprone-checks/src/main/java/tech/pegasys/errorpronechecks/DoNotCreateSecureRandomDirectly.java index 8fa88adcb0..9720525669 100644 --- a/errorprone-checks/src/main/java/tech/pegasys/errorpronechecks/DoNotCreateSecureRandomDirectly.java +++ b/errorprone-checks/src/main/java/tech/pegasys/errorpronechecks/DoNotCreateSecureRandomDirectly.java @@ -29,11 +29,10 @@ @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 { diff --git a/errorprone-checks/src/main/java/tech/pegasys/errorpronechecks/DoNotInvokeMessageDigestDirectly.java b/errorprone-checks/src/main/java/tech/pegasys/errorpronechecks/DoNotInvokeMessageDigestDirectly.java index 2f92256071..baeb4593d4 100644 --- a/errorprone-checks/src/main/java/tech/pegasys/errorpronechecks/DoNotInvokeMessageDigestDirectly.java +++ b/errorprone-checks/src/main/java/tech/pegasys/errorpronechecks/DoNotInvokeMessageDigestDirectly.java @@ -25,11 +25,10 @@ @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 { diff --git a/errorprone-checks/src/main/java/tech/pegasys/errorpronechecks/DoNotReturnNullOptionals.java b/errorprone-checks/src/main/java/tech/pegasys/errorpronechecks/DoNotReturnNullOptionals.java index 7d5cb8ad5f..15fd9217fa 100644 --- a/errorprone-checks/src/main/java/tech/pegasys/errorpronechecks/DoNotReturnNullOptionals.java +++ b/errorprone-checks/src/main/java/tech/pegasys/errorpronechecks/DoNotReturnNullOptionals.java @@ -35,11 +35,10 @@ @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 { diff --git a/errorprone-checks/src/main/java/tech/pegasys/errorpronechecks/MethodInputParametersMustBeFinal.java b/errorprone-checks/src/main/java/tech/pegasys/errorpronechecks/MethodInputParametersMustBeFinal.java index 8b22b62228..98ad9c866c 100644 --- a/errorprone-checks/src/main/java/tech/pegasys/errorpronechecks/MethodInputParametersMustBeFinal.java +++ b/errorprone-checks/src/main/java/tech/pegasys/errorpronechecks/MethodInputParametersMustBeFinal.java @@ -31,11 +31,10 @@ @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 { diff --git a/ethereum/core/src/integration-test/java/tech/pegasys/pantheon/ethereum/vm/TraceTransactionIntegrationTest.java b/ethereum/core/src/integration-test/java/tech/pegasys/pantheon/ethereum/vm/TraceTransactionIntegrationTest.java index 44053f97e9..e93933318b 100644 --- a/ethereum/core/src/integration-test/java/tech/pegasys/pantheon/ethereum/vm/TraceTransactionIntegrationTest.java +++ b/ethereum/core/src/integration-test/java/tech/pegasys/pantheon/ethereum/vm/TraceTransactionIntegrationTest.java @@ -94,9 +94,7 @@ public void shouldTraceSStoreOperation() { blockHashLookup); assertThat(result.isSuccessful()).isTrue(); final Account createdContract = - createTransactionUpdater - .getTouchedAccounts() - .stream() + createTransactionUpdater.getTouchedAccounts().stream() .filter(account -> !account.getCode().isEmpty()) .findAny() .get(); diff --git a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/AbstractMessageProcessor.java b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/AbstractMessageProcessor.java index 719a47c22d..801eeeff5e 100644 --- a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/AbstractMessageProcessor.java +++ b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/AbstractMessageProcessor.java @@ -82,10 +82,7 @@ protected AbstractMessageProcessor( private void clearAccumulatedStateBesidesGasAndOutput(final MessageFrame frame) { final Collection
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)); diff --git a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/BlockHeaderValidator.java b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/BlockHeaderValidator.java index a33ac87a19..23d5920735 100644 --- a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/BlockHeaderValidator.java +++ b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/BlockHeaderValidator.java @@ -82,8 +82,7 @@ private boolean applyRules( final BlockHeader parent, final ProtocolContext protocolContext, final Predicate> filter) { - return rules - .stream() + return rules.stream() .filter(filter) .allMatch(rule -> rule.validate(header, parent, protocolContext)); } diff --git a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetTransactionProcessor.java b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetTransactionProcessor.java index 9b5056ad9b..bc9a546512 100644 --- a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetTransactionProcessor.java +++ b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetTransactionProcessor.java @@ -293,9 +293,7 @@ public Result processTransaction( } private static void clearEmptyAccounts(final WorldUpdater worldState) { - worldState - .getTouchedAccounts() - .stream() + worldState.getTouchedAccounts().stream() .filter(Account::isEmpty) .forEach(a -> worldState.deleteAccount(a.getAddress())); } diff --git a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MutableProtocolSchedule.java b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MutableProtocolSchedule.java index fc4654df77..6a52b490a2 100644 --- a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MutableProtocolSchedule.java +++ b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MutableProtocolSchedule.java @@ -62,8 +62,7 @@ public ProtocolSpec getByBlockNumber(final long number) { } public String listMilestones() { - return protocolSpecs - .stream() + return protocolSpecs.stream() .sorted(Comparator.comparing(ScheduledProtocolSpec::getBlock)) .map(spec -> spec.getSpec().getName() + ": " + spec.getBlock()) .collect(Collectors.joining(", ", "[", "]")); diff --git a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/privacy/PrivateTransactionHandler.java b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/privacy/PrivateTransactionHandler.java index 37202c8453..f1816b47c8 100644 --- a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/privacy/PrivateTransactionHandler.java +++ b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/privacy/PrivateTransactionHandler.java @@ -59,9 +59,7 @@ public Transaction handle(final PrivateTransaction privateTransaction) throws IO private SendRequest createSendRequest(final PrivateTransaction privateTransaction) { final List privateFor = - privateTransaction - .getPrivateFor() - .stream() + privateTransaction.getPrivateFor().stream() .map(BytesValues::asString) .collect(Collectors.toList()); diff --git a/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/core/TransactionPoolTest.java b/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/core/TransactionPoolTest.java index 4ab6bfb983..7467e67242 100644 --- a/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/core/TransactionPoolTest.java +++ b/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/core/TransactionPoolTest.java @@ -429,8 +429,7 @@ private Block appendBlock( .buildHeader(), new BlockBody(transactionList, emptyList())); final List transactionReceipts = - transactionList - .stream() + transactionList.stream() .map(transaction -> new TransactionReceipt(1, 1, emptyList())) .collect(toList()); blockchain.appendBlock(block, transactionReceipts); diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/BlockPropagationManager.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/BlockPropagationManager.java index 2157502cff..d15a3a9772 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/BlockPropagationManager.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/BlockPropagationManager.java @@ -190,8 +190,7 @@ private void handleNewBlockHashesFromNetwork(final EthMessage message) { final long localChainHeight = protocolContext.getBlockchain().getChainHeadBlockNumber(); final long bestChainHeight = syncState.bestChainHeight(localChainHeight); final List relevantAnnouncements = - announcedBlocks - .stream() + announcedBlocks.stream() .filter(a -> shouldImportBlockAtHeight(a.number(), localChainHeight, bestChainHeight)) .collect(Collectors.toList()); diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/fastsync/FastSyncBlockHandler.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/fastsync/FastSyncBlockHandler.java index a8609c4a70..af1e8055c4 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/fastsync/FastSyncBlockHandler.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/fastsync/FastSyncBlockHandler.java @@ -82,8 +82,7 @@ private CompletableFuture>> downloadRe private List combineBlocksAndReceipts( final List blocks, final Map> receiptsByHeader) { - return blocks - .stream() + return blocks.stream() .map( block -> { final List receipts = diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/fastsync/PivotBlockRetriever.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/fastsync/PivotBlockRetriever.java index 5f7a8db87c..bf389cf493 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/fastsync/PivotBlockRetriever.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/fastsync/PivotBlockRetriever.java @@ -83,8 +83,7 @@ private CompletableFuture[] requestHeaderFromAllPeers() { .collect(Collectors.toList()); final int confirmationsRequired = peersToQuery.size() / 2 + 1; - return peersToQuery - .stream() + return peersToQuery.stream() .map( peer -> { final RetryingGetHeaderFromPeerByNumberTask getHeaderTask = createGetHeaderTask(peer); diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/state/PendingBlocks.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/state/PendingBlocks.java index de83108965..d00c1ce482 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/state/PendingBlocks.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/state/PendingBlocks.java @@ -76,9 +76,7 @@ public boolean deregisterPendingBlock(final Block block) { } 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 List childrenOf(final Hash parentBlock) { if (blocksByParent == null || blocksByParent.size() == 0) { return Collections.emptyList(); } - return blocksByParent - .stream() + return blocksByParent.stream() .map(pendingBlocks::get) .filter(Objects::nonNull) .collect(Collectors.toList()); diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/CompleteBlocksTask.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/CompleteBlocksTask.java index 13162cf830..44066ef2e0 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/CompleteBlocksTask.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/CompleteBlocksTask.java @@ -121,8 +121,7 @@ private CompletableFuture> processBodiesResult( } private List incompleteHeaders() { - return headers - .stream() + return headers.stream() .filter(h -> blocks.get(h.getNumber()) == null) .collect(Collectors.toList()); } diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/GetReceiptsFromPeerTask.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/GetReceiptsFromPeerTask.java index 66c5939ef3..d2125a8a52 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/GetReceiptsFromPeerTask.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/tasks/GetReceiptsFromPeerTask.java @@ -74,9 +74,7 @@ protected ResponseStream sendRequest(final EthPeer peer) throws PeerNotConnected // 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 blockHashes = - headersByReceiptsRoot - .values() - .stream() + headersByReceiptsRoot.values().stream() .map(headers -> headers.get(0).getHash()) .collect(toList()); return peer.getReceipts(blockHashes); @@ -116,8 +114,7 @@ protected Optional>> processResponse( @Override protected Optional findSuitablePeer() { final long maximumRequiredBlockNumber = - blockHeaders - .stream() + blockHeaders.stream() .mapToLong(BlockHeader::getNumber) .max() .orElse(BlockHeader.GENESIS_BLOCK_NUMBER); diff --git a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/ethtaskutils/PeerMessageTaskTest.java b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/ethtaskutils/PeerMessageTaskTest.java index c00af3819e..02dcc979d5 100644 --- a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/ethtaskutils/PeerMessageTaskTest.java +++ b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/manager/ethtaskutils/PeerMessageTaskTest.java @@ -126,11 +126,7 @@ public void recordsTimeoutAgainstPeerWhenTaskTimesOut() { assertThat(future.isCompletedExceptionally()).isTrue(); assertThat( - respondingEthPeer - .getEthPeer() - .timeoutCounts() - .values() - .stream() + respondingEthPeer.getEthPeer().timeoutCounts().values().stream() .mapToInt(AtomicInteger::get) .sum()) .isEqualTo(1); diff --git a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/sync/fullsync/FullSyncDownloaderTest.java b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/sync/fullsync/FullSyncDownloaderTest.java index 1087605178..2eddc406fc 100644 --- a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/sync/fullsync/FullSyncDownloaderTest.java +++ b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/sync/fullsync/FullSyncDownloaderTest.java @@ -603,8 +603,7 @@ public void requestsCheckpointsFromSyncTarget() { 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) diff --git a/ethereum/jsonrpc/src/integration-test/java/tech/pegasys/pantheon/ethereum/jsonrpc/methods/EthGetFilterChangesIntegrationTest.java b/ethereum/jsonrpc/src/integration-test/java/tech/pegasys/pantheon/ethereum/jsonrpc/methods/EthGetFilterChangesIntegrationTest.java index 7390ecc264..72bfda863d 100644 --- a/ethereum/jsonrpc/src/integration-test/java/tech/pegasys/pantheon/ethereum/jsonrpc/methods/EthGetFilterChangesIntegrationTest.java +++ b/ethereum/jsonrpc/src/integration-test/java/tech/pegasys/pantheon/ethereum/jsonrpc/methods/EthGetFilterChangesIntegrationTest.java @@ -244,8 +244,7 @@ private Block appendBlock( .buildHeader(), new BlockBody(transactionList, emptyList())); final List transactionReceipts = - transactionList - .stream() + transactionList.stream() .map(transaction -> new TransactionReceipt(1, 1, emptyList())) .collect(toList()); blockchain.appendBlock(block, transactionReceipts); diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcHttpService.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcHttpService.java index 6c6b27991b..59fe532030 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcHttpService.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcHttpService.java @@ -262,9 +262,7 @@ private Optional getAndValidateHostHeader(final RoutingContext event) { } 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 @@ private void handleJsonBatchRequest( final RoutingContext routingContext, final JsonArray jsonArray) { // Interpret json as rpc request final List responses = - jsonArray - .stream() + jsonArray.stream() .map( obj -> { if (!(obj instanceof JsonObject)) { @@ -460,9 +457,7 @@ private void handleJsonBatchRequest( return; } final JsonRpcResponse[] completed = - res.result() - .list() - .stream() + res.result().list().stream() .map(JsonRpcResponse.class::cast) .filter(this::isNonEmptyResponses) .toArray(JsonRpcResponse[]::new); diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/authentication/TomlAuth.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/authentication/TomlAuth.java index 481e5127d5..0eaecef7e3 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/authentication/TomlAuth.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/authentication/TomlAuth.java @@ -116,24 +116,15 @@ private void readUser(final String username, final Handler private TomlUser readTomlUserFromTable(final String username, final TomlTable userData) { final String saltedAndHashedPassword = userData.getString("password", () -> ""); final List groups = - userData - .getArrayOrEmpty("groups") - .toList() - .stream() + userData.getArrayOrEmpty("groups").toList().stream() .map(Object::toString) .collect(Collectors.toList()); final List permissions = - userData - .getArrayOrEmpty("permissions") - .toList() - .stream() + userData.getArrayOrEmpty("permissions").toList().stream() .map(Object::toString) .collect(Collectors.toList()); final List roles = - userData - .getArrayOrEmpty("roles") - .toList() - .stream() + userData.getArrayOrEmpty("roles").toList().stream() .map(Object::toString) .collect(Collectors.toList()); diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/filter/FilterRepository.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/filter/FilterRepository.java index dfa66846c3..180fda3c4e 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/filter/FilterRepository.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/filter/FilterRepository.java @@ -31,9 +31,7 @@ Collection getFilters() { } Collection getFiltersOfType(final Class filterClass) { - return filters - .values() - .stream() + return filters.values().stream() .flatMap(f -> getIfTypeMatches(f, filterClass).map(Stream::of).orElseGet(Stream::empty)) .collect(Collectors.toList()); } diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthProtocolVersion.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthProtocolVersion.java index 4cb80438a8..9344180b5e 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthProtocolVersion.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/EthProtocolVersion.java @@ -27,8 +27,7 @@ public class EthProtocolVersion implements JsonRpcMethod { public EthProtocolVersion(final Set supportedCapabilities) { final OptionalInt version = - supportedCapabilities - .stream() + supportedCapabilities.stream() .filter(cap -> EthProtocol.NAME.equals(cap.getName())) .mapToInt(Capability::getVersion) .max(); diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/queries/BlockchainQueries.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/queries/BlockchainQueries.java index 8c02dc4b2b..6818664efc 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/queries/BlockchainQueries.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/queries/BlockchainQueries.java @@ -293,8 +293,7 @@ public Optional> blockByHash( formatTransactions( txs, header.getNumber(), blockHeaderHash); final List 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 Optional> blockByHashWithTxHashes( .map( (td) -> { final List txs = - body.getTransactions() - .stream() + body.getTransactions().stream() .map(Transaction::hash) .collect(Collectors.toList()); final List ommers = - body.getOmmers() - .stream() + body.getOmmers().stream() .map(BlockHeader::getHash) .collect(Collectors.toList()); final int size = new Block(header, body).calculateSize(); diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/results/BlockResultFactory.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/results/BlockResultFactory.java index 16e658daf0..c1a07376e9 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/results/BlockResultFactory.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/results/BlockResultFactory.java @@ -27,15 +27,11 @@ public class BlockResultFactory { public BlockResult transactionComplete( final BlockWithMetadata blockWithMetadata) { final List txs = - blockWithMetadata - .getTransactions() - .stream() + blockWithMetadata.getTransactions().stream() .map(TransactionCompleteResult::new) .collect(Collectors.toList()); final List ommers = - blockWithMetadata - .getOmmers() - .stream() + blockWithMetadata.getOmmers().stream() .map(Hash::toString) .map(TextNode::new) .collect(Collectors.toList()); @@ -49,16 +45,12 @@ public BlockResult transactionComplete( public BlockResult transactionHash(final BlockWithMetadata blockWithMetadata) { final List txs = - blockWithMetadata - .getTransactions() - .stream() + blockWithMetadata.getTransactions().stream() .map(Hash::toString) .map(TransactionHashResult::new) .collect(Collectors.toList()); final List ommers = - blockWithMetadata - .getOmmers() - .stream() + blockWithMetadata.getOmmers().stream() .map(Hash::toString) .map(TextNode::new) .collect(Collectors.toList()); diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/results/DebugTraceTransactionResult.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/results/DebugTraceTransactionResult.java index 0eaec3ac8e..664d106739 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/results/DebugTraceTransactionResult.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/results/DebugTraceTransactionResult.java @@ -33,9 +33,7 @@ public DebugTraceTransactionResult(final TransactionTrace transactionTrace) { 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(); diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/results/PeerResult.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/results/PeerResult.java index 4a4f67b619..cb8238cd4e 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/results/PeerResult.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/results/PeerResult.java @@ -37,9 +37,7 @@ public PeerResult(final PeerConnection peer) { 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()); diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/results/StructLogWithError.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/results/StructLogWithError.java index a1620af9c9..642e889184 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/results/StructLogWithError.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/results/StructLogWithError.java @@ -26,9 +26,7 @@ public StructLogWithError(final TraceFrame traceFrame) { error = traceFrame.getExceptionalHaltReasons().isEmpty() ? null - : traceFrame - .getExceptionalHaltReasons() - .stream() + : traceFrame.getExceptionalHaltReasons().stream() .map(ExceptionalHaltReason::name) .toArray(String[]::new); } diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/subscription/SubscriptionManager.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/subscription/SubscriptionManager.java index 174211a30c..5773ceb41f 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/subscription/SubscriptionManager.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/subscription/SubscriptionManager.java @@ -152,9 +152,7 @@ public Map> getConnectionSubscriptionsMap() { } public List subscriptionsOfType(final SubscriptionType type, final Class 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 List subscriptionsOfType(final SubscriptionType type, final Class< 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() diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/subscription/logs/LogsSubscriptionService.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/subscription/logs/LogsSubscriptionService.java index e49102d0f4..72abc0a7f3 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/subscription/logs/LogsSubscriptionService.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/subscription/logs/LogsSubscriptionService.java @@ -46,9 +46,7 @@ public void onBlockAdded(final BlockAddedEvent event, final Blockchain blockchai return; } - event - .getAddedTransactions() - .stream() + event.getAddedTransactions().stream() .map(tx -> blockchainQueries.transactionReceiptByTransactionHash(tx.hash())) .filter(Optional::isPresent) .map(Optional::get) @@ -58,9 +56,7 @@ public void onBlockAdded(final BlockAddedEvent event, final Blockchain blockchai sendLogsToMatchingSubscriptions(logs, logsSubscriptions, receiptWithMetadata, false); }); - event - .getRemovedTransactions() - .stream() + event.getRemovedTransactions().stream() .map(tx -> blockchainQueries.transactionReceiptByTransactionHash(tx.hash())) .filter(Optional::isPresent) .map(Optional::get) diff --git a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcHttpServiceTest.java b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcHttpServiceTest.java index b1ed145cea..4c06ffb4ae 100644 --- a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcHttpServiceTest.java +++ b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcHttpServiceTest.java @@ -1824,10 +1824,7 @@ public BlockWithMetadata blockWithMetadataAndTxHashes(final Block bl final int size = block.calculateSize(); final List txs = - block - .getBody() - .getTransactions() - .stream() + block.getBody().getTransactions().stream() .map(Transaction::hash) .collect(Collectors.toList()); final List ommers = diff --git a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/queries/BlockchainQueriesTest.java b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/queries/BlockchainQueriesTest.java index 4668773eb2..67e5f230b7 100644 --- a/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/queries/BlockchainQueriesTest.java +++ b/ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/queries/BlockchainQueriesTest.java @@ -485,10 +485,7 @@ private void assertBlockMatchesResult( final Block targetBlock, final BlockWithMetadata result) { assertEquals(targetBlock.getHeader(), result.getHeader()); final List expectedOmmers = - targetBlock - .getBody() - .getOmmers() - .stream() + targetBlock.getBody().getOmmers().stream() .map(BlockHeader::getHash) .collect(Collectors.toList()); assertEquals(expectedOmmers, result.getOmmers()); @@ -507,10 +504,7 @@ private void assertBlockMatchesResultWithTxHashes( final Block targetBlock, final BlockWithMetadata result) { assertEquals(targetBlock.getHeader(), result.getHeader()); final List expectedOmmers = - targetBlock - .getBody() - .getOmmers() - .stream() + targetBlock.getBody().getOmmers().stream() .map(BlockHeader::getHash) .collect(Collectors.toList()); assertEquals(expectedOmmers, result.getOmmers()); diff --git a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/NetworkRunner.java b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/NetworkRunner.java index b87d729436..1085aef6c2 100644 --- a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/NetworkRunner.java +++ b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/NetworkRunner.java @@ -196,8 +196,7 @@ public NetworkRunner build() { subProtocolMap.put(subProtocol.getName(), subProtocol); } final List caps = - protocolManagers - .stream() + protocolManagers.stream() .flatMap(p -> p.getSupportedCapabilities().stream()) .collect(Collectors.toList()); for (final Capability cap : caps) { diff --git a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryController.java b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryController.java index f6debecb13..9870e8d558 100644 --- a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryController.java +++ b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryController.java @@ -153,8 +153,7 @@ public CompletableFuture start() { 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)); diff --git a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerTable.java b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerTable.java index d1b3dfbc84..384f2a6004 100644 --- a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerTable.java +++ b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerTable.java @@ -179,8 +179,7 @@ private void buildBloomFilter() { */ public List 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) diff --git a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/permissioning/NodeWhitelistController.java b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/permissioning/NodeWhitelistController.java index b7f4346483..f10f3c6292 100644 --- a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/permissioning/NodeWhitelistController.java +++ b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/permissioning/NodeWhitelistController.java @@ -99,8 +99,7 @@ private NodesWhitelistResult validInput(final List peers) { } public boolean isPermitted(final Peer node) { - return nodesWhitelist - .stream() + return nodesWhitelist.stream() .anyMatch( p -> { boolean idsMatch = node.getId().equals(p.getId()); diff --git a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java index 5065b25099..2f9d891bde 100644 --- a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java +++ b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java @@ -64,8 +64,7 @@ public void neighborsPacketLimited() { final List otherAgents = helper.startDiscoveryAgents(20, Collections.emptyList()); final List otherPeers = - otherAgents - .stream() + otherAgents.stream() .map(MockPeerDiscoveryAgent::getAdvertisedPeer) .collect(Collectors.toList()); @@ -91,9 +90,7 @@ public void neighborsPacketLimited() { // Check response packet List incomingPackets = - testAgent - .getIncomingPackets() - .stream() + testAgent.getIncomingPackets().stream() .filter(p -> p.packet.getType().equals(PacketType.NEIGHBORS)) .collect(Collectors.toList()); assertThat(incomingPackets.size()).isEqualTo(1); diff --git a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryBondingTest.java b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryBondingTest.java index f1f9f82e69..23846a3e9a 100644 --- a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryBondingTest.java +++ b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryBondingTest.java @@ -43,9 +43,7 @@ public void pongSentUponPing() { helper.sendMessageBetweenAgents(otherAgent, agent, ping); final List 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 void neighborsPacketNotSentUnlessBonded() throws InterruptedException { // Now we received a PONG. final List incomingPongs = - otherNode - .getIncomingPackets() - .stream() + otherNode.getIncomingPackets().stream() .filter(p -> p.packet.getType().equals(PacketType.PONG)) .collect(Collectors.toList()); assertThat(incomingPongs.size()).isEqualTo(1); diff --git a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryBootstrappingTest.java b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryBootstrappingTest.java index 51befa6bba..be13dcc73b 100644 --- a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryBootstrappingTest.java +++ b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryBootstrappingTest.java @@ -42,9 +42,7 @@ public void bootstrappingPingsSentSingleBootstrapPeer() { final PeerDiscoveryAgent agent = helper.startDiscoveryAgent(testAgent.getAdvertisedPeer()); final List 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 void bootstrappingPingsSentMultipleBootstrapPeers() { final List senderIds = packets.stream().map(Packet::getNodeId).distinct().collect(toList()); final List agentIds = - agents - .stream() + agents.stream() .map(PeerDiscoveryAgent::getAdvertisedPeer) .map(Peer::getId) .distinct() diff --git a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryObserversTest.java b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryObserversTest.java index 81b5b734c4..ecbf74545b 100644 --- a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryObserversTest.java +++ b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryObserversTest.java @@ -85,16 +85,14 @@ public void peerBondedObserverTriggered() throws TimeoutException, InterruptedEx final List others1 = helper.startDiscoveryAgents(3, Collections.emptyList()); final List peers1 = - others1 - .stream() + others1.stream() .map(MockPeerDiscoveryAgent::getAdvertisedPeer) .collect(Collectors.toList()); // Create two discovery agents pointing to the above as bootstrap peers. final List others2 = helper.startDiscoveryAgents(2, peers1); final List peers2 = - others2 - .stream() + others2.stream() .map(MockPeerDiscoveryAgent::getAdvertisedPeer) .collect(Collectors.toList()); @@ -112,8 +110,7 @@ public void peerBondedObserverTriggered() throws TimeoutException, InterruptedEx final HashSet seenPeers = new HashSet<>(); List 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, diff --git a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryControllerTest.java b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryControllerTest.java index 47e9a83f3e..5e38ae730b 100644 --- a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryControllerTest.java +++ b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryControllerTest.java @@ -221,9 +221,7 @@ public void bootstrapPeersPongReceived_HashMatched() { controller.start(); assertThat( - controller - .getPeers() - .stream() + controller.getPeers().stream() .filter(p -> p.getStatus() == PeerDiscoveryStatus.BONDING)) .hasSize(3); @@ -242,9 +240,7 @@ public void bootstrapPeersPongReceived_HashMatched() { .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 void bootstrapPeersPongReceived_HashUnmatched() { controller.start(); assertThat( - controller - .getPeers() - .stream() + controller.getPeers().stream() .filter(p -> p.getStatus() == PeerDiscoveryStatus.BONDING)) .hasSize(3); @@ -291,9 +285,7 @@ public void bootstrapPeersPongReceived_HashUnmatched() { .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 void findNeighborsSentAfterBondingFinished() { final ArgumentCaptor captor = ArgumentCaptor.forClass(Packet.class); verify(outboundMessageHandler, atLeast(1)).send(eq(peers.get(0)), captor.capture()); List neighborsPackets = - captor - .getAllValues() - .stream() + captor.getAllValues().stream() .filter(p -> p.getType().equals(PacketType.FIND_NEIGHBORS)) .collect(Collectors.toList()); assertThat(neighborsPackets.size()).isEqualTo(1); diff --git a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryTableRefreshTest.java b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryTableRefreshTest.java index ba30e23696..8f8401108a 100644 --- a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryTableRefreshTest.java +++ b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryTableRefreshTest.java @@ -86,9 +86,7 @@ public void tableRefreshSingleNode() { } verify(outboundMessageHandler, atLeast(5)).send(eq(peers.get(1)), captor.capture()); List capturedFindNeighborsPackets = - captor - .getAllValues() - .stream() + captor.getAllValues().stream() .filter(p -> p.getType().equals(PacketType.FIND_NEIGHBORS)) .collect(Collectors.toList()); assertThat(capturedFindNeighborsPackets.size()).isEqualTo(5); diff --git a/metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsHttpService.java b/metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsHttpService.java index 6f1a62f587..d5d4cb211a 100644 --- a/metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsHttpService.java +++ b/metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsHttpService.java @@ -157,9 +157,7 @@ private Optional getAndValidateHostHeader(final RoutingContext event) { } private boolean hostIsInWhitelist(final String hostHeader) { - return config - .getHostsWhitelist() - .stream() + return config.getHostsWhitelist().stream() .anyMatch(whitelistEntry -> whitelistEntry.toLowerCase().equals(hostHeader.toLowerCase())); } diff --git a/metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusMetricsSystem.java b/metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusMetricsSystem.java index fef0ee052c..de37600c8c 100644 --- a/metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusMetricsSystem.java +++ b/metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusMetricsSystem.java @@ -120,18 +120,14 @@ private void addCollector(final MetricCategory category, final Collector metric) @Override public Stream 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 convertSamplesToObservations( final MetricCategory category, final MetricFamilySamples familySamples) { - return familySamples - .samples - .stream() + return familySamples.samples.stream() .map(sample -> createObservationFromSample(category, sample, familySamples)); } diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/PermissioningConfigurationBuilder.java b/pantheon/src/main/java/tech/pegasys/pantheon/PermissioningConfigurationBuilder.java index 2f0ffc4fee..7e86f70fd6 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/PermissioningConfigurationBuilder.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/PermissioningConfigurationBuilder.java @@ -70,9 +70,7 @@ public static PermissioningConfiguration permissioningConfiguration( if (permissionedAccountEnabled) { if (accountWhitelistTomlArray != null) { List accountsWhitelistToml = - accountWhitelistTomlArray - .toList() - .stream() + accountWhitelistTomlArray.toList().stream() .map(Object::toString) .collect(Collectors.toList()); permissioningConfiguration.setAccountWhitelist(accountsWhitelistToml); @@ -84,9 +82,7 @@ public static PermissioningConfiguration permissioningConfiguration( if (permissionedNodeEnabled) { if (nodeWhitelistTomlArray != null) { List nodesWhitelistToml = - nodeWhitelistTomlArray - .toList() - .stream() + nodeWhitelistTomlArray.toList().stream() .map(Object::toString) .map(EnodeToURIPropertyConverter::convertToURI) .collect(Collectors.toList()); diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java b/pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java index 1b07d6995b..dd2cc0509c 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java @@ -198,8 +198,7 @@ public Runner build() { final List subProtocols = subProtocolConfiguration.getSubProtocols(); final List protocolManagers = subProtocolConfiguration.getProtocolManagers(); final Set supportedCapabilities = - protocolManagers - .stream() + protocolManagers.stream() .flatMap(protocolManager -> protocolManager.getSupportedCapabilities().stream()) .collect(Collectors.toSet()); diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/BlocksSubCommand.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/BlocksSubCommand.java index 9427018c9b..e5e455cf7f 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/BlocksSubCommand.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/BlocksSubCommand.java @@ -41,11 +41,10 @@ /** 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 @@ public void run() { *

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 diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/CommandLineUtils.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/CommandLineUtils.java index 38b9b62c96..92e6d0487b 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/CommandLineUtils.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/CommandLineUtils.java @@ -47,10 +47,7 @@ static void checkOptionDependencies( final List dependentOptionsNames) { if (isMainOptionCondition) { String affectedOptions = - commandLine - .getCommandSpec() - .options() - .stream() + commandLine.getCommandSpec().options().stream() .filter( option -> Arrays.stream(option.names()).anyMatch(dependentOptionsNames::contains) diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java index 41daf9d5b8..5e4af70e19 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java @@ -86,18 +86,17 @@ @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 static class RpcApisConversionException extends Exception { // 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 static class RpcApisConversionException extends Exception { // 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 = "", - description = - "Comma separated enode URLs for P2P discovery bootstrap. " - + "Default is a predefined list.", - split = ",", - arity = "0..*", - converter = EnodeToURIPropertyConverter.class - ) + names = {"--bootnodes"}, + paramLabel = "", + description = + "Comma separated enode URLs for P2P discovery bootstrap. " + + "Default is a predefined list.", + split = ",", + arity = "0..*", + converter = EnodeToURIPropertyConverter.class) private final Collection 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 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 = "", - 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 = "", + split = ",", + arity = "1..*", + converter = RpcApisConverter.class, + description = "Comma separated APIs to enable on JSON-RPC channel. default: ${DEFAULT-VALUE}") private final Collection 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 = "", - 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 = "", + split = ",", + arity = "1..*", + converter = RpcApisConverter.class, + description = + "Comma separated APIs to enable on WebSocket channel. default: ${DEFAULT-VALUE}") private final Collection rpcWsApis = DEFAULT_JSON_RPC_APIS; private Long rpcWsRefreshDelay; @Option( - names = {"--rpc-ws-refresh-delay"}, - paramLabel = "", - 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 = "", + 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 @@ private Long configureRefreshDelay(final Long refreshDelay) { } @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 = "[,...]... 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 = "[,...]... 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 = "", - description = - "Logging verbosity levels: OFF, FATAL, WARN, INFO, DEBUG, TRACE, ALL (default: INFO)." - ) + names = {"--logging", "-l"}, + paramLabel = "", + 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( diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PasswordSubCommand.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PasswordSubCommand.java index 6ba548b464..7bc95ae877 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PasswordSubCommand.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PasswordSubCommand.java @@ -24,10 +24,9 @@ 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"; diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PublicKeySubCommand.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PublicKeySubCommand.java index 1638b73946..29a6d7ceb4 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PublicKeySubCommand.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PublicKeySubCommand.java @@ -38,11 +38,10 @@ /** 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 @@ public void run() { * 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") diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/StandaloneCommand.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/StandaloneCommand.java index 83d3543515..8fd0c35184 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/StandaloneCommand.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/StandaloneCommand.java @@ -22,17 +22,15 @@ 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; } diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/TomlConfigFileDefaultProvider.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/TomlConfigFileDefaultProvider.java index 83d026dfc1..2fc9f4896e 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/TomlConfigFileDefaultProvider.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/TomlConfigFileDefaultProvider.java @@ -118,9 +118,7 @@ private void loadConfigurationFromFile() { if (result.hasErrors()) { final String errors = - result - .errors() - .stream() + result.errors().stream() .map(TomlParseError::toString) .collect(Collectors.joining("%n")); ; diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/util/PermissioningConfigurationValidator.java b/pantheon/src/main/java/tech/pegasys/pantheon/util/PermissioningConfigurationValidator.java index 4ac1b4221d..1cd70d2409 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/util/PermissioningConfigurationValidator.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/util/PermissioningConfigurationValidator.java @@ -35,8 +35,7 @@ public static void areAllBootnodesAreInWhitelist( ethNetworkConfig.getBootNodes()); if (permissioningConfiguration.isNodeWhitelistEnabled() && bootnodes != null) { bootnodesNotInWhitelist = - bootnodes - .stream() + bootnodes.stream() .filter( node -> !permissioningConfiguration diff --git a/pantheon/src/test/java/tech/pegasys/pantheon/cli/CommandLineUtilsTest.java b/pantheon/src/test/java/tech/pegasys/pantheon/cli/CommandLineUtilsTest.java index c62b4400a4..1fa308ecd9 100644 --- a/pantheon/src/test/java/tech/pegasys/pantheon/cli/CommandLineUtilsTest.java +++ b/pantheon/src/test/java/tech/pegasys/pantheon/cli/CommandLineUtilsTest.java @@ -48,9 +48,8 @@ private abstract static class AbstractTestCommand implements Runnable { // Completely disables p2p within Pantheon. @Option( - names = {"--option-enabled"}, - arity = "1" - ) + names = {"--option-enabled"}, + arity = "1") final Boolean optionEnabled = true; @Option(names = {"--option2"}) diff --git a/pantheon/src/test/java/tech/pegasys/pantheon/util/StringUtilsTest.java b/pantheon/src/test/java/tech/pegasys/pantheon/util/StringUtilsTest.java index a2c4657b42..c07005f041 100644 --- a/pantheon/src/test/java/tech/pegasys/pantheon/util/StringUtilsTest.java +++ b/pantheon/src/test/java/tech/pegasys/pantheon/util/StringUtilsTest.java @@ -35,9 +35,7 @@ public void joiningWithLastDelimiter() { for (Entry, String> entry : testCases.entrySet()) { String joinedResult = - entry - .getKey() - .stream() + entry.getKey().stream() .collect( Collectors.collectingAndThen( Collectors.toList(), StringUtils.joiningWithLastDelimiter(", ", " and "))); diff --git a/services/kvstore/src/main/java/tech/pegasys/pantheon/services/kvstore/InMemoryKeyValueStorage.java b/services/kvstore/src/main/java/tech/pegasys/pantheon/services/kvstore/InMemoryKeyValueStorage.java index b4395fcb57..5585364eae 100644 --- a/services/kvstore/src/main/java/tech/pegasys/pantheon/services/kvstore/InMemoryKeyValueStorage.java +++ b/services/kvstore/src/main/java/tech/pegasys/pantheon/services/kvstore/InMemoryKeyValueStorage.java @@ -52,9 +52,7 @@ public Stream entries() { 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(); diff --git a/testutil/src/main/java/tech/pegasys/orion/testutil/OrionTestHarness.java b/testutil/src/main/java/tech/pegasys/orion/testutil/OrionTestHarness.java index 0f93eb3fe9..ea35b656cf 100644 --- a/testutil/src/main/java/tech/pegasys/orion/testutil/OrionTestHarness.java +++ b/testutil/src/main/java/tech/pegasys/orion/testutil/OrionTestHarness.java @@ -86,17 +86,13 @@ public Config getConfig() { } public List getPublicKeys() { - return config - .publicKeys() - .stream() + return config.publicKeys().stream() .map(OrionTestHarness::readFile) .collect(Collectors.toList()); } public List getPrivateKeys() { - return config - .privateKeys() - .stream() + return config.privateKeys().stream() .map(OrionTestHarness::readFile) .collect(Collectors.toList()); }