mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-01-31 15:22:16 +00:00
Better use of annotations in Block
This commit is contained in:
parent
e4a5c6bbc9
commit
e3bcb49c4c
@ -24,6 +24,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
@ -984,7 +985,8 @@ public class Block extends Message {
|
||||
* Returns a solved block that builds on top of this one. This exists for unit tests.
|
||||
* In this variant you can specify a public key (pubkey) for use in generating coinbase blocks.
|
||||
*/
|
||||
Block createNextBlock(Address to, TransactionOutPoint prevOut, long time, byte[] pubKey, BigInteger coinbaseValue) {
|
||||
Block createNextBlock(@Nullable Address to, @Nullable TransactionOutPoint prevOut, long time,
|
||||
byte[] pubKey, BigInteger coinbaseValue) {
|
||||
Block b = new Block(params);
|
||||
b.setDifficultyTarget(difficultyTarget);
|
||||
b.addCoinbaseTransaction(pubKey, coinbaseValue);
|
||||
@ -1025,21 +1027,22 @@ public class Block extends Message {
|
||||
return b;
|
||||
}
|
||||
|
||||
// Visible for testing.
|
||||
public Block createNextBlock(Address to, TransactionOutPoint prevOut) {
|
||||
@VisibleForTesting
|
||||
public Block createNextBlock(@Nullable Address to, TransactionOutPoint prevOut) {
|
||||
return createNextBlock(to, prevOut, Utils.now().getTime() / 1000, EMPTY_BYTES, Utils.toNanoCoins(50, 0));
|
||||
}
|
||||
|
||||
// Visible for testing.
|
||||
public Block createNextBlock(Address to, BigInteger value) {
|
||||
@VisibleForTesting
|
||||
public Block createNextBlock(@Nullable Address to, BigInteger value) {
|
||||
return createNextBlock(to, null, Utils.now().getTime() / 1000, EMPTY_BYTES, value);
|
||||
}
|
||||
|
||||
public Block createNextBlock(Address to) {
|
||||
@VisibleForTesting
|
||||
public Block createNextBlock(@Nullable Address to) {
|
||||
return createNextBlock(to, Utils.toNanoCoins(50, 0));
|
||||
}
|
||||
|
||||
// Visible for testing.
|
||||
@VisibleForTesting
|
||||
public Block createNextBlockWithCoinbase(byte[] pubKey, BigInteger coinbaseValue) {
|
||||
return createNextBlock(null, null, Utils.now().getTime() / 1000, pubKey, coinbaseValue);
|
||||
}
|
||||
@ -1048,44 +1051,28 @@ public class Block extends Message {
|
||||
* Create a block sending 50BTC as a coinbase transaction to the public key specified.
|
||||
* This method is intended for test use only.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
Block createNextBlockWithCoinbase(byte[] pubKey) {
|
||||
return createNextBlock(null, null, Utils.now().getTime() / 1000, pubKey, Utils.toNanoCoins(50, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for unit test
|
||||
*
|
||||
* @return the headerParsed
|
||||
*/
|
||||
@VisibleForTesting
|
||||
boolean isParsedHeader() {
|
||||
return headerParsed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for unit test
|
||||
*
|
||||
* @return the transactionsParsed
|
||||
*/
|
||||
@VisibleForTesting
|
||||
boolean isParsedTransactions() {
|
||||
return transactionsParsed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for unit test
|
||||
*
|
||||
* @return the headerBytesValid
|
||||
*/
|
||||
@VisibleForTesting
|
||||
boolean isHeaderBytesValid() {
|
||||
return headerBytesValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for unit test
|
||||
*
|
||||
* @return the transactionBytesValid
|
||||
*/
|
||||
@VisibleForTesting
|
||||
boolean isTransactionBytesValid() {
|
||||
return transactionBytesValid;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user