diff --git a/core/src/main/java/com/google/bitcoin/core/AddressMessage.java b/core/src/main/java/com/google/bitcoin/core/AddressMessage.java index 15f8c193..db4f33d0 100644 --- a/core/src/main/java/com/google/bitcoin/core/AddressMessage.java +++ b/core/src/main/java/com/google/bitcoin/core/AddressMessage.java @@ -127,14 +127,12 @@ public class AddressMessage extends Message { getMessageSize(); else length += address.getMessageSize(); - ; } public void removeAddress(int index) { unCache(); PeerAddress address = addresses.remove(index); - if (address != null) - address.setParent(null); + address.setParent(null); if (length == UNKNOWN_LENGTH) getMessageSize(); else diff --git a/core/src/main/java/com/google/bitcoin/core/BitcoinSerializer.java b/core/src/main/java/com/google/bitcoin/core/BitcoinSerializer.java index 55e31ae6..ee3df9d9 100644 --- a/core/src/main/java/com/google/bitcoin/core/BitcoinSerializer.java +++ b/core/src/main/java/com/google/bitcoin/core/BitcoinSerializer.java @@ -193,7 +193,7 @@ public class BitcoinSerializer { } // Verify the checksum. - byte[] hash = null; + byte[] hash; hash = doubleDigest(payloadBytes); if (header.checksum[0] != hash[0] || header.checksum[1] != hash[1] || header.checksum[2] != hash[2] || header.checksum[3] != hash[3]) { diff --git a/core/src/main/java/com/google/bitcoin/core/BloomFilter.java b/core/src/main/java/com/google/bitcoin/core/BloomFilter.java index 9c761df3..20899d07 100644 --- a/core/src/main/java/com/google/bitcoin/core/BloomFilter.java +++ b/core/src/main/java/com/google/bitcoin/core/BloomFilter.java @@ -162,7 +162,7 @@ public class BloomFilter extends Message { private int hash(int hashNum, byte[] object) { // The following is MurmurHash3 (x86_32), see http://code.google.com/p/smhasher/source/browse/trunk/MurmurHash3.cpp - int h1 = (int)((hashNum * 0xFBA4C795L + nTweak) & 0xFFFFFFFF); + int h1 = (int)(hashNum * 0xFBA4C795L + nTweak); final int c1 = 0xcc9e2d51; final int c2 = 0x1b873593; @@ -199,7 +199,7 @@ public class BloomFilter extends Message { default: // Do nothing. break; - }; + } // finalization h1 ^= object.length; @@ -246,12 +246,10 @@ public class BloomFilter extends Message { @Override public boolean equals(Object other) { - if (other instanceof BloomFilter && - ((BloomFilter)other).hashFuncs == this.hashFuncs && - ((BloomFilter)other).nTweak == this.nTweak && - Arrays.equals(((BloomFilter)other).data, this.data)) - return true; - return false; + return other instanceof BloomFilter && + ((BloomFilter) other).hashFuncs == this.hashFuncs && + ((BloomFilter) other).nTweak == this.nTweak && + Arrays.equals(((BloomFilter) other).data, this.data); } @Override diff --git a/core/src/main/java/com/google/bitcoin/core/ECKey.java b/core/src/main/java/com/google/bitcoin/core/ECKey.java index a404a13f..5ac67f66 100644 --- a/core/src/main/java/com/google/bitcoin/core/ECKey.java +++ b/core/src/main/java/com/google/bitcoin/core/ECKey.java @@ -228,16 +228,16 @@ public class ECKey implements Serializable { } public String toString() { - StringBuffer b = new StringBuffer(); + StringBuilder b = new StringBuilder(); b.append("pub:").append(Utils.bytesToHexString(pub)); if (creationTimeSeconds != 0) { - b.append(" timestamp:" + creationTimeSeconds); + b.append(" timestamp:").append(creationTimeSeconds); } return b.toString(); } public String toStringWithPrivate() { - StringBuffer b = new StringBuffer(); + StringBuilder b = new StringBuilder(); b.append(toString()); if (priv != null) { b.append(" priv:").append(Utils.bytesToHexString(priv.toByteArray())); @@ -585,7 +585,6 @@ public class ECKey implements Serializable { /** * Sets the creation time of this key. Zero is a convention to mean "unavailable". This method can be useful when * you have a raw key you are importing from somewhere else. - * @param newCreationTimeSeconds */ public void setCreationTimeSeconds(long newCreationTimeSeconds) { if (newCreationTimeSeconds < 0) @@ -600,9 +599,7 @@ public class ECKey implements Serializable { ECKey ecKey = (ECKey) o; - if (!Arrays.equals(pub, ecKey.pub)) return false; - - return true; + return Arrays.equals(pub, ecKey.pub); } @Override diff --git a/core/src/main/java/com/google/bitcoin/core/MemoryPool.java b/core/src/main/java/com/google/bitcoin/core/MemoryPool.java index b17bf5b0..955c5cf0 100644 --- a/core/src/main/java/com/google/bitcoin/core/MemoryPool.java +++ b/core/src/main/java/com/google/bitcoin/core/MemoryPool.java @@ -60,7 +60,7 @@ public class MemoryPool { super(tx, queue); hash = tx.getHash(); } - }; + } private static class Entry { // Invariants: one of the two fields must be null, to indicate which is used. Set addresses; diff --git a/core/src/main/java/com/google/bitcoin/core/PeerGroup.java b/core/src/main/java/com/google/bitcoin/core/PeerGroup.java index a47fb540..b7916c86 100644 --- a/core/src/main/java/com/google/bitcoin/core/PeerGroup.java +++ b/core/src/main/java/com/google/bitcoin/core/PeerGroup.java @@ -1213,7 +1213,6 @@ public class PeerGroup extends AbstractIdleService { lock.unlock(); } future.set(pinnedTx); - return; } }); } diff --git a/core/src/main/java/com/google/bitcoin/core/Script.java b/core/src/main/java/com/google/bitcoin/core/Script.java index 8727617e..7ed528da 100644 --- a/core/src/main/java/com/google/bitcoin/core/Script.java +++ b/core/src/main/java/com/google/bitcoin/core/Script.java @@ -859,13 +859,9 @@ public class Script { private static boolean castToBool(byte[] data) { for (int i = 0; i < data.length; i++) { + // "Can be negative zero" -reference client (see OpenSSL's BN_bn2mpi) if (data[i] != 0) - { - // "Can be negative zero" -reference client (see OpenSSL's BN_bn2mpi) - if (i == data.length - 1 && (data[i] & 0xFF) == 0x80) - return false; - return true; - } + return !(i == data.length - 1 && (data[i] & 0xFF) == 0x80); } return false; } diff --git a/core/src/main/java/com/google/bitcoin/core/Transaction.java b/core/src/main/java/com/google/bitcoin/core/Transaction.java index 7996f490..b23a85f4 100644 --- a/core/src/main/java/com/google/bitcoin/core/Transaction.java +++ b/core/src/main/java/com/google/bitcoin/core/Transaction.java @@ -439,15 +439,15 @@ public class Transaction extends ChildMessage implements Serializable { //parse(); //parsed = true; - length = calcLength(bytes, cursor, offset); + length = calcLength(bytes, offset); cursor = offset + length; } } - protected static int calcLength(byte[] buf, int cursor, int offset) { + protected static int calcLength(byte[] buf, int offset) { VarInt varint; // jump past version (uint32) - cursor = offset + 4; + int cursor = offset + 4; int i; long scriptLen; diff --git a/core/src/main/java/com/google/bitcoin/core/TransactionConfidence.java b/core/src/main/java/com/google/bitcoin/core/TransactionConfidence.java index be81ccc0..432cbb79 100644 --- a/core/src/main/java/com/google/bitcoin/core/TransactionConfidence.java +++ b/core/src/main/java/com/google/bitcoin/core/TransactionConfidence.java @@ -125,7 +125,7 @@ public class TransactionConfidence implements Serializable { } } - }; + } private ConfidenceType confidenceType = ConfidenceType.UNKNOWN; private int appearedAtChainHeight = -1; @@ -165,7 +165,7 @@ public class TransactionConfidence implements Serializable { */ public interface Listener { public void onConfidenceChanged(Transaction tx); - }; + } /** *

Adds an event listener that will be run when this confidence object is updated. The listener will be locked and diff --git a/core/src/main/java/com/google/bitcoin/discovery/IrcDiscovery.java b/core/src/main/java/com/google/bitcoin/discovery/IrcDiscovery.java index 5e434853..005ebf2f 100644 --- a/core/src/main/java/com/google/bitcoin/discovery/IrcDiscovery.java +++ b/core/src/main/java/com/google/bitcoin/discovery/IrcDiscovery.java @@ -244,11 +244,7 @@ public class IrcDiscovery implements PeerDiscovery { // Look for first space. int startIndex = response.indexOf(" ") + 1; // Next part should be status code. - if (response.indexOf(statusCode + " ", startIndex) == startIndex) { - return true; - } else { - return false; - } + return response.indexOf(statusCode + " ", startIndex) == startIndex; } else { if (response.startsWith(statusCode + " ")) { return true; diff --git a/core/src/main/java/com/google/bitcoin/uri/BitcoinURI.java b/core/src/main/java/com/google/bitcoin/uri/BitcoinURI.java index 4cfb0a8e..b751e9b5 100644 --- a/core/src/main/java/com/google/bitcoin/uri/BitcoinURI.java +++ b/core/src/main/java/com/google/bitcoin/uri/BitcoinURI.java @@ -335,8 +335,7 @@ public class BitcoinURI { if (questionMarkHasBeenOutput) { builder.append(AMPERSAND_SEPARATOR); } else { - builder.append(QUESTION_MARK_SEPARATOR); - questionMarkHasBeenOutput = true; + builder.append(QUESTION_MARK_SEPARATOR); } builder.append(FIELD_MESSAGE).append("=").append(encodeURLString(message)); }