mirror of
https://github.com/Qortal/qortal.git
synced 2025-02-15 11:45:49 +00:00
Modified AT and transaction repository queries to use Transactions.block_sequence instead of BlockTransactions.sequence.
The former is available for all blocks, whereas the latter is only available for unpruned blocks. Also removed joins with the Blocks table - as the Blocks table is also pruned - and instead retrieved the height from the Transactions table.
This commit is contained in:
parent
af6be759e7
commit
a8c27be18a
@ -296,10 +296,9 @@ public class HSQLDBATRepository implements ATRepository {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getATCreationBlockHeight(String atAddress) throws DataException {
|
public Integer getATCreationBlockHeight(String atAddress) throws DataException {
|
||||||
String sql = "SELECT height "
|
String sql = "SELECT block_height "
|
||||||
+ "FROM DeployATTransactions "
|
+ "FROM DeployATTransactions "
|
||||||
+ "JOIN BlockTransactions ON transaction_signature = signature "
|
+ "JOIN Transactions USING (signature) "
|
||||||
+ "JOIN Blocks ON Blocks.signature = block_signature "
|
|
||||||
+ "WHERE AT_address = ? "
|
+ "WHERE AT_address = ? "
|
||||||
+ "LIMIT 1";
|
+ "LIMIT 1";
|
||||||
|
|
||||||
@ -877,18 +876,17 @@ public class HSQLDBATRepository implements ATRepository {
|
|||||||
public NextTransactionInfo findNextTransaction(String recipient, int height, int sequence) throws DataException {
|
public NextTransactionInfo findNextTransaction(String recipient, int height, int sequence) throws DataException {
|
||||||
// We only need to search for a subset of transaction types: MESSAGE, PAYMENT or AT
|
// We only need to search for a subset of transaction types: MESSAGE, PAYMENT or AT
|
||||||
|
|
||||||
String sql = "SELECT height, sequence, Transactions.signature "
|
String sql = "SELECT block_height, block_sequence, Transactions.signature "
|
||||||
+ "FROM ("
|
+ "FROM ("
|
||||||
+ "SELECT signature FROM PaymentTransactions WHERE recipient = ? "
|
+ "SELECT signature FROM PaymentTransactions WHERE recipient = ? "
|
||||||
+ "UNION "
|
+ "UNION "
|
||||||
+ "SELECT signature FROM MessageTransactions WHERE recipient = ? "
|
+ "SELECT signature FROM MessageTransactions WHERE recipient = ? "
|
||||||
+ "UNION "
|
+ "UNION "
|
||||||
+ "SELECT signature FROM ATTransactions WHERE recipient = ?"
|
+ "SELECT signature FROM ATTransactions WHERE recipient = ?"
|
||||||
+ ") AS Transactions "
|
+ ") AS SelectedTransactions "
|
||||||
+ "JOIN BlockTransactions ON BlockTransactions.transaction_signature = Transactions.signature "
|
+ "JOIN Transactions USING (signature)"
|
||||||
+ "JOIN Blocks ON Blocks.signature = BlockTransactions.block_signature "
|
+ "WHERE (block_height > ? OR (block_height = ? AND block_sequence > ?)) "
|
||||||
+ "WHERE (height > ? OR (height = ? AND sequence > ?)) "
|
+ "ORDER BY block_height ASC, block_sequence ASC "
|
||||||
+ "ORDER BY height ASC, sequence ASC "
|
|
||||||
+ "LIMIT 1";
|
+ "LIMIT 1";
|
||||||
|
|
||||||
Object[] bindParams = new Object[] { recipient, recipient, recipient, height, height, sequence };
|
Object[] bindParams = new Object[] { recipient, recipient, recipient, height, height, sequence };
|
||||||
|
@ -194,8 +194,7 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TransactionData fromHeightAndSequence(int height, int sequence) throws DataException {
|
public TransactionData fromHeightAndSequence(int height, int sequence) throws DataException {
|
||||||
String sql = "SELECT transaction_signature FROM BlockTransactions JOIN Blocks ON signature = block_signature "
|
String sql = "SELECT signature FROM Transactions WHERE block_height = ? AND block_sequence = ?";
|
||||||
+ "WHERE height = ? AND sequence = ?";
|
|
||||||
|
|
||||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, height, sequence)) {
|
try (ResultSet resultSet = this.repository.checkedExecute(sql, height, sequence)) {
|
||||||
if (resultSet == null)
|
if (resultSet == null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user