mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-07 14:54:15 +00:00
Clear out the remaining non-security related FindBugs warnings.
This commit is contained in:
parent
ddb1679a78
commit
1785f9bb1c
@ -18,6 +18,7 @@ package com.google.bitcoin.core;
|
|||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -78,6 +79,13 @@ public class Block extends Message {
|
|||||||
super(params, payloadBytes, 0);
|
super(params, payloadBytes, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
|
||||||
|
ois.defaultReadObject();
|
||||||
|
// This code is not actually necessary, as transient fields are initialized to the default value which is in
|
||||||
|
// this case null. However it clears out a FindBugs warning and makes it explicit what we're doing.
|
||||||
|
hash = null;
|
||||||
|
}
|
||||||
|
|
||||||
void parse() throws ProtocolException {
|
void parse() throws ProtocolException {
|
||||||
version = readUint32();
|
version = readUint32();
|
||||||
prevBlockHash = readHash();
|
prevBlockHash = readHash();
|
||||||
@ -172,13 +180,13 @@ public class Block extends Message {
|
|||||||
public Block cloneAsHeader() {
|
public Block cloneAsHeader() {
|
||||||
Block block = new Block(params);
|
Block block = new Block(params);
|
||||||
block.nonce = nonce;
|
block.nonce = nonce;
|
||||||
block.prevBlockHash = prevBlockHash.clone();
|
block.prevBlockHash = prevBlockHash.duplicate();
|
||||||
block.merkleRoot = getMerkleRoot().clone();
|
block.merkleRoot = getMerkleRoot().duplicate();
|
||||||
block.version = version;
|
block.version = version;
|
||||||
block.time = time;
|
block.time = time;
|
||||||
block.difficultyTarget = difficultyTarget;
|
block.difficultyTarget = difficultyTarget;
|
||||||
block.transactions = null;
|
block.transactions = null;
|
||||||
block.hash = getHash().clone();
|
block.hash = getHash().duplicate();
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,6 +86,7 @@ public class NetworkParameters implements Serializable {
|
|||||||
t.outputs.add(new TransactionOutput(n, t, scriptPubKeyBytes.toByteArray()));
|
t.outputs.add(new TransactionOutput(n, t, scriptPubKeyBytes.toByteArray()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Cannot happen.
|
// Cannot happen.
|
||||||
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
genesisBlock.addTransaction(t);
|
genesisBlock.addTransaction(t);
|
||||||
return genesisBlock;
|
return genesisBlock;
|
||||||
|
@ -74,8 +74,7 @@ public class Sha256Hash implements Serializable {
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public Sha256Hash duplicate() {
|
||||||
public Sha256Hash clone() {
|
|
||||||
return new Sha256Hash(bytes);
|
return new Sha256Hash(bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,12 +258,15 @@ public class Transaction extends Message implements Serializable {
|
|||||||
s.append(getHashAsString());
|
s.append(getHashAsString());
|
||||||
s.append("\n");
|
s.append("\n");
|
||||||
if (isCoinBase()) {
|
if (isCoinBase()) {
|
||||||
String script = "???";
|
String script;
|
||||||
String script2 = "???";
|
String script2;
|
||||||
try {
|
try {
|
||||||
script = inputs.get(0).getScriptSig().toString();
|
script = inputs.get(0).getScriptSig().toString();
|
||||||
script2 = outputs.get(0).getScriptPubKey().toString();
|
script2 = outputs.get(0).getScriptPubKey().toString();
|
||||||
} catch (ScriptException e) {}
|
} catch (ScriptException e) {
|
||||||
|
script = "???";
|
||||||
|
script2 = "???";
|
||||||
|
}
|
||||||
return " == COINBASE TXN (scriptSig " + script + ") (scriptPubKey " + script2 + ")";
|
return " == COINBASE TXN (scriptSig " + script + ") (scriptPubKey " + script2 + ")";
|
||||||
}
|
}
|
||||||
for (TransactionInput in : inputs) {
|
for (TransactionInput in : inputs) {
|
||||||
|
@ -75,7 +75,9 @@ public class DiskBlockStore implements BlockStore {
|
|||||||
|
|
||||||
private void load(File file) throws IOException, BlockStoreException {
|
private void load(File file) throws IOException, BlockStoreException {
|
||||||
log.info("Reading block store from {}", file);
|
log.info("Reading block store from {}", file);
|
||||||
InputStream input = new BufferedInputStream(new FileInputStream(file));
|
InputStream input = null;
|
||||||
|
try {
|
||||||
|
input = new BufferedInputStream(new FileInputStream(file));
|
||||||
// Read a version byte.
|
// Read a version byte.
|
||||||
int version = input.read();
|
int version = input.read();
|
||||||
if (version == -1) {
|
if (version == -1) {
|
||||||
@ -87,7 +89,8 @@ public class DiskBlockStore implements BlockStore {
|
|||||||
}
|
}
|
||||||
// Chain head pointer is the first thing in the file.
|
// Chain head pointer is the first thing in the file.
|
||||||
byte[] chainHeadHash = new byte[32];
|
byte[] chainHeadHash = new byte[32];
|
||||||
input.read(chainHeadHash);
|
if (input.read(chainHeadHash) < chainHeadHash.length)
|
||||||
|
throw new BlockStoreException("Truncated block store: cannot read chain head hash");
|
||||||
this.chainHead = new Sha256Hash(chainHeadHash);
|
this.chainHead = new Sha256Hash(chainHeadHash);
|
||||||
log.info("Read chain head from disk: {}", this.chainHead);
|
log.info("Read chain head from disk: {}", this.chainHead);
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
@ -131,6 +134,9 @@ public class DiskBlockStore implements BlockStore {
|
|||||||
}
|
}
|
||||||
long elapsed = System.currentTimeMillis() - now;
|
long elapsed = System.currentTimeMillis() - now;
|
||||||
log.info("Block chain read complete in {}ms", elapsed);
|
log.info("Block chain read complete in {}ms", elapsed);
|
||||||
|
} finally {
|
||||||
|
if (input != null) input.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void put(StoredBlock block) throws BlockStoreException {
|
public synchronized void put(StoredBlock block) throws BlockStoreException {
|
||||||
|
Loading…
Reference in New Issue
Block a user