3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-31 23:32:16 +00:00

Clear some minor cosmetic issues found by IntelliJ static analysis.

This commit is contained in:
Mike Hearn 2013-03-15 17:14:07 +01:00
parent c2e96be58b
commit 3a899767b4
11 changed files with 22 additions and 39 deletions

View File

@ -127,14 +127,12 @@ public class AddressMessage extends Message {
getMessageSize(); getMessageSize();
else else
length += address.getMessageSize(); length += address.getMessageSize();
;
} }
public void removeAddress(int index) { public void removeAddress(int index) {
unCache(); unCache();
PeerAddress address = addresses.remove(index); PeerAddress address = addresses.remove(index);
if (address != null) address.setParent(null);
address.setParent(null);
if (length == UNKNOWN_LENGTH) if (length == UNKNOWN_LENGTH)
getMessageSize(); getMessageSize();
else else

View File

@ -193,7 +193,7 @@ public class BitcoinSerializer {
} }
// Verify the checksum. // Verify the checksum.
byte[] hash = null; byte[] hash;
hash = doubleDigest(payloadBytes); hash = doubleDigest(payloadBytes);
if (header.checksum[0] != hash[0] || header.checksum[1] != hash[1] || if (header.checksum[0] != hash[0] || header.checksum[1] != hash[1] ||
header.checksum[2] != hash[2] || header.checksum[3] != hash[3]) { header.checksum[2] != hash[2] || header.checksum[3] != hash[3]) {

View File

@ -162,7 +162,7 @@ public class BloomFilter extends Message {
private int hash(int hashNum, byte[] object) { 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 // 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 c1 = 0xcc9e2d51;
final int c2 = 0x1b873593; final int c2 = 0x1b873593;
@ -199,7 +199,7 @@ public class BloomFilter extends Message {
default: default:
// Do nothing. // Do nothing.
break; break;
}; }
// finalization // finalization
h1 ^= object.length; h1 ^= object.length;
@ -246,12 +246,10 @@ public class BloomFilter extends Message {
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (other instanceof BloomFilter && return other instanceof BloomFilter &&
((BloomFilter)other).hashFuncs == this.hashFuncs && ((BloomFilter) other).hashFuncs == this.hashFuncs &&
((BloomFilter)other).nTweak == this.nTweak && ((BloomFilter) other).nTweak == this.nTweak &&
Arrays.equals(((BloomFilter)other).data, this.data)) Arrays.equals(((BloomFilter) other).data, this.data);
return true;
return false;
} }
@Override @Override

View File

@ -228,16 +228,16 @@ public class ECKey implements Serializable {
} }
public String toString() { public String toString() {
StringBuffer b = new StringBuffer(); StringBuilder b = new StringBuilder();
b.append("pub:").append(Utils.bytesToHexString(pub)); b.append("pub:").append(Utils.bytesToHexString(pub));
if (creationTimeSeconds != 0) { if (creationTimeSeconds != 0) {
b.append(" timestamp:" + creationTimeSeconds); b.append(" timestamp:").append(creationTimeSeconds);
} }
return b.toString(); return b.toString();
} }
public String toStringWithPrivate() { public String toStringWithPrivate() {
StringBuffer b = new StringBuffer(); StringBuilder b = new StringBuilder();
b.append(toString()); b.append(toString());
if (priv != null) { if (priv != null) {
b.append(" priv:").append(Utils.bytesToHexString(priv.toByteArray())); 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 * 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. * you have a raw key you are importing from somewhere else.
* @param newCreationTimeSeconds
*/ */
public void setCreationTimeSeconds(long newCreationTimeSeconds) { public void setCreationTimeSeconds(long newCreationTimeSeconds) {
if (newCreationTimeSeconds < 0) if (newCreationTimeSeconds < 0)
@ -600,9 +599,7 @@ public class ECKey implements Serializable {
ECKey ecKey = (ECKey) o; ECKey ecKey = (ECKey) o;
if (!Arrays.equals(pub, ecKey.pub)) return false; return Arrays.equals(pub, ecKey.pub);
return true;
} }
@Override @Override

View File

@ -60,7 +60,7 @@ public class MemoryPool {
super(tx, queue); super(tx, queue);
hash = tx.getHash(); hash = tx.getHash();
} }
}; }
private static class Entry { private static class Entry {
// Invariants: one of the two fields must be null, to indicate which is used. // Invariants: one of the two fields must be null, to indicate which is used.
Set<PeerAddress> addresses; Set<PeerAddress> addresses;

View File

@ -1213,7 +1213,6 @@ public class PeerGroup extends AbstractIdleService {
lock.unlock(); lock.unlock();
} }
future.set(pinnedTx); future.set(pinnedTx);
return;
} }
}); });
} }

View File

@ -859,13 +859,9 @@ public class Script {
private static boolean castToBool(byte[] data) { private static boolean castToBool(byte[] data) {
for (int i = 0; i < data.length; i++) for (int i = 0; i < data.length; i++)
{ {
// "Can be negative zero" -reference client (see OpenSSL's BN_bn2mpi)
if (data[i] != 0) if (data[i] != 0)
{ return !(i == data.length - 1 && (data[i] & 0xFF) == 0x80);
// "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 false; return false;
} }

View File

@ -439,15 +439,15 @@ public class Transaction extends ChildMessage implements Serializable {
//parse(); //parse();
//parsed = true; //parsed = true;
length = calcLength(bytes, cursor, offset); length = calcLength(bytes, offset);
cursor = offset + length; cursor = offset + length;
} }
} }
protected static int calcLength(byte[] buf, int cursor, int offset) { protected static int calcLength(byte[] buf, int offset) {
VarInt varint; VarInt varint;
// jump past version (uint32) // jump past version (uint32)
cursor = offset + 4; int cursor = offset + 4;
int i; int i;
long scriptLen; long scriptLen;

View File

@ -125,7 +125,7 @@ public class TransactionConfidence implements Serializable {
} }
} }
}; }
private ConfidenceType confidenceType = ConfidenceType.UNKNOWN; private ConfidenceType confidenceType = ConfidenceType.UNKNOWN;
private int appearedAtChainHeight = -1; private int appearedAtChainHeight = -1;
@ -165,7 +165,7 @@ public class TransactionConfidence implements Serializable {
*/ */
public interface Listener { public interface Listener {
public void onConfidenceChanged(Transaction tx); public void onConfidenceChanged(Transaction tx);
}; }
/** /**
* <p>Adds an event listener that will be run when this confidence object is updated. The listener will be locked and * <p>Adds an event listener that will be run when this confidence object is updated. The listener will be locked and

View File

@ -244,11 +244,7 @@ public class IrcDiscovery implements PeerDiscovery {
// Look for first space. // Look for first space.
int startIndex = response.indexOf(" ") + 1; int startIndex = response.indexOf(" ") + 1;
// Next part should be status code. // Next part should be status code.
if (response.indexOf(statusCode + " ", startIndex) == startIndex) { return response.indexOf(statusCode + " ", startIndex) == startIndex;
return true;
} else {
return false;
}
} else { } else {
if (response.startsWith(statusCode + " ")) { if (response.startsWith(statusCode + " ")) {
return true; return true;

View File

@ -335,8 +335,7 @@ public class BitcoinURI {
if (questionMarkHasBeenOutput) { if (questionMarkHasBeenOutput) {
builder.append(AMPERSAND_SEPARATOR); builder.append(AMPERSAND_SEPARATOR);
} else { } else {
builder.append(QUESTION_MARK_SEPARATOR); builder.append(QUESTION_MARK_SEPARATOR);
questionMarkHasBeenOutput = true;
} }
builder.append(FIELD_MESSAGE).append("=").append(encodeURLString(message)); builder.append(FIELD_MESSAGE).append("=").append(encodeURLString(message));
} }