3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-07 23:03:04 +00:00

More minor issues found by IntelliJ static analysis.

This commit is contained in:
Mike Hearn 2013-03-15 17:19:28 +01:00
parent 3a899767b4
commit 1ed2459522
6 changed files with 66 additions and 69 deletions

View File

@ -100,7 +100,7 @@ public class GetBlocksMessage extends Message {
@Override
public int hashCode() {
int hashCode = (int) version ^ "getblocks".hashCode();
for (int i = 0; i < locator.size(); i++) hashCode ^= locator.get(i).hashCode();
for (Sha256Hash aLocator : locator) hashCode ^= aLocator.hashCode();
hashCode ^= stopHash.hashCode();
return hashCode;
}

View File

@ -56,7 +56,7 @@ public class GetHeadersMessage extends GetBlocksMessage {
@Override
public int hashCode() {
int hashCode = (int) version ^ "getheaders".hashCode();
for (int i = 0; i < locator.size(); i++) hashCode ^= locator.get(i).hashCode();
for (Sha256Hash aLocator : locator) hashCode ^= aLocator.hashCode();
hashCode ^= stopHash.hashCode();
return hashCode;
}

View File

@ -70,7 +70,7 @@ public class HeadersMessage extends Message {
// Read 80 bytes of the header and one more byte for the transaction list, which is always a 00 because the
// transaction list is empty.
byte[] blockHeader = readBytes(81);
if (blockHeader[80] != 00)
if (blockHeader[80] != 0)
throw new ProtocolException("Block header does not end with a null byte");
Block newBlockHeader = new Block(this.params, blockHeader, true, true, 81);
blockHeaders.add(newBlockHeader);

View File

@ -109,7 +109,6 @@ public class DiskBlockStore implements BlockStore {
private void load(File theFile) throws IOException, BlockStoreException {
log.info("Reading block store from {}", theFile);
try {
// Read a version byte.
int version = file.read();
if (version == -1) {
@ -170,8 +169,6 @@ public class DiskBlockStore implements BlockStore {
}
long elapsed = System.currentTimeMillis() - now;
log.info("Block chain read complete in {}ms", elapsed);
} finally {
}
}
private void ensureOpen() throws BlockStoreException {

View File

@ -43,6 +43,6 @@ public class WalletExtensionSerializer {
* Get collection of extensions to add, should be overridden by any class adding wallet extensions.
*/
public Collection<Protos.Extension> getExtensionsToWrite(Wallet wallet) {
return Collections.<Protos.Extension>emptyList();
return Collections.emptyList();
}
}

View File

@ -185,11 +185,11 @@ public class BitcoinURI {
}
// Attempt to decode the rest of the tokens into a parameter map.
for (int i = 0; i < nameValuePairTokens.length; i++) {
String[] tokens = nameValuePairTokens[i].split("=");
for (String nameValuePairToken : nameValuePairTokens) {
String[] tokens = nameValuePairToken.split("=");
if (tokens.length != 2 || "".equals(tokens[0])) {
throw new BitcoinURIParseException("Malformed Bitcoin URI - cannot parse name value pair '" +
nameValuePairTokens[i] + "'");
nameValuePairToken + "'");
}
String nameToken = tokens[0].toLowerCase();