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();
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

View File

@ -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]) {

View File

@ -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

View File

@ -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

View File

@ -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<PeerAddress> addresses;

View File

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

View File

@ -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;
}

View File

@ -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;

View File

@ -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);
};
}
/**
* <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.
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;

View File

@ -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));
}