mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-12 02:05:53 +00:00
Let calls to Block.addTransaction override sanity checks in testing
This commit is contained in:
parent
dd47862829
commit
2bfe8dfa25
@ -776,14 +776,19 @@ public class Block extends Message {
|
|||||||
|
|
||||||
/** Adds a transaction to this block. The nonce and merkle root are invalid after this. */
|
/** Adds a transaction to this block. The nonce and merkle root are invalid after this. */
|
||||||
public void addTransaction(Transaction t) {
|
public void addTransaction(Transaction t) {
|
||||||
|
addTransaction(t, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Adds a transaction to this block, with or without checking the sanity of doing so */
|
||||||
|
void addTransaction(Transaction t, boolean runSanityChecks) {
|
||||||
unCacheTransactions();
|
unCacheTransactions();
|
||||||
if (transactions == null) {
|
if (transactions == null) {
|
||||||
transactions = new ArrayList<Transaction>();
|
transactions = new ArrayList<Transaction>();
|
||||||
}
|
}
|
||||||
t.setParent(this);
|
t.setParent(this);
|
||||||
if (transactions.size() == 0 && !t.isCoinBase())
|
if (runSanityChecks && transactions.size() == 0 && !t.isCoinBase())
|
||||||
throw new RuntimeException("Attempted to add a non-coinbase transaction as the first transaction: " + t);
|
throw new RuntimeException("Attempted to add a non-coinbase transaction as the first transaction: " + t);
|
||||||
else if (transactions.size() > 0 && t.isCoinBase())
|
else if (runSanityChecks && transactions.size() > 0 && t.isCoinBase())
|
||||||
throw new RuntimeException("Attempted to add a coinbase transaction when there already is one: " + t);
|
throw new RuntimeException("Attempted to add a coinbase transaction when there already is one: " + t);
|
||||||
transactions.add(t);
|
transactions.add(t);
|
||||||
adjustLength(transactions.size(), t.length);
|
adjustLength(transactions.size(), t.length);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user