forked from Qortal/qortal
Re-ordered chat transaction transformation, to simplify UI code. New additions are now at the end of the data bytes.
This commit is contained in:
parent
910191b074
commit
a4759a0ef4
@ -29,7 +29,7 @@ public class ChatTransactionTransformer extends TransactionTransformer {
|
|||||||
private static final int IS_TEXT_LENGTH = BOOLEAN_LENGTH;
|
private static final int IS_TEXT_LENGTH = BOOLEAN_LENGTH;
|
||||||
private static final int IS_ENCRYPTED_LENGTH = BOOLEAN_LENGTH;
|
private static final int IS_ENCRYPTED_LENGTH = BOOLEAN_LENGTH;
|
||||||
|
|
||||||
private static final int EXTRAS_LENGTH = NONCE_LENGTH + HAS_RECIPIENT_LENGTH + HAS_CHAT_REFERENCE_LENGTH + DATA_SIZE_LENGTH + IS_ENCRYPTED_LENGTH + IS_TEXT_LENGTH;
|
private static final int EXTRAS_LENGTH = NONCE_LENGTH + HAS_RECIPIENT_LENGTH + DATA_SIZE_LENGTH + IS_ENCRYPTED_LENGTH + IS_TEXT_LENGTH + HAS_CHAT_REFERENCE_LENGTH;
|
||||||
|
|
||||||
protected static final TransactionLayout layout;
|
protected static final TransactionLayout layout;
|
||||||
|
|
||||||
@ -66,17 +66,6 @@ public class ChatTransactionTransformer extends TransactionTransformer {
|
|||||||
boolean hasRecipient = byteBuffer.get() != 0;
|
boolean hasRecipient = byteBuffer.get() != 0;
|
||||||
String recipient = hasRecipient ? Serialization.deserializeAddress(byteBuffer) : null;
|
String recipient = hasRecipient ? Serialization.deserializeAddress(byteBuffer) : null;
|
||||||
|
|
||||||
byte[] chatReference = null;
|
|
||||||
|
|
||||||
if (timestamp >= BlockChain.getInstance().getChatReferenceTimestamp()) {
|
|
||||||
boolean hasChatReference = byteBuffer.get() != 0;
|
|
||||||
|
|
||||||
if (hasChatReference) {
|
|
||||||
chatReference = new byte[CHAT_REFERENCE_LENGTH];
|
|
||||||
byteBuffer.get(chatReference);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int dataSize = byteBuffer.getInt();
|
int dataSize = byteBuffer.getInt();
|
||||||
// Don't allow invalid dataSize here to avoid run-time issues
|
// Don't allow invalid dataSize here to avoid run-time issues
|
||||||
if (dataSize > ChatTransaction.MAX_DATA_SIZE)
|
if (dataSize > ChatTransaction.MAX_DATA_SIZE)
|
||||||
@ -91,6 +80,17 @@ public class ChatTransactionTransformer extends TransactionTransformer {
|
|||||||
|
|
||||||
long fee = byteBuffer.getLong();
|
long fee = byteBuffer.getLong();
|
||||||
|
|
||||||
|
byte[] chatReference = null;
|
||||||
|
|
||||||
|
if (timestamp >= BlockChain.getInstance().getChatReferenceTimestamp()) {
|
||||||
|
boolean hasChatReference = byteBuffer.get() != 0;
|
||||||
|
|
||||||
|
if (hasChatReference) {
|
||||||
|
chatReference = new byte[CHAT_REFERENCE_LENGTH];
|
||||||
|
byteBuffer.get(chatReference);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
byte[] signature = new byte[SIGNATURE_LENGTH];
|
byte[] signature = new byte[SIGNATURE_LENGTH];
|
||||||
byteBuffer.get(signature);
|
byteBuffer.get(signature);
|
||||||
|
|
||||||
@ -131,16 +131,6 @@ public class ChatTransactionTransformer extends TransactionTransformer {
|
|||||||
bytes.write((byte) 0);
|
bytes.write((byte) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transactionData.getTimestamp() >= BlockChain.getInstance().getChatReferenceTimestamp()) {
|
|
||||||
// Include chat reference if it's not null
|
|
||||||
if (chatTransactionData.getChatReference() != null) {
|
|
||||||
bytes.write((byte) 1);
|
|
||||||
bytes.write(chatTransactionData.getChatReference());
|
|
||||||
} else {
|
|
||||||
bytes.write((byte) 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bytes.write(Ints.toByteArray(chatTransactionData.getData().length));
|
bytes.write(Ints.toByteArray(chatTransactionData.getData().length));
|
||||||
|
|
||||||
bytes.write(chatTransactionData.getData());
|
bytes.write(chatTransactionData.getData());
|
||||||
@ -151,6 +141,16 @@ public class ChatTransactionTransformer extends TransactionTransformer {
|
|||||||
|
|
||||||
bytes.write(Longs.toByteArray(chatTransactionData.getFee()));
|
bytes.write(Longs.toByteArray(chatTransactionData.getFee()));
|
||||||
|
|
||||||
|
if (transactionData.getTimestamp() >= BlockChain.getInstance().getChatReferenceTimestamp()) {
|
||||||
|
// Include chat reference if it's not null
|
||||||
|
if (chatTransactionData.getChatReference() != null) {
|
||||||
|
bytes.write((byte) 1);
|
||||||
|
bytes.write(chatTransactionData.getChatReference());
|
||||||
|
} else {
|
||||||
|
bytes.write((byte) 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (chatTransactionData.getSignature() != null)
|
if (chatTransactionData.getSignature() != null)
|
||||||
bytes.write(chatTransactionData.getSignature());
|
bytes.write(chatTransactionData.getSignature());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user