3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-14 11:15:51 +00:00

Eliminate some warnings from IntelliJ inspections. There are still quite a few but they are all harmless.

This commit is contained in:
Mike Hearn 2011-03-13 21:39:44 +00:00
parent a504328044
commit 845224c8d5
6 changed files with 16 additions and 15 deletions

View File

@ -48,8 +48,8 @@ public class Base58 {
} }
s.insert(0, ALPHABET.charAt(bi.intValue())); s.insert(0, ALPHABET.charAt(bi.intValue()));
// Convert leading zeros too. // Convert leading zeros too.
for (int i = 0; i < input.length; i++) { for (byte anInput : input) {
if (input[i] == 0) if (anInput == 0)
s.insert(0, ALPHABET.charAt(0)); s.insert(0, ALPHABET.charAt(0));
else else
break; break;

View File

@ -52,7 +52,7 @@ public class NetworkConnection {
private final OutputStream out; private final OutputStream out;
private final InputStream in; private final InputStream in;
// The IP address to which we are connecting. // The IP address to which we are connecting.
private InetAddress remoteIp; private final InetAddress remoteIp;
private boolean usesChecksumming; private boolean usesChecksumming;
private final NetworkParameters params; private final NetworkParameters params;
static final private boolean PROTOCOL_LOG = false; static final private boolean PROTOCOL_LOG = false;
@ -82,7 +82,7 @@ public class NetworkConnection {
// And get one back ... // And get one back ...
readMessage(); readMessage();
// Switch to the new protocol version. // Switch to the new protocol version.
int peerVersion = (int) ver.clientVersion; int peerVersion = ver.clientVersion;
LOG("Connected to peer, version is " + peerVersion + ", services=" + Long.toHexString( LOG("Connected to peer, version is " + peerVersion + ", services=" + Long.toHexString(
ver.localServices) + ", time=" + new Date(ver.time.longValue() * 1000).toString()); ver.localServices) + ", time=" + new Date(ver.time.longValue() * 1000).toString());
// BitCoinJ is a client mode implementation. That means there's not much point in us talking to other client // BitCoinJ is a client mode implementation. That means there's not much point in us talking to other client

View File

@ -44,7 +44,7 @@ public class Peer {
private CountDownLatch chainCompletionLatch; private CountDownLatch chainCompletionLatch;
// When we want to download a block or transaction from a peer, the InventoryItem is put here whilst waiting for // When we want to download a block or transaction from a peer, the InventoryItem is put here whilst waiting for
// the response. Synchronized on itself. // the response. Synchronized on itself.
private List<GetDataFuture<Block>> pendingGetBlockFutures; private final List<GetDataFuture<Block>> pendingGetBlockFutures;
/** /**
* Construct a peer that handles the given network connection and reads/writes from the given block chain. Note that * Construct a peer that handles the given network connection and reads/writes from the given block chain. Note that
@ -217,8 +217,8 @@ public class Peer {
// decide whether to wait forever, wait for a short while or check later after doing other work. // decide whether to wait forever, wait for a short while or check later after doing other work.
private class GetDataFuture<T extends Message> implements Future<T> { private class GetDataFuture<T extends Message> implements Future<T> {
private boolean cancelled; private boolean cancelled;
private InventoryItem item; private final InventoryItem item;
private CountDownLatch latch; private final CountDownLatch latch;
private T result; private T result;
GetDataFuture(InventoryItem item) { GetDataFuture(InventoryItem item) {

View File

@ -51,12 +51,12 @@ public class Script {
private int cursor; private int cursor;
// The stack consists of an ordered series of data buffers growing from zero up. // The stack consists of an ordered series of data buffers growing from zero up.
private Stack<byte[]> stack; private final Stack<byte[]> stack;
// The program is a set of byte[]s where each element is either [opcode] or [data, data, data ...] // The program is a set of byte[]s where each element is either [opcode] or [data, data, data ...]
private List<byte[]> chunks; private List<byte[]> chunks;
private boolean tracing; private boolean tracing;
byte[] programCopy; // TODO: remove this byte[] programCopy; // TODO: remove this
private NetworkParameters params; private final NetworkParameters params;
/** Concatenates two scripts to form a new one. This is used when verifying transactions. */ /** Concatenates two scripts to form a new one. This is used when verifying transactions. */
public static Script join(Script a, Script b) throws ScriptException { public static Script join(Script a, Script b) throws ScriptException {
@ -321,6 +321,7 @@ public class Script {
pushBool(true); pushBool(true);
} }
@SuppressWarnings({"SameParameterValue"})
private void pushBool(boolean val) { private void pushBool(boolean val) {
stack.push(new byte[] { val ? (byte)1 : (byte)0 }); stack.push(new byte[] { val ? (byte)1 : (byte)0 });
} }

View File

@ -254,6 +254,7 @@ public class Transaction extends Message implements Serializable {
* @param hashType This should always be set to SigHash.ALL currently. Other types are unused. * @param hashType This should always be set to SigHash.ALL currently. Other types are unused.
* @param wallet A wallet is required to fetch the keys needed for signing. * @param wallet A wallet is required to fetch the keys needed for signing.
*/ */
@SuppressWarnings({"SameParameterValue"})
public void signInputs(SigHash hashType, Wallet wallet) throws ScriptException { public void signInputs(SigHash hashType, Wallet wallet) throws ScriptException {
assert inputs.size() > 0; assert inputs.size() > 0;
assert outputs.size() > 0; assert outputs.size() > 0;

View File

@ -28,13 +28,14 @@ import java.security.NoSuchAlgorithmException;
* A collection of various utility methods that are helpful for working with the BitCoin protocol. * A collection of various utility methods that are helpful for working with the BitCoin protocol.
* To enable debug logging from the library, run with -Dbitcoinj.logging=true on your command line. * To enable debug logging from the library, run with -Dbitcoinj.logging=true on your command line.
*/ */
@SuppressWarnings({"SameParameterValue"})
public class Utils { public class Utils {
/** How many nanocoins there are in a BitCoin. */ /** How many nanocoins there are in a BitCoin. */
public static final BigInteger COIN = new BigInteger("100000000", 10); public static final BigInteger COIN = new BigInteger("100000000", 10);
/** How many nanocoins there are in 0.01 BitCoins. */ /** How many nanocoins there are in 0.01 BitCoins. */
public static final BigInteger CENT = new BigInteger("1000000", 10); public static final BigInteger CENT = new BigInteger("1000000", 10);
private static boolean logging; private static final boolean logging;
static { static {
logging = Boolean.parseBoolean(System.getProperty("bitcoinj.logging", "false")); logging = Boolean.parseBoolean(System.getProperty("bitcoinj.logging", "false"));
@ -98,8 +99,7 @@ public class Utils {
MessageDigest digest = MessageDigest.getInstance("SHA-256"); MessageDigest digest = MessageDigest.getInstance("SHA-256");
digest.update(input, offset, length); digest.update(input, offset, length);
byte[] first = digest.digest(); byte[] first = digest.digest();
byte[] second = digest.digest(first); return digest.digest(first);
return second;
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e); // Cannot happen. throw new RuntimeException(e); // Cannot happen.
} }
@ -115,8 +115,7 @@ public class Utils {
digest.update(input1, offset1, length1); digest.update(input1, offset1, length1);
digest.update(input2, offset2, length2); digest.update(input2, offset2, length2);
byte[] first = digest.digest(); byte[] first = digest.digest();
byte[] second = digest.digest(first); return digest.digest(first);
return second;
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e); // Cannot happen. throw new RuntimeException(e); // Cannot happen.
} }
@ -154,7 +153,7 @@ public class Utils {
return ((bytes[offset++] & 0xFFL) << 0) | return ((bytes[offset++] & 0xFFL) << 0) |
((bytes[offset++] & 0xFFL) << 8) | ((bytes[offset++] & 0xFFL) << 8) |
((bytes[offset++] & 0xFFL) << 16) | ((bytes[offset++] & 0xFFL) << 16) |
((bytes[offset++] & 0xFFL) << 24); ((bytes[offset] & 0xFFL) << 24);
} }
public static long readUint32BE(byte[] bytes, int offset) { public static long readUint32BE(byte[] bytes, int offset) {