mirror of
https://github.com/Qortal/qortal.git
synced 2025-07-23 04:36:50 +00:00
Another significant upgrade of arbitrary transactions
Adds "name", "method", "secret", and "compression" properties. These are the foundations needed in order to handle updates, encryption, and name registration. Compression has been added so that we have the option of switching to different algorithms whilst maintaining support for existing transactions.
This commit is contained in:
@@ -36,10 +36,14 @@ public class ArbitraryTransactionTests extends Common {
|
||||
|
||||
TestAccount alice = Common.getTestAccount(repository, "alice");
|
||||
ArbitraryTransactionData.DataType dataType = ArbitraryTransactionData.DataType.DATA_HASH;
|
||||
ArbitraryTransactionData.Service service = ArbitraryTransactionData.Service.ARBITRARY_DATA;
|
||||
ArbitraryTransactionData.Method method = ArbitraryTransactionData.Method.PUT;
|
||||
ArbitraryTransactionData.Compression compression = ArbitraryTransactionData.Compression.NONE;
|
||||
List<PaymentData> payments = new ArrayList<>();
|
||||
|
||||
ArbitraryTransactionData transactionData = new ArbitraryTransactionData(TestTransaction.generateBase(alice),
|
||||
5, ArbitraryTransaction.SERVICE_ARBITRARY_DATA, 0, 0, null, dataType, null, payments);
|
||||
5, service, 0, 0, null, method,
|
||||
null, compression, null, dataType, null, payments);
|
||||
|
||||
ArbitraryTransaction transaction = (ArbitraryTransaction) Transaction.fromData(repository, transactionData);
|
||||
assertEquals(12, transaction.difficultyForFileSize(1));
|
||||
|
@@ -17,9 +17,13 @@ public class ArbitraryTestTransaction extends TestTransaction {
|
||||
|
||||
public static TransactionData randomTransaction(Repository repository, PrivateKeyAccount account, boolean wantValid) throws DataException {
|
||||
final int version = 4;
|
||||
final int service = 123;
|
||||
final ArbitraryTransactionData.Service service = ArbitraryTransactionData.Service.ARBITRARY_DATA;
|
||||
final int nonce = 0; // Version 4 doesn't need a nonce
|
||||
final int size = 0; // Version 4 doesn't need a size
|
||||
final String name = null; // Version 4 doesn't need a name
|
||||
final ArbitraryTransactionData.Method method = ArbitraryTransactionData.Method.PUT; // Version 4 doesn't need a method
|
||||
final byte[] secret = null; // Version 4 doesn't need a secret
|
||||
final ArbitraryTransactionData.Compression compression = ArbitraryTransactionData.Compression.NONE; // Version 4 doesn't use compression
|
||||
final byte[] chunkHashes = null; // Version 4 doesn't use chunk hashes
|
||||
|
||||
byte[] data = new byte[1024];
|
||||
@@ -34,7 +38,8 @@ public class ArbitraryTestTransaction extends TestTransaction {
|
||||
List<PaymentData> payments = new ArrayList<>();
|
||||
payments.add(new PaymentData(recipient, assetId, amount));
|
||||
|
||||
return new ArbitraryTransactionData(generateBase(account), version, service, nonce, size, data, dataType, chunkHashes, payments);
|
||||
return new ArbitraryTransactionData(generateBase(account), version, service, nonce, size, name, method,
|
||||
secret, compression, data, dataType, chunkHashes, payments);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user