forked from Qortal/qortal
Moved proof of work difficulty definition from ArbitraryTransaction to ArbitraryDataManager
This commit is contained in:
parent
302428f1d1
commit
2452d3c24b
@ -32,6 +32,10 @@ public class ArbitraryDataManager extends Thread {
|
||||
private static final Logger LOGGER = LogManager.getLogger(ArbitraryDataManager.class);
|
||||
private static final List<TransactionType> ARBITRARY_TX_TYPE = Arrays.asList(TransactionType.ARBITRARY);
|
||||
|
||||
/** Difficulty (leading zero bits) used in arbitrary data transactions
|
||||
* Set here so that it can be more easily reduced when running unit tests */
|
||||
private int powDifficulty = 12; // Must not be final, as unit tests need to reduce this value
|
||||
|
||||
/** Request timeout when transferring arbitrary data */
|
||||
public static final long ARBITRARY_REQUEST_TIMEOUT = 6 * 1000L; // ms
|
||||
|
||||
@ -415,4 +419,9 @@ public class ArbitraryDataManager extends Thread {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int getPowDifficulty() {
|
||||
return this.powDifficulty;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ public class ArbitraryTransaction extends Transaction {
|
||||
public static final int MAX_METADATA_LENGTH = 32;
|
||||
public static final int HASH_LENGTH = TransactionTransformer.SHA256_LENGTH;
|
||||
public static final int POW_BUFFER_SIZE = 8 * 1024 * 1024; // bytes
|
||||
public static final int POW_DIFFICULTY = 12; // leading zero bits
|
||||
public static final int MAX_IDENTIFIER_LENGTH = 64;
|
||||
|
||||
// Constructors
|
||||
@ -75,7 +74,8 @@ public class ArbitraryTransaction extends Transaction {
|
||||
ArbitraryTransactionTransformer.clearNonce(transactionBytes);
|
||||
|
||||
// Calculate nonce
|
||||
this.arbitraryTransactionData.setNonce(MemoryPoW.compute2(transactionBytes, POW_BUFFER_SIZE, POW_DIFFICULTY));
|
||||
int difficulty = ArbitraryDataManager.getInstance().getPowDifficulty();
|
||||
this.arbitraryTransactionData.setNonce(MemoryPoW.compute2(transactionBytes, POW_BUFFER_SIZE, difficulty));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -196,7 +196,8 @@ public class ArbitraryTransaction extends Transaction {
|
||||
ArbitraryTransactionTransformer.clearNonce(transactionBytes);
|
||||
|
||||
// Check nonce
|
||||
return MemoryPoW.verify2(transactionBytes, POW_BUFFER_SIZE, POW_DIFFICULTY, nonce);
|
||||
int difficulty = ArbitraryDataManager.getInstance().getPowDifficulty();
|
||||
return MemoryPoW.verify2(transactionBytes, POW_BUFFER_SIZE, difficulty, nonce);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user