forked from Qortal/qortal
Interim commit - refactored HSQLDBTransactionRepository, and subclasses. Also added approval_height to transactions, renaming height to block_height.
This commit is contained in:
parent
431e15c7ae
commit
06ba004238
@ -1115,7 +1115,7 @@ public class Block {
|
||||
this.repository.getBlockRepository().save(blockTransactionData);
|
||||
|
||||
// Update transaction's height in repository
|
||||
this.repository.getTransactionRepository().updateHeight(transaction.getTransactionData().getSignature(), this.blockData.getHeight());
|
||||
this.repository.getTransactionRepository().updateBlockHeight(transaction.getTransactionData().getSignature(), this.blockData.getHeight());
|
||||
// Update local transactionData's height too
|
||||
transaction.getTransactionData().setBlockHeight(this.blockData.getHeight());
|
||||
|
||||
|
@ -164,7 +164,9 @@ public interface TransactionRepository {
|
||||
*/
|
||||
public void confirmTransaction(byte[] signature) throws DataException;
|
||||
|
||||
public void updateHeight(byte[] signature, Integer height) throws DataException;
|
||||
public void updateBlockHeight(byte[] signature, Integer height) throws DataException;
|
||||
|
||||
public void updateApprovalHeight(byte[] signature, Integer approvalHeight) throws DataException;
|
||||
|
||||
/**
|
||||
* Add transaction to unconfirmed transactions pile.
|
||||
|
@ -739,9 +739,9 @@ public class HSQLDBDatabaseUpdates {
|
||||
|
||||
case 50:
|
||||
// Cached block height in Transactions to save loads of JOINs
|
||||
stmt.execute("ALTER TABLE Transactions ADD COLUMN height INT");
|
||||
stmt.execute("ALTER TABLE Transactions ADD COLUMN block_height INT");
|
||||
// Add height-based index
|
||||
stmt.execute("CREATE INDEX TransactionHeightIndex on Transactions (height)");
|
||||
stmt.execute("CREATE INDEX TransactionHeightIndex on Transactions (block_height)");
|
||||
break;
|
||||
|
||||
case 51:
|
||||
@ -750,8 +750,12 @@ public class HSQLDBDatabaseUpdates {
|
||||
stmt.execute("CREATE INDEX GroupApprovalLatestIndex on GroupApprovalTransactions (pending_signature, admin)");
|
||||
// Transaction's approval status (Java enum) stored as tiny integer for efficiency
|
||||
stmt.execute("ALTER TABLE Transactions ADD COLUMN approval_status TINYINT NOT NULL");
|
||||
// For search transactions based on approval status
|
||||
stmt.execute("CREATE INDEX TransactionApprovalStatusIndex on Transactions (approval_status, height)");
|
||||
// For searching transactions based on approval status
|
||||
stmt.execute("CREATE INDEX TransactionApprovalStatusIndex on Transactions (approval_status, block_height)");
|
||||
// Height when/if transaction is finally approved
|
||||
stmt.execute("ALTER TABLE Transactions ADD COLUMN approval_height INT");
|
||||
// For searching transactions based on approval height
|
||||
stmt.execute("CREATE INDEX TransactionApprovalHeightIndex on Transactions (approval_height)");
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -1,15 +1,14 @@
|
||||
package org.qora.repository.hsqldb.transaction;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.AccountFlagsTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBAccountFlagsTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,9 +16,10 @@ public class HSQLDBAccountFlagsTransactionRepository extends HSQLDBTransactionRe
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository
|
||||
.checkedExecute("SELECT target, and_mask, or_mask, xor_mask, previous_flags FROM AccountFlagsTransactions WHERE signature = ?", signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT target, and_mask, or_mask, xor_mask, previous_flags FROM AccountFlagsTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -29,11 +29,10 @@ public class HSQLDBAccountFlagsTransactionRepository extends HSQLDBTransactionRe
|
||||
int xorMask = resultSet.getInt(4);
|
||||
|
||||
Integer previousFlags = resultSet.getInt(5);
|
||||
if (resultSet.wasNull())
|
||||
if (previousFlags == 0 && resultSet.wasNull())
|
||||
previousFlags = null;
|
||||
|
||||
return new AccountFlagsTransactionData(timestamp, txGroupId, reference, creatorPublicKey, target, andMask, orMask, xorMask, previousFlags,
|
||||
fee, approvalStatus, height, signature);
|
||||
return new AccountFlagsTransactionData(baseTransactionData, target, andMask, orMask, xorMask, previousFlags);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch account flags transaction from repository", e);
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package org.qora.repository.hsqldb.transaction;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.AddGroupAdminTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBAddGroupAdminTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,15 +16,17 @@ public class HSQLDBAddGroupAdminTransactionRepository extends HSQLDBTransactionR
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute("SELECT group_id, address FROM AddGroupAdminTransactions WHERE signature = ?", signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT group_id, address FROM AddGroupAdminTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
int groupId = resultSet.getInt(1);
|
||||
String member = resultSet.getString(2);
|
||||
|
||||
return new AddGroupAdminTransactionData(timestamp, txGroupId, reference, creatorPublicKey, groupId, member, fee, approvalStatus, height, signature);
|
||||
return new AddGroupAdminTransactionData(baseTransactionData, groupId, member);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch add group admin transaction from repository", e);
|
||||
}
|
||||
|
@ -1,18 +1,17 @@
|
||||
package org.qora.repository.hsqldb.transaction;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.qora.data.PaymentData;
|
||||
import org.qora.data.transaction.ArbitraryTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.data.transaction.ArbitraryTransactionData.DataType;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBArbitraryTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -20,9 +19,10 @@ public class HSQLDBArbitraryTransactionRepository extends HSQLDBTransactionRepos
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute("SELECT version, service, data_hash from ArbitraryTransactions WHERE signature = ?",
|
||||
signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT version, service, data_hash from ArbitraryTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -30,10 +30,9 @@ public class HSQLDBArbitraryTransactionRepository extends HSQLDBTransactionRepos
|
||||
int service = resultSet.getInt(2);
|
||||
byte[] dataHash = resultSet.getBytes(3);
|
||||
|
||||
List<PaymentData> payments = this.getPaymentsFromSignature(signature);
|
||||
List<PaymentData> payments = this.getPaymentsFromSignature(baseTransactionData.getSignature());
|
||||
|
||||
return new ArbitraryTransactionData(timestamp, txGroupId, reference, creatorPublicKey, version, service, dataHash, DataType.DATA_HASH, payments,
|
||||
fee, approvalStatus, height, signature);
|
||||
return new ArbitraryTransactionData(baseTransactionData, version, service, dataHash, DataType.DATA_HASH, payments);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch arbitrary transaction from repository", e);
|
||||
}
|
||||
|
@ -5,11 +5,11 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.ATTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBAtTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,9 +17,10 @@ public class HSQLDBAtTransactionRepository extends HSQLDBTransactionRepository {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository
|
||||
.checkedExecute("SELECT AT_address, recipient, amount, asset_id, message FROM ATTransactions WHERE signature = ?", signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT AT_address, recipient, amount, asset_id, message FROM ATTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -27,18 +28,14 @@ public class HSQLDBAtTransactionRepository extends HSQLDBTransactionRepository {
|
||||
String recipient = resultSet.getString(2);
|
||||
|
||||
BigDecimal amount = resultSet.getBigDecimal(3);
|
||||
if (resultSet.wasNull())
|
||||
amount = null;
|
||||
|
||||
Long assetId = resultSet.getLong(4);
|
||||
if (resultSet.wasNull())
|
||||
if (assetId == 0 && resultSet.wasNull())
|
||||
assetId = null;
|
||||
|
||||
byte[] message = resultSet.getBytes(5);
|
||||
if (resultSet.wasNull())
|
||||
message = null;
|
||||
|
||||
return new ATTransactionData(timestamp, txGroupId, reference, atAddress, recipient, amount, assetId, message, fee, approvalStatus, height, signature);
|
||||
return new ATTransactionData(baseTransactionData, atAddress, recipient, amount, assetId, message);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch AT transaction from repository", e);
|
||||
}
|
||||
|
@ -5,11 +5,11 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.BuyNameTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBBuyNameTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,9 +17,10 @@ public class HSQLDBBuyNameTransactionRepository extends HSQLDBTransactionReposit
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute("SELECT name, amount, seller, name_reference FROM BuyNameTransactions WHERE signature = ?",
|
||||
signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT name, amount, seller, name_reference FROM BuyNameTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -28,7 +29,7 @@ public class HSQLDBBuyNameTransactionRepository extends HSQLDBTransactionReposit
|
||||
String seller = resultSet.getString(3);
|
||||
byte[] nameReference = resultSet.getBytes(4);
|
||||
|
||||
return new BuyNameTransactionData(timestamp, txGroupId, reference, creatorPublicKey, name, amount, seller, nameReference, fee, approvalStatus, height, signature);
|
||||
return new BuyNameTransactionData(baseTransactionData, name, amount, seller, nameReference);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch buy name transaction from repository", e);
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package org.qora.repository.hsqldb.transaction;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.CancelAssetOrderTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBCancelAssetOrderTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,14 +16,16 @@ public class HSQLDBCancelAssetOrderTransactionRepository extends HSQLDBTransacti
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute("SELECT asset_order_id FROM CancelAssetOrderTransactions WHERE signature = ?", signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT asset_order_id FROM CancelAssetOrderTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
byte[] assetOrderId = resultSet.getBytes(1);
|
||||
|
||||
return new CancelAssetOrderTransactionData(timestamp, txGroupId, reference, creatorPublicKey, assetOrderId, fee, approvalStatus, height, signature);
|
||||
return new CancelAssetOrderTransactionData(baseTransactionData, assetOrderId);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch cancel order transaction from repository", e);
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package org.qora.repository.hsqldb.transaction;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.CancelGroupBanTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBCancelGroupBanTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,9 +16,10 @@ public class HSQLDBCancelGroupBanTransactionRepository extends HSQLDBTransaction
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute("SELECT group_id, address, ban_reference FROM CancelGroupBanTransactions WHERE signature = ?",
|
||||
signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT group_id, address, ban_reference FROM CancelGroupBanTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -27,7 +27,7 @@ public class HSQLDBCancelGroupBanTransactionRepository extends HSQLDBTransaction
|
||||
String member = resultSet.getString(2);
|
||||
byte[] banReference = resultSet.getBytes(3);
|
||||
|
||||
return new CancelGroupBanTransactionData(timestamp, txGroupId, reference, creatorPublicKey, groupId, member, banReference, fee, approvalStatus, height, signature);
|
||||
return new CancelGroupBanTransactionData(baseTransactionData, groupId, member, banReference);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch group unban transaction from repository", e);
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package org.qora.repository.hsqldb.transaction;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.CancelGroupInviteTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBCancelGroupInviteTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,9 +16,10 @@ public class HSQLDBCancelGroupInviteTransactionRepository extends HSQLDBTransact
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository
|
||||
.checkedExecute("SELECT group_id, invitee, invite_reference FROM CancelGroupInviteTransactions WHERE signature = ?", signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT group_id, invitee, invite_reference FROM CancelGroupInviteTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -27,7 +27,7 @@ public class HSQLDBCancelGroupInviteTransactionRepository extends HSQLDBTransact
|
||||
String invitee = resultSet.getString(2);
|
||||
byte[] inviteReference = resultSet.getBytes(3);
|
||||
|
||||
return new CancelGroupInviteTransactionData(timestamp, txGroupId, reference, creatorPublicKey, groupId, invitee, inviteReference, fee, approvalStatus, height, signature);
|
||||
return new CancelGroupInviteTransactionData(baseTransactionData, groupId, invitee, inviteReference);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch cancel group invite transaction from repository", e);
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package org.qora.repository.hsqldb.transaction;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.CancelSellNameTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBCancelSellNameTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,14 +16,16 @@ public class HSQLDBCancelSellNameTransactionRepository extends HSQLDBTransaction
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute("SELECT name FROM CancelSellNameTransactions WHERE signature = ?", signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT name FROM CancelSellNameTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
String name = resultSet.getString(1);
|
||||
|
||||
return new CancelSellNameTransactionData(timestamp, txGroupId, reference, creatorPublicKey, name, fee, approvalStatus, height, signature);
|
||||
return new CancelSellNameTransactionData(baseTransactionData, name);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch cancel sell name transaction from repository", e);
|
||||
}
|
||||
|
@ -5,11 +5,11 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.CreateAssetOrderTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBCreateAssetOrderTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,14 +17,14 @@ public class HSQLDBCreateAssetOrderTransactionRepository extends HSQLDBTransacti
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
String sql = "SELECT have_asset_id, amount, want_asset_id, price, HaveAsset.asset_name, WantAsset.asset_name "
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT have_asset_id, amount, want_asset_id, price, HaveAsset.asset_name, WantAsset.asset_name "
|
||||
+ "FROM CreateAssetOrderTransactions "
|
||||
+ "JOIN Assets AS HaveAsset ON HaveAsset.asset_id = have_asset_id "
|
||||
+ "JOIN Assets AS WantAsset ON WantAsset.asset_id = want_asset_id "
|
||||
+ "WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, signature)) {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -35,8 +35,7 @@ public class HSQLDBCreateAssetOrderTransactionRepository extends HSQLDBTransacti
|
||||
String haveAssetName = resultSet.getString(5);
|
||||
String wantAssetName = resultSet.getString(6);
|
||||
|
||||
return new CreateAssetOrderTransactionData(timestamp, txGroupId, reference, creatorPublicKey, haveAssetId, wantAssetId, amount, price, fee,
|
||||
haveAssetName, wantAssetName, approvalStatus, height, signature);
|
||||
return new CreateAssetOrderTransactionData(baseTransactionData, haveAssetId, wantAssetId, amount, price, haveAssetName, wantAssetName);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch create order transaction from repository", e);
|
||||
}
|
||||
|
@ -1,16 +1,15 @@
|
||||
package org.qora.repository.hsqldb.transaction;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.CreateGroupTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.group.Group.ApprovalThreshold;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBCreateGroupTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -18,10 +17,10 @@ public class HSQLDBCreateGroupTransactionRepository extends HSQLDBTransactionRep
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(
|
||||
"SELECT owner, group_name, description, is_open, approval_threshold, min_block_delay, max_block_delay, group_id FROM CreateGroupTransactions WHERE signature = ?",
|
||||
signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT owner, group_name, description, is_open, approval_threshold, min_block_delay, max_block_delay, group_id FROM CreateGroupTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -36,11 +35,11 @@ public class HSQLDBCreateGroupTransactionRepository extends HSQLDBTransactionRep
|
||||
int maxBlockDelay = resultSet.getInt(7);
|
||||
|
||||
Integer groupId = resultSet.getInt(8);
|
||||
if (resultSet.wasNull())
|
||||
if (groupId == 0 && resultSet.wasNull())
|
||||
groupId = null;
|
||||
|
||||
return new CreateGroupTransactionData(timestamp, txGroupId, reference, creatorPublicKey, owner, groupName, description, isOpen, approvalThreshold,
|
||||
minBlockDelay, maxBlockDelay, groupId, fee, approvalStatus, height, signature);
|
||||
return new CreateGroupTransactionData(baseTransactionData, owner, groupName, description, isOpen, approvalThreshold,
|
||||
minBlockDelay, maxBlockDelay, groupId);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch create group transaction from repository", e);
|
||||
}
|
||||
|
@ -1,18 +1,17 @@
|
||||
package org.qora.repository.hsqldb.transaction;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.qora.data.transaction.CreatePollTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.data.voting.PollOptionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBCreatePollTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -20,9 +19,10 @@ public class HSQLDBCreatePollTransactionRepository extends HSQLDBTransactionRepo
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute("SELECT owner, poll_name, description FROM CreatePollTransactions WHERE signature = ?",
|
||||
signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT owner, poll_name, description FROM CreatePollTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -30,8 +30,9 @@ public class HSQLDBCreatePollTransactionRepository extends HSQLDBTransactionRepo
|
||||
String pollName = resultSet.getString(2);
|
||||
String description = resultSet.getString(3);
|
||||
|
||||
try (ResultSet optionsResultSet = this.repository
|
||||
.checkedExecute("SELECT option_name FROM CreatePollTransactionOptions WHERE signature = ? ORDER BY option_index ASC", signature)) {
|
||||
final String optionsSql = "SELECT option_name FROM CreatePollTransactionOptions WHERE signature = ? ORDER BY option_index ASC";
|
||||
|
||||
try (ResultSet optionsResultSet = this.repository.checkedExecute(optionsSql, baseTransactionData.getSignature())) {
|
||||
if (optionsResultSet == null)
|
||||
return null;
|
||||
|
||||
@ -44,8 +45,7 @@ public class HSQLDBCreatePollTransactionRepository extends HSQLDBTransactionRepo
|
||||
pollOptions.add(new PollOptionData(optionName));
|
||||
} while (optionsResultSet.next());
|
||||
|
||||
return new CreatePollTransactionData(timestamp, txGroupId, reference, creatorPublicKey, owner, pollName, description, pollOptions,
|
||||
fee, approvalStatus, height, signature);
|
||||
return new CreatePollTransactionData(baseTransactionData, owner, pollName, description, pollOptions);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch create poll transaction from repository", e);
|
||||
|
@ -5,11 +5,11 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.DeployAtTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBDeployAtTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,10 +17,10 @@ public class HSQLDBDeployAtTransactionRepository extends HSQLDBTransactionReposi
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(
|
||||
"SELECT AT_name, description, AT_type, AT_tags, creation_bytes, amount, asset_id, AT_address FROM DeployATTransactions WHERE signature = ?",
|
||||
signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT AT_name, description, AT_type, AT_tags, creation_bytes, amount, asset_id, AT_address FROM DeployATTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -34,11 +34,8 @@ public class HSQLDBDeployAtTransactionRepository extends HSQLDBTransactionReposi
|
||||
|
||||
// Special null-checking for AT address
|
||||
String atAddress = resultSet.getString(8);
|
||||
if (resultSet.wasNull())
|
||||
atAddress = null;
|
||||
|
||||
return new DeployAtTransactionData(timestamp, txGroupId, reference, creatorPublicKey, atAddress, name, description, atType, tags, creationBytes, amount,
|
||||
assetId, fee, approvalStatus, height, signature);
|
||||
return new DeployAtTransactionData(baseTransactionData, atAddress, name, description, atType, tags, creationBytes, amount, assetId);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch deploy AT transaction from repository", e);
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package org.qora.repository.hsqldb.transaction;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.EnableForgingTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBEnableForgingTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,15 +16,16 @@ public class HSQLDBEnableForgingTransactionRepository extends HSQLDBTransactionR
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository
|
||||
.checkedExecute("SELECT target FROM EnableForgingTransactions WHERE signature = ?", signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT target FROM EnableForgingTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
String target = resultSet.getString(1);
|
||||
|
||||
return new EnableForgingTransactionData(timestamp, txGroupId, reference, creatorPublicKey, target, fee, approvalStatus, height, signature);
|
||||
return new EnableForgingTransactionData(baseTransactionData, target);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch account flags transaction from repository", e);
|
||||
}
|
||||
|
@ -5,11 +5,11 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.GenesisTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBGenesisTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,9 +17,10 @@ public class HSQLDBGenesisTransactionRepository extends HSQLDBTransactionReposit
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute("SELECT recipient, amount, asset_id FROM GenesisTransactions WHERE signature = ?",
|
||||
signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT recipient, amount, asset_id FROM GenesisTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -27,7 +28,7 @@ public class HSQLDBGenesisTransactionRepository extends HSQLDBTransactionReposit
|
||||
BigDecimal amount = resultSet.getBigDecimal(2).setScale(8);
|
||||
long assetId = resultSet.getLong(3);
|
||||
|
||||
return new GenesisTransactionData(timestamp, recipient, amount, assetId, signature);
|
||||
return new GenesisTransactionData(baseTransactionData, recipient, amount, assetId);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch genesis transaction from repository", e);
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package org.qora.repository.hsqldb.transaction;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.GroupApprovalTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBGroupApprovalTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,9 +16,10 @@ public class HSQLDBGroupApprovalTransactionRepository extends HSQLDBTransactionR
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository
|
||||
.checkedExecute("SELECT pending_signature, approval, prior_reference FROM GroupApprovalTransactions WHERE signature = ?", signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT pending_signature, approval, prior_reference FROM GroupApprovalTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -27,8 +27,7 @@ public class HSQLDBGroupApprovalTransactionRepository extends HSQLDBTransactionR
|
||||
boolean approval = resultSet.getBoolean(2);
|
||||
byte[] priorReference = resultSet.getBytes(3);
|
||||
|
||||
return new GroupApprovalTransactionData(timestamp, txGroupId, reference, creatorPublicKey, pendingSignature, approval, priorReference,
|
||||
fee, approvalStatus, height, signature);
|
||||
return new GroupApprovalTransactionData(baseTransactionData, pendingSignature, approval, priorReference);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch group approval transaction from repository", e);
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package org.qora.repository.hsqldb.transaction;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.GroupBanTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBGroupBanTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,10 +16,10 @@ public class HSQLDBGroupBanTransactionRepository extends HSQLDBTransactionReposi
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(
|
||||
"SELECT group_id, address, reason, time_to_live, member_reference, admin_reference, join_invite_reference, previous_group_id FROM GroupBanTransactions WHERE signature = ?",
|
||||
signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT group_id, address, reason, time_to_live, member_reference, admin_reference, join_invite_reference, previous_group_id FROM GroupBanTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -33,11 +32,11 @@ public class HSQLDBGroupBanTransactionRepository extends HSQLDBTransactionReposi
|
||||
byte[] joinInviteReference = resultSet.getBytes(7);
|
||||
|
||||
Integer previousGroupId = resultSet.getInt(8);
|
||||
if (resultSet.wasNull())
|
||||
if (previousGroupId == 0 && resultSet.wasNull())
|
||||
previousGroupId = null;
|
||||
|
||||
return new GroupBanTransactionData(timestamp, txGroupId, reference, creatorPublicKey, groupId, offender, reason, timeToLive,
|
||||
memberReference, adminReference, joinInviteReference, previousGroupId, fee, approvalStatus, height, signature);
|
||||
return new GroupBanTransactionData(baseTransactionData, groupId, offender, reason, timeToLive,
|
||||
memberReference, adminReference, joinInviteReference, previousGroupId);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch group ban transaction from repository", e);
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package org.qora.repository.hsqldb.transaction;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.GroupInviteTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBGroupInviteTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,9 +16,10 @@ public class HSQLDBGroupInviteTransactionRepository extends HSQLDBTransactionRep
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository
|
||||
.checkedExecute("SELECT group_id, invitee, time_to_live, join_reference, previous_group_id FROM GroupInviteTransactions WHERE signature = ?", signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT group_id, invitee, time_to_live, join_reference, previous_group_id FROM GroupInviteTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -29,11 +29,10 @@ public class HSQLDBGroupInviteTransactionRepository extends HSQLDBTransactionRep
|
||||
byte[] joinReference = resultSet.getBytes(4);
|
||||
|
||||
Integer previousGroupId = resultSet.getInt(5);
|
||||
if (resultSet.wasNull())
|
||||
if (previousGroupId == 0 && resultSet.wasNull())
|
||||
previousGroupId = null;
|
||||
|
||||
return new GroupInviteTransactionData(timestamp, txGroupId, reference, creatorPublicKey, groupId, invitee, timeToLive, joinReference, previousGroupId,
|
||||
fee, approvalStatus, height, signature);
|
||||
return new GroupInviteTransactionData(baseTransactionData, groupId, invitee, timeToLive, joinReference, previousGroupId);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch group invite transaction from repository", e);
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package org.qora.repository.hsqldb.transaction;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.GroupKickTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBGroupKickTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,10 +16,10 @@ public class HSQLDBGroupKickTransactionRepository extends HSQLDBTransactionRepos
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(
|
||||
"SELECT group_id, address, reason, member_reference, admin_reference, join_reference, previous_group_id FROM GroupKickTransactions WHERE signature = ?",
|
||||
signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT group_id, address, reason, member_reference, admin_reference, join_reference, previous_group_id FROM GroupKickTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -32,11 +31,11 @@ public class HSQLDBGroupKickTransactionRepository extends HSQLDBTransactionRepos
|
||||
byte[] joinReference = resultSet.getBytes(6);
|
||||
|
||||
Integer previousGroupId = resultSet.getInt(7);
|
||||
if (resultSet.wasNull())
|
||||
if (previousGroupId == 0 && resultSet.wasNull())
|
||||
previousGroupId = null;
|
||||
|
||||
return new GroupKickTransactionData(timestamp, txGroupId, reference, creatorPublicKey, groupId, member, reason, memberReference, adminReference,
|
||||
joinReference, previousGroupId, fee, approvalStatus, height, signature);
|
||||
return new GroupKickTransactionData(baseTransactionData, groupId, member, reason, memberReference, adminReference,
|
||||
joinReference, previousGroupId);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch group kick transaction from repository", e);
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package org.qora.repository.hsqldb.transaction;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.IssueAssetTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBIssueAssetTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,9 +16,10 @@ public class HSQLDBIssueAssetTransactionRepository extends HSQLDBTransactionRepo
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(
|
||||
"SELECT owner, asset_name, description, quantity, is_divisible, data, asset_id FROM IssueAssetTransactions WHERE signature = ?", signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT owner, asset_name, description, quantity, is_divisible, data, asset_id FROM IssueAssetTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -32,11 +32,11 @@ public class HSQLDBIssueAssetTransactionRepository extends HSQLDBTransactionRepo
|
||||
|
||||
// Special null-checking for asset ID
|
||||
Long assetId = resultSet.getLong(7);
|
||||
if (resultSet.wasNull())
|
||||
if (assetId == 0 && resultSet.wasNull())
|
||||
assetId = null;
|
||||
|
||||
return new IssueAssetTransactionData(timestamp, txGroupId, reference, creatorPublicKey, assetId, owner, assetName, description, quantity, isDivisible,
|
||||
data, fee, approvalStatus, height, signature);
|
||||
return new IssueAssetTransactionData(baseTransactionData, assetId, owner, assetName, description, quantity, isDivisible,
|
||||
data);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch issue asset transaction from repository", e);
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package org.qora.repository.hsqldb.transaction;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.JoinGroupTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBJoinGroupTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,9 +16,10 @@ public class HSQLDBJoinGroupTransactionRepository extends HSQLDBTransactionRepos
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute("SELECT group_id, invite_reference, previous_group_id FROM JoinGroupTransactions WHERE signature = ?",
|
||||
signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT group_id, invite_reference, previous_group_id FROM JoinGroupTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -27,10 +27,10 @@ public class HSQLDBJoinGroupTransactionRepository extends HSQLDBTransactionRepos
|
||||
byte[] inviteReference = resultSet.getBytes(2);
|
||||
|
||||
Integer previousGroupId = resultSet.getInt(3);
|
||||
if (resultSet.wasNull())
|
||||
if (previousGroupId == 0 && resultSet.wasNull())
|
||||
previousGroupId = null;
|
||||
|
||||
return new JoinGroupTransactionData(timestamp, txGroupId, reference, creatorPublicKey, groupId, inviteReference, previousGroupId, fee, approvalStatus, height, signature);
|
||||
return new JoinGroupTransactionData(baseTransactionData, groupId, inviteReference, previousGroupId);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch join group transaction from repository", e);
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package org.qora.repository.hsqldb.transaction;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.LeaveGroupTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBLeaveGroupTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,9 +16,10 @@ public class HSQLDBLeaveGroupTransactionRepository extends HSQLDBTransactionRepo
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository
|
||||
.checkedExecute("SELECT group_id, member_reference, admin_reference, previous_group_id FROM LeaveGroupTransactions WHERE signature = ?", signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT group_id, member_reference, admin_reference, previous_group_id FROM LeaveGroupTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -28,11 +28,10 @@ public class HSQLDBLeaveGroupTransactionRepository extends HSQLDBTransactionRepo
|
||||
byte[] adminReference = resultSet.getBytes(3);
|
||||
|
||||
Integer previousGroupId = resultSet.getInt(4);
|
||||
if (resultSet.wasNull())
|
||||
if (previousGroupId == 0 && resultSet.wasNull())
|
||||
previousGroupId = null;
|
||||
|
||||
return new LeaveGroupTransactionData(timestamp, txGroupId, reference, creatorPublicKey, groupId, memberReference, adminReference, previousGroupId,
|
||||
fee, approvalStatus, height, signature);
|
||||
return new LeaveGroupTransactionData(baseTransactionData, groupId, memberReference, adminReference, previousGroupId);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch leave group transaction from repository", e);
|
||||
}
|
||||
|
@ -5,11 +5,11 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.MessageTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBMessageTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,9 +17,10 @@ public class HSQLDBMessageTransactionRepository extends HSQLDBTransactionReposit
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(
|
||||
"SELECT version, recipient, is_text, is_encrypted, amount, asset_id, data FROM MessageTransactions WHERE signature = ?", signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT version, recipient, is_text, is_encrypted, amount, asset_id, data FROM MessageTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -31,13 +32,12 @@ public class HSQLDBMessageTransactionRepository extends HSQLDBTransactionReposit
|
||||
|
||||
// Special null-checking for asset ID
|
||||
Long assetId = resultSet.getLong(6);
|
||||
if (resultSet.wasNull())
|
||||
if (assetId == 0 && resultSet.wasNull())
|
||||
assetId = null;
|
||||
|
||||
byte[] data = resultSet.getBytes(7);
|
||||
|
||||
return new MessageTransactionData(timestamp, txGroupId, reference, creatorPublicKey, version, recipient, assetId, amount, data, isText, isEncrypted,
|
||||
fee, approvalStatus, height, signature);
|
||||
return new MessageTransactionData(baseTransactionData, version, recipient, assetId, amount, data, isText, isEncrypted);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch message transaction from repository", e);
|
||||
}
|
||||
|
@ -1,17 +1,16 @@
|
||||
package org.qora.repository.hsqldb.transaction;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.qora.data.PaymentData;
|
||||
import org.qora.data.transaction.MultiPaymentTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBMultiPaymentTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -19,14 +18,16 @@ public class HSQLDBMultiPaymentTransactionRepository extends HSQLDBTransactionRe
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute("SELECT TRUE from MultiPaymentTransactions WHERE signature = ?", signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT TRUE from MultiPaymentTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
List<PaymentData> payments = this.getPaymentsFromSignature(signature);
|
||||
List<PaymentData> payments = this.getPaymentsFromSignature(baseTransactionData.getSignature());
|
||||
|
||||
return new MultiPaymentTransactionData(timestamp, txGroupId, reference, creatorPublicKey, payments, fee, approvalStatus, height, signature);
|
||||
return new MultiPaymentTransactionData(baseTransactionData, payments);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch multi-payment transaction from repository", e);
|
||||
}
|
||||
|
@ -5,11 +5,11 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.PaymentTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBPaymentTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,15 +17,17 @@ public class HSQLDBPaymentTransactionRepository extends HSQLDBTransactionReposit
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute("SELECT recipient, amount FROM PaymentTransactions WHERE signature = ?", signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT recipient, amount FROM PaymentTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
String recipient = resultSet.getString(1);
|
||||
BigDecimal amount = resultSet.getBigDecimal(2);
|
||||
|
||||
return new PaymentTransactionData(timestamp, txGroupId, reference, creatorPublicKey, recipient, amount, fee, approvalStatus, height, signature);
|
||||
return new PaymentTransactionData(baseTransactionData, recipient, amount);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch payment transaction from repository", e);
|
||||
}
|
||||
|
@ -4,12 +4,12 @@ import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.ProxyForgingTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBProxyForgingTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,9 +17,10 @@ public class HSQLDBProxyForgingTransactionRepository extends HSQLDBTransactionRe
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository
|
||||
.checkedExecute("SELECT recipient, proxy_public_key, share, previous_share FROM ProxyForgingTransactions WHERE signature = ?", signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT recipient, proxy_public_key, share, previous_share FROM ProxyForgingTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -28,8 +29,7 @@ public class HSQLDBProxyForgingTransactionRepository extends HSQLDBTransactionRe
|
||||
BigDecimal share = resultSet.getBigDecimal(3);
|
||||
BigDecimal previousShare = resultSet.getBigDecimal(4);
|
||||
|
||||
return new ProxyForgingTransactionData(timestamp, txGroupId, reference, creatorPublicKey, recipient, proxyPublicKey, share, previousShare,
|
||||
fee, approvalStatus, height, signature);
|
||||
return new ProxyForgingTransactionData(baseTransactionData, recipient, proxyPublicKey, share, previousShare);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch proxy forging transaction from repository", e);
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package org.qora.repository.hsqldb.transaction;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.RegisterNameTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBRegisterNameTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,8 +16,10 @@ public class HSQLDBRegisterNameTransactionRepository extends HSQLDBTransactionRe
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute("SELECT owner, name, data FROM RegisterNameTransactions WHERE signature = ?", signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT owner, name, data FROM RegisterNameTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -26,7 +27,7 @@ public class HSQLDBRegisterNameTransactionRepository extends HSQLDBTransactionRe
|
||||
String name = resultSet.getString(2);
|
||||
String data = resultSet.getString(3);
|
||||
|
||||
return new RegisterNameTransactionData(timestamp, txGroupId, reference, creatorPublicKey, owner, name, data, fee, approvalStatus, height, signature);
|
||||
return new RegisterNameTransactionData(baseTransactionData, owner, name, data);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch register name transaction from repository", e);
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package org.qora.repository.hsqldb.transaction;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.RemoveGroupAdminTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBRemoveGroupAdminTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,9 +16,10 @@ public class HSQLDBRemoveGroupAdminTransactionRepository extends HSQLDBTransacti
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository
|
||||
.checkedExecute("SELECT group_id, admin, admin_reference FROM RemoveGroupAdminTransactions WHERE signature = ?", signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT group_id, admin, admin_reference FROM RemoveGroupAdminTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -27,7 +27,7 @@ public class HSQLDBRemoveGroupAdminTransactionRepository extends HSQLDBTransacti
|
||||
String admin = resultSet.getString(2);
|
||||
byte[] adminReference = resultSet.getBytes(3);
|
||||
|
||||
return new RemoveGroupAdminTransactionData(timestamp, txGroupId, reference, creatorPublicKey, groupId, admin, adminReference, fee, approvalStatus, height, signature);
|
||||
return new RemoveGroupAdminTransactionData(baseTransactionData, groupId, admin, adminReference);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch remove group admin transaction from repository", e);
|
||||
}
|
||||
|
@ -5,11 +5,11 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.SellNameTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBSellNameTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,15 +17,17 @@ public class HSQLDBSellNameTransactionRepository extends HSQLDBTransactionReposi
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute("SELECT name, amount FROM SellNameTransactions WHERE signature = ?", signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT name, amount FROM SellNameTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
String name = resultSet.getString(1);
|
||||
BigDecimal amount = resultSet.getBigDecimal(2);
|
||||
|
||||
return new SellNameTransactionData(timestamp, txGroupId, reference, creatorPublicKey, name, amount, fee, approvalStatus, height, signature);
|
||||
return new SellNameTransactionData(baseTransactionData, name, amount);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch sell name transaction from repository", e);
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package org.qora.repository.hsqldb.transaction;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.SetGroupTransactionData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBSetGroupTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,19 +16,19 @@ public class HSQLDBSetGroupTransactionRepository extends HSQLDBTransactionReposi
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository
|
||||
.checkedExecute("SELECT default_group_id, previous_default_group_id FROM SetGroupTransactions WHERE signature = ?", signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT default_group_id, previous_default_group_id FROM SetGroupTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
int defaultGroupId = resultSet.getInt(1);
|
||||
Integer previousDefaultGroupId = resultSet.getInt(2);
|
||||
if (resultSet.wasNull())
|
||||
if (previousDefaultGroupId == 0 && resultSet.wasNull())
|
||||
previousDefaultGroupId = null;
|
||||
|
||||
return new SetGroupTransactionData(timestamp, txGroupId, reference, creatorPublicKey, defaultGroupId, previousDefaultGroupId,
|
||||
fee, approvalStatus, height, signature);
|
||||
return new SetGroupTransactionData(baseTransactionData, defaultGroupId, previousDefaultGroupId);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch set group transaction from repository", e);
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.qora.api.resource.TransactionsResource.ConfirmationStatus;
|
||||
import org.qora.data.PaymentData;
|
||||
import org.qora.data.group.GroupApprovalData;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.GroupApprovalTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.data.transaction.TransferAssetTransactionData;
|
||||
@ -67,8 +68,7 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
|
||||
}
|
||||
|
||||
try {
|
||||
// params: long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, byte[] signature
|
||||
subclassInfo.fromBaseMethod = subclassInfo.clazz.getDeclaredMethod("fromBase", long.class, int.class, byte[].class, byte[].class, BigDecimal.class, ApprovalStatus.class, Integer.class, byte[].class);
|
||||
subclassInfo.fromBaseMethod = subclassInfo.clazz.getDeclaredMethod("fromBase", BaseTransactionData.class);
|
||||
} catch (IllegalArgumentException | SecurityException | NoSuchMethodException e) {
|
||||
LOGGER.debug(String.format("HSQLDBTransactionRepository subclass's \"fromBase\" method not found for transaction type \"%s\"", txType.name()));
|
||||
}
|
||||
@ -128,24 +128,32 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
|
||||
|
||||
@Override
|
||||
public TransactionData fromSignature(byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute("SELECT type, reference, creator, creation, fee, tx_group_id, approval_status, height FROM Transactions WHERE signature = ?",
|
||||
signature)) {
|
||||
final String sql = "SELECT type, reference, creator, creation, fee, tx_group_id, block_height, approval_status, approval_height FROM Transactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, signature)) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
TransactionType type = TransactionType.valueOf(resultSet.getInt(1));
|
||||
|
||||
byte[] reference = resultSet.getBytes(2);
|
||||
byte[] creatorPublicKey = resultSet.getBytes(3);
|
||||
long timestamp = resultSet.getTimestamp(4, Calendar.getInstance(HSQLDBRepository.UTC)).getTime();
|
||||
BigDecimal fee = resultSet.getBigDecimal(5).setScale(8);
|
||||
int txGroupId = resultSet.getInt(6);
|
||||
ApprovalStatus approvalStatus = ApprovalStatus.valueOf(resultSet.getInt(7));
|
||||
|
||||
Integer height = resultSet.getInt(8);
|
||||
if (resultSet.wasNull())
|
||||
height = null;
|
||||
Integer blockHeight = resultSet.getInt(7);
|
||||
if (blockHeight == 0 && resultSet.wasNull())
|
||||
blockHeight = null;
|
||||
|
||||
ApprovalStatus approvalStatus = ApprovalStatus.valueOf(resultSet.getInt(8));
|
||||
Integer approvalHeight = resultSet.getInt(9);
|
||||
if (approvalHeight == 0 && resultSet.wasNull())
|
||||
approvalHeight = null;
|
||||
|
||||
BaseTransactionData baseTransactionData = new BaseTransactionData(timestamp, txGroupId, reference, creatorPublicKey, fee, approvalStatus, blockHeight, approvalHeight, signature);
|
||||
TransactionData transactionData = this.fromBase(type, baseTransactionData);
|
||||
|
||||
TransactionData transactionData = this.fromBase(type, timestamp, txGroupId, reference, creatorPublicKey, fee, approvalStatus, height, signature);
|
||||
return transactionData;
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch transaction from repository", e);
|
||||
@ -154,24 +162,32 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
|
||||
|
||||
@Override
|
||||
public TransactionData fromReference(byte[] reference) throws DataException {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute("SELECT type, signature, creator, creation, fee, tx_group_id, approval_status, height FROM Transactions WHERE reference = ?",
|
||||
reference)) {
|
||||
final String sql = "SELECT type, signature, creator, creation, fee, tx_group_id, block_height, approval_status, approval_height FROM Transactions WHERE reference = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, reference)) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
TransactionType type = TransactionType.valueOf(resultSet.getInt(1));
|
||||
|
||||
byte[] signature = resultSet.getBytes(2);
|
||||
byte[] creatorPublicKey = resultSet.getBytes(3);
|
||||
long timestamp = resultSet.getTimestamp(4, Calendar.getInstance(HSQLDBRepository.UTC)).getTime();
|
||||
BigDecimal fee = resultSet.getBigDecimal(5).setScale(8);
|
||||
int txGroupId = resultSet.getInt(6);
|
||||
ApprovalStatus approvalStatus = ApprovalStatus.valueOf(resultSet.getInt(7));
|
||||
|
||||
Integer height = resultSet.getInt(8);
|
||||
if (resultSet.wasNull())
|
||||
height = null;
|
||||
Integer blockHeight = resultSet.getInt(7);
|
||||
if (blockHeight == 0 && resultSet.wasNull())
|
||||
blockHeight = null;
|
||||
|
||||
ApprovalStatus approvalStatus = ApprovalStatus.valueOf(resultSet.getInt(8));
|
||||
Integer approvalHeight = resultSet.getInt(9);
|
||||
if (approvalHeight == 0 && resultSet.wasNull())
|
||||
approvalHeight = null;
|
||||
|
||||
BaseTransactionData baseTransactionData = new BaseTransactionData(timestamp, txGroupId, reference, creatorPublicKey, fee, approvalStatus, blockHeight, approvalHeight, signature);
|
||||
TransactionData transactionData = this.fromBase(type, baseTransactionData);
|
||||
|
||||
TransactionData transactionData = this.fromBase(type, timestamp, txGroupId, reference, creatorPublicKey, fee, approvalStatus, height, signature);
|
||||
return transactionData;
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch transaction from repository", e);
|
||||
@ -180,7 +196,7 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
|
||||
|
||||
@Override
|
||||
public TransactionData fromHeightAndSequence(int height, int sequence) throws DataException {
|
||||
String sql = "SELECT transaction_signature FROM BlockTransactions JOIN Blocks ON signature = block_signature WHERE height = ? AND sequence = ?";
|
||||
final String sql = "SELECT transaction_signature FROM BlockTransactions JOIN Blocks ON signature = block_signature WHERE height = ? AND sequence = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, height, sequence)) {
|
||||
if (resultSet == null)
|
||||
@ -194,15 +210,14 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
|
||||
}
|
||||
}
|
||||
|
||||
private TransactionData fromBase(TransactionType type, long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer blockHeight, byte[] signature)
|
||||
throws DataException {
|
||||
private TransactionData fromBase(TransactionType type, BaseTransactionData baseTransactionData) throws DataException {
|
||||
HSQLDBTransactionRepository txRepository = repositoryByTxType[type.value];
|
||||
|
||||
if (txRepository == null)
|
||||
throw new DataException("Unsupported transaction type [" + type.name() + "] during fetch from HSQLDB repository");
|
||||
|
||||
try {
|
||||
// params: long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer blockHeight, byte[] signature
|
||||
return (TransactionData) subclassInfos[type.value].fromBaseMethod.invoke(txRepository, timestamp, txGroupId, reference, creatorPublicKey, fee, approvalStatus, blockHeight, signature);
|
||||
return (TransactionData) subclassInfos[type.value].fromBaseMethod.invoke(txRepository, baseTransactionData);
|
||||
} catch (InvocationTargetException e) {
|
||||
if (e.getCause() instanceof DataException)
|
||||
throw (DataException) e.getCause();
|
||||
@ -223,10 +238,11 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
|
||||
* @throws DataException
|
||||
*/
|
||||
protected List<PaymentData> getPaymentsFromSignature(byte[] signature) throws DataException {
|
||||
final String sql = "SELECT recipient, amount, asset_id FROM SharedTransactionPayments WHERE signature = ?";
|
||||
|
||||
List<PaymentData> payments = new ArrayList<PaymentData>();
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute("SELECT recipient, amount, asset_id FROM SharedTransactionPayments WHERE signature = ?",
|
||||
signature)) {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, signature)) {
|
||||
if (resultSet == null)
|
||||
return payments;
|
||||
|
||||
@ -265,19 +281,17 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
|
||||
if (signature == null)
|
||||
return 0;
|
||||
|
||||
String sql = "SELECT height from Transactions WHERE signature = ? LIMIT 1";
|
||||
|
||||
// Fetch height using join via block's transactions
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, signature)) {
|
||||
final String sql = "SELECT block_height from Transactions WHERE signature = ? LIMIT 1";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, signature)) {
|
||||
if (resultSet == null)
|
||||
return 0;
|
||||
|
||||
Integer height = resultSet.getInt(1);
|
||||
if (resultSet.wasNull())
|
||||
Integer blockHeight = resultSet.getInt(1);
|
||||
if (blockHeight == 0 && resultSet.wasNull())
|
||||
return 0;
|
||||
|
||||
return height;
|
||||
return blockHeight;
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch transaction's height from repository", e);
|
||||
}
|
||||
@ -296,9 +310,11 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
|
||||
|
||||
@Override
|
||||
public List<byte[]> getSignaturesInvolvingAddress(String address) throws DataException {
|
||||
final String sql = "SELECT signature FROM TransactionRecipients WHERE participant = ?";
|
||||
|
||||
List<byte[]> signatures = new ArrayList<byte[]>();
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute("SELECT signature FROM TransactionRecipients WHERE participant = ?", address)) {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, address)) {
|
||||
if (resultSet == null)
|
||||
return signatures;
|
||||
|
||||
@ -345,7 +361,7 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
|
||||
@Override
|
||||
public Map<TransactionType, Integer> getTransactionSummary(int startHeight, int endHeight) throws DataException {
|
||||
String sql = "SELECT type, COUNT(signature) FROM Transactions "
|
||||
+ "WHERE height BETWEEN ? AND ? "
|
||||
+ "WHERE block_height BETWEEN ? AND ? "
|
||||
+ "GROUP BY type";
|
||||
|
||||
Map<TransactionType, Integer> transactionCounts = new HashMap<>();
|
||||
@ -407,20 +423,20 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
|
||||
break;
|
||||
|
||||
case CONFIRMED:
|
||||
whereClauses.add("Transactions.height IS NOT NULL");
|
||||
whereClauses.add("Transactions.block_height IS NOT NULL");
|
||||
break;
|
||||
|
||||
case UNCONFIRMED:
|
||||
whereClauses.add("Transactions.height IS NULL");
|
||||
whereClauses.add("Transactions.block_height IS NULL");
|
||||
break;
|
||||
}
|
||||
|
||||
// Height range
|
||||
if (hasHeightRange) {
|
||||
whereClauses.add("Transactions.height >= " + startBlock);
|
||||
whereClauses.add("Transactions.block_height >= " + startBlock);
|
||||
|
||||
if (blockLimit != null)
|
||||
whereClauses.add("Transactions.height < " + (startBlock + blockLimit));
|
||||
whereClauses.add("Transactions.block_height < " + (startBlock + blockLimit));
|
||||
}
|
||||
|
||||
if (txGroupId != null) {
|
||||
@ -480,6 +496,7 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
|
||||
TransactionType[] transactionTypes = new TransactionType[] {
|
||||
ISSUE_ASSET, TRANSFER_ASSET, CREATE_ASSET_ORDER, CANCEL_ASSET_ORDER
|
||||
};
|
||||
|
||||
List<String> typeValueStrings = Arrays.asList(transactionTypes).stream().map(type -> String.valueOf(type.value)).collect(Collectors.toList());
|
||||
|
||||
String sql = "SELECT Transactions.signature FROM Transactions";
|
||||
@ -498,11 +515,11 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
|
||||
break;
|
||||
|
||||
case CONFIRMED:
|
||||
sql += " AND Transactions.height IS NOT NULL";
|
||||
sql += " AND Transactions.block_height IS NOT NULL";
|
||||
break;
|
||||
|
||||
case UNCONFIRMED:
|
||||
sql += " AND Transactions.height IS NULL";
|
||||
sql += " AND Transactions.block_height IS NULL";
|
||||
break;
|
||||
}
|
||||
|
||||
@ -552,7 +569,7 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
|
||||
throws DataException {
|
||||
List<Object> bindParams = new ArrayList<>(3);
|
||||
|
||||
String sql = "SELECT creation, tx_group_id, reference, fee, signature, sender, recipient, amount, asset_name, approval_status, height "
|
||||
String sql = "SELECT creation, tx_group_id, reference, fee, signature, sender, block_height, approval_status, approval_height, recipient, amount, asset_name "
|
||||
+ "FROM TransferAssetTransactions JOIN Transactions USING (signature) ";
|
||||
|
||||
if (address != null)
|
||||
@ -584,15 +601,24 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
|
||||
BigDecimal fee = resultSet.getBigDecimal(4).setScale(8);
|
||||
byte[] signature = resultSet.getBytes(5);
|
||||
byte[] creatorPublicKey = resultSet.getBytes(6);
|
||||
String recipient = resultSet.getString(7);
|
||||
BigDecimal amount = resultSet.getBigDecimal(8);
|
||||
String assetName = resultSet.getString(9);
|
||||
ApprovalStatus approvalStatus = ApprovalStatus.valueOf(resultSet.getInt(10));
|
||||
Integer height = resultSet.getInt(11);
|
||||
if (resultSet.wasNull())
|
||||
height = null;
|
||||
|
||||
assetTransfers.add(new TransferAssetTransactionData(timestamp, txGroupId, reference, creatorPublicKey, recipient, amount, assetId, fee, assetName, approvalStatus, height, signature));
|
||||
Integer blockHeight = resultSet.getInt(7);
|
||||
if (blockHeight == 0 && resultSet.wasNull())
|
||||
blockHeight = null;
|
||||
|
||||
ApprovalStatus approvalStatus = ApprovalStatus.valueOf(resultSet.getInt(8));
|
||||
|
||||
Integer approvalHeight = resultSet.getInt(9);
|
||||
if (approvalHeight == 0 && resultSet.wasNull())
|
||||
approvalHeight = null;
|
||||
|
||||
BaseTransactionData baseTransactionData = new BaseTransactionData(timestamp, txGroupId, reference, creatorPublicKey, fee, approvalStatus, blockHeight, approvalHeight, signature);
|
||||
|
||||
String recipient = resultSet.getString(10);
|
||||
BigDecimal amount = resultSet.getBigDecimal(11);
|
||||
String assetName = resultSet.getString(12);
|
||||
|
||||
assetTransfers.add(new TransferAssetTransactionData(baseTransactionData, recipient, amount, assetId, assetName));
|
||||
} while (resultSet.next());
|
||||
|
||||
return assetTransfers;
|
||||
@ -653,7 +679,7 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
|
||||
String sql = "SELECT signature FROM Transactions "
|
||||
+ "JOIN Groups on Groups.group_id = Transactions.tx_group_id "
|
||||
+ "WHERE Transactions.approval_status = ? "
|
||||
+ "AND Transactions.height >= ? - Groups.min_block_delay";
|
||||
+ "AND Transactions.block_height >= ? - Groups.min_block_delay";
|
||||
|
||||
List<TransactionData> transactions = new ArrayList<TransactionData>();
|
||||
|
||||
@ -684,7 +710,7 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
|
||||
String sql = "SELECT signature FROM Transactions "
|
||||
+ "JOIN Groups on Groups.group_id = Transactions.tx_group_id "
|
||||
+ "WHERE Transactions.approval_status = ? "
|
||||
+ "AND Transactions.height < ? - Groups.max_block_delay";
|
||||
+ "AND Transactions.block_height < ? - Groups.max_block_delay";
|
||||
|
||||
List<TransactionData> transactions = new ArrayList<TransactionData>();
|
||||
|
||||
@ -714,7 +740,7 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
|
||||
public GroupApprovalTransactionData getLatestApproval(byte[] pendingSignature, byte[] adminPublicKey) throws DataException {
|
||||
String sql = "SELECT signature FROM GroupApprovalTransactions "
|
||||
+ "NATURAL JOIN Transactions "
|
||||
+ "WHERE pending_signature = ? AND admin = ? AND height IS NOT NULL "
|
||||
+ "WHERE pending_signature = ? AND admin = ? AND block_height IS NOT NULL "
|
||||
+ "ORDER BY creation DESC, signature DESC LIMIT 1";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, pendingSignature, adminPublicKey)) {
|
||||
@ -737,7 +763,7 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
|
||||
|
||||
// Sub-query SQL to find latest GroupApprovalTransaction relating to passed pending signature
|
||||
String latestApprovalSql = "SELECT pending_signature, admin, approval, creation, signature FROM GroupApprovalTransactions "
|
||||
+ "NATURAL JOIN Transactions WHERE pending_signature = ? AND height IS NOT NULL";
|
||||
+ "NATURAL JOIN Transactions WHERE pending_signature = ? AND block_height IS NOT NULL";
|
||||
|
||||
String sql = "SELECT GAT.admin, GAT.approval FROM "
|
||||
+ "(" + latestApprovalSql + ") AS GAT "
|
||||
@ -828,15 +854,28 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateHeight(byte[] signature, Integer height) throws DataException {
|
||||
public void updateBlockHeight(byte[] signature, Integer blockHeight) throws DataException {
|
||||
HSQLDBSaver saver = new HSQLDBSaver("Transactions");
|
||||
|
||||
saver.bind("signature", signature).bind("height", height);
|
||||
saver.bind("signature", signature).bind("block_height", blockHeight);
|
||||
|
||||
try {
|
||||
saver.execute(repository);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to update transaction's height in repository", e);
|
||||
throw new DataException("Unable to update transaction's block height in repository", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateApprovalHeight(byte[] signature, Integer approvalHeight) throws DataException {
|
||||
HSQLDBSaver saver = new HSQLDBSaver("Transactions");
|
||||
|
||||
saver.bind("signature", signature).bind("approval_height", approvalHeight);
|
||||
|
||||
try {
|
||||
saver.execute(repository);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to update transaction's approval height in repository", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -857,7 +896,8 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
|
||||
public void save(TransactionData transactionData) throws DataException {
|
||||
HSQLDBSaver saver = new HSQLDBSaver("Transactions");
|
||||
|
||||
// Do not include "height" as that is modified a different way
|
||||
// Do not include "block_height" or "approval_height" as they are modified a different way
|
||||
|
||||
saver.bind("signature", transactionData.getSignature()).bind("reference", transactionData.getReference())
|
||||
.bind("type", transactionData.getType().value)
|
||||
.bind("creator", transactionData.getCreatorPublicKey()).bind("creation", new Timestamp(transactionData.getTimestamp()))
|
||||
|
@ -4,12 +4,12 @@ import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.data.transaction.TransferAssetTransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBTransferAssetTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,10 +17,10 @@ public class HSQLDBTransferAssetTransactionRepository extends HSQLDBTransactionR
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
String sql = "SELECT recipient, asset_id, amount, asset_name FROM TransferAssetTransactions JOIN Assets USING (asset_id) WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, signature)) {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql)) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -29,7 +29,7 @@ public class HSQLDBTransferAssetTransactionRepository extends HSQLDBTransactionR
|
||||
BigDecimal amount = resultSet.getBigDecimal(3);
|
||||
String assetName = resultSet.getString(4);
|
||||
|
||||
return new TransferAssetTransactionData(timestamp, txGroupId, reference, creatorPublicKey, recipient, amount, assetId, fee, assetName, approvalStatus, height, signature);
|
||||
return new TransferAssetTransactionData(baseTransactionData, recipient, amount, assetId, assetName);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch transfer asset transaction from repository", e);
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package org.qora.repository.hsqldb.transaction;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.data.transaction.UpdateAssetTransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBUpdateAssetTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,11 +16,10 @@ public class HSQLDBUpdateAssetTransactionRepository extends HSQLDBTransactionRep
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee,
|
||||
ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(
|
||||
"SELECT asset_id, new_owner, new_description, new_data, orphan_reference FROM UpdateAssetTransactions WHERE signature = ?",
|
||||
signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT asset_id, new_owner, new_description, new_data, orphan_reference FROM UpdateAssetTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -31,8 +29,7 @@ public class HSQLDBUpdateAssetTransactionRepository extends HSQLDBTransactionRep
|
||||
String newData = resultSet.getString(4);
|
||||
byte[] orphanReference = resultSet.getBytes(5);
|
||||
|
||||
return new UpdateAssetTransactionData(timestamp, txGroupId, reference, creatorPublicKey, assetId, newOwner,
|
||||
newDescription, newData, fee, orphanReference, approvalStatus, height, signature);
|
||||
return new UpdateAssetTransactionData(baseTransactionData, assetId, newOwner, newDescription, newData, orphanReference);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch update asset transaction from repository", e);
|
||||
}
|
||||
|
@ -1,16 +1,15 @@
|
||||
package org.qora.repository.hsqldb.transaction;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.UpdateGroupTransactionData;
|
||||
import org.qora.group.Group.ApprovalThreshold;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBUpdateGroupTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -18,10 +17,10 @@ public class HSQLDBUpdateGroupTransactionRepository extends HSQLDBTransactionRep
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(
|
||||
"SELECT group_id, new_owner, new_description, new_is_open, new_approval_threshold, new_min_block_delay, new_max_block_delay, group_reference FROM UpdateGroupTransactions WHERE signature = ?",
|
||||
signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT group_id, new_owner, new_description, new_is_open, new_approval_threshold, new_min_block_delay, new_max_block_delay, group_reference FROM UpdateGroupTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -34,8 +33,8 @@ public class HSQLDBUpdateGroupTransactionRepository extends HSQLDBTransactionRep
|
||||
int newMaxBlockDelay = resultSet.getInt(7);
|
||||
byte[] groupReference = resultSet.getBytes(8);
|
||||
|
||||
return new UpdateGroupTransactionData(timestamp, txGroupId, reference, creatorPublicKey, groupId, newOwner, newDescription, newIsOpen,
|
||||
newApprovalThreshold, newMinBlockDelay, newMaxBlockDelay, groupReference, fee, approvalStatus, height, signature);
|
||||
return new UpdateGroupTransactionData(baseTransactionData, groupId, newOwner, newDescription, newIsOpen,
|
||||
newApprovalThreshold, newMinBlockDelay, newMaxBlockDelay, groupReference);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch update group transaction from repository", e);
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package org.qora.repository.hsqldb.transaction;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.data.transaction.UpdateNameTransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBUpdateNameTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,9 +16,10 @@ public class HSQLDBUpdateNameTransactionRepository extends HSQLDBTransactionRepo
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository
|
||||
.checkedExecute("SELECT new_owner, name, new_data, name_reference FROM UpdateNameTransactions WHERE signature = ?", signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT new_owner, name, new_data, name_reference FROM UpdateNameTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -28,7 +28,7 @@ public class HSQLDBUpdateNameTransactionRepository extends HSQLDBTransactionRepo
|
||||
String newData = resultSet.getString(3);
|
||||
byte[] nameReference = resultSet.getBytes(4);
|
||||
|
||||
return new UpdateNameTransactionData(timestamp, txGroupId, reference, creatorPublicKey, newOwner, name, newData, nameReference, fee, approvalStatus, height, signature);
|
||||
return new UpdateNameTransactionData(baseTransactionData, newOwner, name, newData, nameReference);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch update name transaction from repository", e);
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package org.qora.repository.hsqldb.transaction;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.data.transaction.VoteOnPollTransactionData;
|
||||
import org.qora.repository.DataException;
|
||||
import org.qora.repository.hsqldb.HSQLDBRepository;
|
||||
import org.qora.repository.hsqldb.HSQLDBSaver;
|
||||
import org.qora.transaction.Transaction.ApprovalStatus;
|
||||
|
||||
public class HSQLDBVoteOnPollTransactionRepository extends HSQLDBTransactionRepository {
|
||||
|
||||
@ -17,9 +16,10 @@ public class HSQLDBVoteOnPollTransactionRepository extends HSQLDBTransactionRepo
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
TransactionData fromBase(long timestamp, int txGroupId, byte[] reference, byte[] creatorPublicKey, BigDecimal fee, ApprovalStatus approvalStatus, Integer height, byte[] signature) throws DataException {
|
||||
try (ResultSet resultSet = this.repository
|
||||
.checkedExecute("SELECT poll_name, option_index, previous_option_index FROM VoteOnPollTransactions WHERE signature = ?", signature)) {
|
||||
TransactionData fromBase(BaseTransactionData baseTransactionData) throws DataException {
|
||||
final String sql = "SELECT poll_name, option_index, previous_option_index FROM VoteOnPollTransactions WHERE signature = ?";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, baseTransactionData.getSignature())) {
|
||||
if (resultSet == null)
|
||||
return null;
|
||||
|
||||
@ -28,11 +28,10 @@ public class HSQLDBVoteOnPollTransactionRepository extends HSQLDBTransactionRepo
|
||||
|
||||
// Special null-checking for previous option index
|
||||
Integer previousOptionIndex = resultSet.getInt(3);
|
||||
if (resultSet.wasNull())
|
||||
if (previousOptionIndex == 0 && resultSet.wasNull())
|
||||
previousOptionIndex = null;
|
||||
|
||||
return new VoteOnPollTransactionData(timestamp, txGroupId, reference, creatorPublicKey, pollName, optionIndex, previousOptionIndex,
|
||||
fee, approvalStatus, height, signature);
|
||||
return new VoteOnPollTransactionData(baseTransactionData, pollName, optionIndex, previousOptionIndex);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to fetch vote on poll transaction from repository", e);
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import java.math.BigDecimal;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.qora.block.BlockChain;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.ProxyForgingTransactionData;
|
||||
import org.qora.data.transaction.TransactionData;
|
||||
import org.qora.transaction.Transaction.TransactionType;
|
||||
@ -59,7 +60,9 @@ public class ProxyForgingTransactionTransformer extends TransactionTransformer {
|
||||
byte[] signature = new byte[SIGNATURE_LENGTH];
|
||||
byteBuffer.get(signature);
|
||||
|
||||
return new ProxyForgingTransactionData(timestamp, txGroupId, reference, forgerPublicKey, recipient, proxyPublicKey, share, fee, signature);
|
||||
BaseTransactionData baseTransactionData = new BaseTransactionData(timestamp, txGroupId, reference, forgerPublicKey, fee, signature);
|
||||
|
||||
return new ProxyForgingTransactionData(baseTransactionData, recipient, proxyPublicKey, share);
|
||||
}
|
||||
|
||||
public static int getDataLength(TransactionData transactionData) throws TransformationException {
|
||||
|
@ -6,6 +6,7 @@ import java.util.Map;
|
||||
|
||||
import org.qora.account.PrivateKeyAccount;
|
||||
import org.qora.crypto.Crypto;
|
||||
import org.qora.data.transaction.BaseTransactionData;
|
||||
import org.qora.data.transaction.EnableForgingTransactionData;
|
||||
import org.qora.data.transaction.PaymentTransactionData;
|
||||
import org.qora.data.transaction.ProxyForgingTransactionData;
|
||||
@ -41,7 +42,8 @@ public class AccountUtils {
|
||||
byte[] proxyPrivateKey = forgingAccount.getSharedSecret(recipientAccount.getPublicKey());
|
||||
PrivateKeyAccount proxyAccount = new PrivateKeyAccount(null, proxyPrivateKey);
|
||||
|
||||
TransactionData transactionData = new ProxyForgingTransactionData(timestamp, txGroupId, reference, forgingAccount.getPublicKey(), recipientAccount.getAddress(), proxyAccount.getPublicKey(), share, fee);
|
||||
BaseTransactionData baseTransactionData = new BaseTransactionData(timestamp, txGroupId, reference, forgingAccount.getPublicKey(), fee, null);
|
||||
TransactionData transactionData = new ProxyForgingTransactionData(baseTransactionData, recipientAccount.getAddress(), proxyAccount.getPublicKey(), share);
|
||||
|
||||
TransactionUtils.signAndForge(repository, transactionData, forgingAccount);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user