Polish whitespace and imports

As part of pull request #179, commits 0d922e1, 003249c and d099100
introduced use of Java 8 language features and APIs. Commit c95f5ea
manually reverted these changes (see #184 as to why), but in the process
re-introduced formatting issues originally cleaned up by other commits
in #179. This change fixes those formatting issues.

 - Replace leading tabs with spaces (for reasons detailed in 0827fb5)
 - Add space before opening curly brace
 - Optimize imports using shared .idea/codeStyleSettings.xml (note
   especially expansion of wildcard imports. See rationale in 780393d)
 - Do not align assignments on equals sign
 - Remove unnecessary additional newlines
 - Remove braces from single-line loops and conditionals
This commit is contained in:
Chris Beams 2014-12-30 19:24:49 +01:00
parent c95f5ea75f
commit a155518b41
No known key found for this signature in database
GPG Key ID: 3D214F8F5BC5ED73
18 changed files with 96 additions and 108 deletions

View File

@ -13,21 +13,17 @@ plugins {
mainClassName = 'org.ethereum.Start'
ext.generatedSrcDir = file('src/gen/java')
sourceSets.main.java.srcDirs += generatedSrcDir
antlr4 {
extraArgs = ['-package', 'org.ethereum.serpent']
output = file("${generatedSrcDir}/org/ethereum/serpent")
}
compileJava.dependsOn antlr4
configurations {
compile.extendsFrom antlr4
}

View File

@ -82,7 +82,8 @@ public class Wallet {
Account account = new Account();
String address = Hex.toHexString(account.getEcKey().getAddress());
rows.put(address, account);
for (WalletListener listener : listeners) listener.valueChanged();
for (WalletListener listener : listeners)
listener.valueChanged();
}
public void importKey(byte[] privKey) {

View File

@ -74,9 +74,8 @@ public class BlockStore {
setParameter("limit", block.getNumber() - qty).
setMaxResults(qty).list();
for (byte[] h : result){
for (byte[] h : result)
hashes.add(h);
}
return hashes;
}

View File

@ -1,6 +1,10 @@
package org.ethereum.manager;
import org.ethereum.core.*;
import org.ethereum.core.Block;
import org.ethereum.core.Genesis;
import org.ethereum.core.Transaction;
import org.ethereum.core.TransactionReceipt;
import org.ethereum.core.Wallet;
import org.ethereum.crypto.HashUtil;
import org.ethereum.db.BlockStore;
import org.ethereum.facade.Blockchain;

View File

@ -48,8 +48,7 @@ public class BlockHashesMessage extends EthMessage {
encodedElements.add(RLP.encodeByte(BLOCK_HASHES.asByte()));
for (byte[] blockHash : blockHashes)
encodedElements.add(RLP.encodeElement(blockHash));
byte[][] encodedElementArray = encodedElements
.toArray(new byte[encodedElements.size()][]);
byte[][] encodedElementArray = encodedElements.toArray(new byte[encodedElements.size()][]);
this.encoded = RLP.encodeList(encodedElementArray);
}

View File

@ -46,9 +46,8 @@ public class BlocksMessage extends EthMessage {
List<byte[]> encodedElements = new Vector<>();
encodedElements.add(RLP.encodeByte(BLOCKS.asByte()));
for (Block block : blocks){
for (Block block : blocks)
encodedElements.add(block.getEncoded());
}
byte[][] encodedElementArray = encodedElements
.toArray(new byte[encodedElements.size()][]);

View File

@ -46,8 +46,7 @@ public class GetBlocksMessage extends EthMessage {
encodedElements.add(RLP.encodeByte(GET_BLOCKS.asByte()));
for (byte[] hash : blockHashes)
encodedElements.add(RLP.encodeElement(hash));
byte[][] encodedElementArray = encodedElements
.toArray(new byte[encodedElements.size()][]);
byte[][] encodedElementArray = encodedElements.toArray(new byte[encodedElements.size()][]);
this.encoded = RLP.encodeList(encodedElementArray);
}

View File

@ -54,8 +54,7 @@ public class TransactionsMessage extends EthMessage {
encodedElements.add(RLP.encodeByte(TRANSACTIONS.asByte()));
for (Transaction tx : transactions)
encodedElements.add(tx.getEncoded());
byte[][] encodedElementArray = encodedElements
.toArray(new byte[encodedElements.size()][]);
byte[][] encodedElementArray = encodedElements.toArray(new byte[encodedElements.size()][]);
this.encoded = RLP.encodeList(encodedElementArray);
}

View File

@ -207,8 +207,9 @@ public class P2pHandler extends SimpleChannelInboundHandler<P2pMessage> {
private void setHandshake(HelloMessage msg, ChannelHandlerContext ctx) {
this.handshakeHelloMessage = msg;
if (msg.getP2PVersion() != P2pHandler.VERSION)
if (msg.getP2PVersion() != P2pHandler.VERSION) {
msgQueue.sendMessage(new DisconnectMessage(ReasonCode.INCOMPATIBLE_PROTOCOL));
}
else {
List<Capability> capInCommon = new ArrayList<>();
for (Capability capability : msg.getCapabilities()) {

View File

@ -60,9 +60,8 @@ public class PeerDiscovery {
threadFactory = Executors.defaultThreadFactory();
// creating the ThreadPoolExecutor
executorPool = new ThreadPoolExecutor(CONFIG.peerDiscoveryWorkers(),
CONFIG.peerDiscoveryWorkers(), 10, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(
1000), threadFactory, rejectionHandler);
executorPool = new ThreadPoolExecutor(CONFIG.peerDiscoveryWorkers(), CONFIG.peerDiscoveryWorkers(), 10,
TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(1000), threadFactory, rejectionHandler);
// start the monitoring thread
monitor = new PeerMonitorThread(executorPool, 1, this);

View File

@ -108,10 +108,9 @@ public class ChannelManager {
}
public void reconnect(){
for (Channel channel : channels){
for (Channel channel : channels)
channel.p2pHandler.sendDisconnect();
}
}
public void ethSync() {

View File

@ -11,8 +11,11 @@ import org.slf4j.LoggerFactory;
import org.spongycastle.util.encoders.Hex;
import java.util.*;
import java.util.stream.Collectors;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static java.util.Arrays.copyOfRange;
import static org.ethereum.crypto.HashUtil.EMPTY_TRIE_HASH;
@ -437,14 +440,11 @@ public class TrieImpl implements Trie {
Map<ByteArrayWrapper, Node> nodes = this.getCache().getNodes();
Set<ByteArrayWrapper> toRemoveSet = new HashSet<>();
for (ByteArrayWrapper key : nodes.keySet()) {
if (!hashSet.contains(key.getData())) {
for (ByteArrayWrapper key : nodes.keySet())
if (!hashSet.contains(key.getData()))
toRemoveSet.add(key);
}
}
for (ByteArrayWrapper key : toRemoveSet) {
this.getCache().delete(key.getData());
if (logger.isTraceEnabled())

View File

@ -26,9 +26,8 @@ public class RLPList extends ArrayList<RLPElement> implements RLPElement {
RLPList rlpList = (RLPList) element;
System.out.print("[");
for (RLPElement singleElement : rlpList) {
for (RLPElement singleElement : rlpList)
recursivePrint(singleElement);
}
System.out.print("]");
} else {
String hex = ByteUtil.toHexString(element.getRLPData());

View File

@ -77,11 +77,9 @@ public class GitHubJSONTestSuite {
TestRunner runner = new TestRunner();
List<String> result = runner.runTestCase(testCase);
if (!result.isEmpty()){
for (String single : result){
if (!result.isEmpty())
for (String single : result)
logger.info(single);
}
}
Assert.assertTrue(result.isEmpty());
}
@ -109,11 +107,9 @@ public class GitHubJSONTestSuite {
TestRunner runner = new TestRunner();
List<String> result = runner.runTestCase(testCase);
if (!result.isEmpty()){
for (String single : result){
if (!result.isEmpty())
for (String single : result)
logger.info(single);
}
}
Assert.assertTrue(result.isEmpty());
}
@ -135,11 +131,9 @@ public class GitHubJSONTestSuite {
TestRunner runner = new TestRunner();
List<String> result = runner.runTestCase(testCase);
if (!result.isEmpty()){
for (String single : result){
if (!result.isEmpty())
for (String single : result)
logger.info(single);
}
}
Assert.assertTrue(result.isEmpty());
}