Skip to content

Commit

Permalink
Use default values for method and compression if not specified.
Browse files Browse the repository at this point in the history
Should fix issue with v4 transactions where these aren't used. Matches with the NOT NULL DEFAULT 0 which automatically transitions existing v4 ARBITRARY transactions to use the same defaults.
  • Loading branch information
archived-2 committed Jan 13, 2022
1 parent 1277ce3 commit 119c1b4
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,19 @@ public void save(TransactionData transactionData) throws DataException {
if (arbitraryTransactionData.getVersion() >= 4)
this.repository.getArbitraryRepository().save(arbitraryTransactionData);

// method and compression use NOT NULL DEFAULT 0, so fall back to these values if null
Integer method = arbitraryTransactionData.getMethod() != null ? arbitraryTransactionData.getMethod().value : 0;
Integer compression = arbitraryTransactionData.getCompression() != null ? arbitraryTransactionData.getCompression().value : 0;

HSQLDBSaver saveHelper = new HSQLDBSaver("ArbitraryTransactions");

saveHelper.bind("signature", arbitraryTransactionData.getSignature()).bind("sender", arbitraryTransactionData.getSenderPublicKey())
.bind("version", arbitraryTransactionData.getVersion()).bind("service", arbitraryTransactionData.getService().value)
.bind("nonce", arbitraryTransactionData.getNonce()).bind("size", arbitraryTransactionData.getSize())
.bind("is_data_raw", arbitraryTransactionData.getDataType() == DataType.RAW_DATA).bind("data", arbitraryTransactionData.getData())
.bind("metadata_hash", arbitraryTransactionData.getMetadataHash()).bind("name", arbitraryTransactionData.getName())
.bind("identifier", arbitraryTransactionData.getIdentifier()).bind("update_method", arbitraryTransactionData.getMethod().value)
.bind("secret", arbitraryTransactionData.getSecret()).bind("compression", arbitraryTransactionData.getCompression().value);
.bind("identifier", arbitraryTransactionData.getIdentifier()).bind("update_method", method)
.bind("secret", arbitraryTransactionData.getSecret()).bind("compression", compression);

try {
saveHelper.execute(this.repository);
Expand Down

0 comments on commit 119c1b4

Please sign in to comment.