forked from Qortal/qortal
Added maxTransactionsPerBlock setting (default 25) to reduce minting load on slower machines.
This is a short term limit, is well above current usage levels, and can be increased substantially in future once the block minter code has been improved.
This commit is contained in:
parent
f7e1f2fca8
commit
f5c8dfe766
@ -314,7 +314,7 @@ public interface TransactionRepository {
|
|||||||
* @return list of transactions, or empty if none.
|
* @return list of transactions, or empty if none.
|
||||||
* @throws DataException
|
* @throws DataException
|
||||||
*/
|
*/
|
||||||
public List<TransactionData> getUnconfirmedTransactions(EnumSet<TransactionType> excludedTxTypes) throws DataException;
|
public List<TransactionData> getUnconfirmedTransactions(EnumSet<TransactionType> excludedTxTypes, Integer limit) throws DataException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove transaction from unconfirmed transactions pile.
|
* Remove transaction from unconfirmed transactions pile.
|
||||||
|
@ -1429,8 +1429,10 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TransactionData> getUnconfirmedTransactions(EnumSet<TransactionType> excludedTxTypes) throws DataException {
|
public List<TransactionData> getUnconfirmedTransactions(EnumSet<TransactionType> excludedTxTypes, Integer limit) throws DataException {
|
||||||
StringBuilder sql = new StringBuilder(1024);
|
StringBuilder sql = new StringBuilder(1024);
|
||||||
|
List<Object> bindParams = new ArrayList<>();
|
||||||
|
|
||||||
sql.append("SELECT signature FROM UnconfirmedTransactions ");
|
sql.append("SELECT signature FROM UnconfirmedTransactions ");
|
||||||
sql.append("JOIN Transactions USING (signature) ");
|
sql.append("JOIN Transactions USING (signature) ");
|
||||||
sql.append("WHERE type NOT IN (");
|
sql.append("WHERE type NOT IN (");
|
||||||
@ -1446,12 +1448,17 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sql.append(")");
|
sql.append(")");
|
||||||
sql.append("ORDER BY created_when, signature");
|
sql.append("ORDER BY created_when, signature ");
|
||||||
|
|
||||||
|
if (limit != null) {
|
||||||
|
sql.append("LIMIT ?");
|
||||||
|
bindParams.add(limit);
|
||||||
|
}
|
||||||
|
|
||||||
List<TransactionData> transactions = new ArrayList<>();
|
List<TransactionData> transactions = new ArrayList<>();
|
||||||
|
|
||||||
// Find transactions with no corresponding row in BlockTransactions
|
// Find transactions with no corresponding row in BlockTransactions
|
||||||
try (ResultSet resultSet = this.repository.checkedExecute(sql.toString())) {
|
try (ResultSet resultSet = this.repository.checkedExecute(sql.toString(), bindParams.toArray())) {
|
||||||
if (resultSet == null)
|
if (resultSet == null)
|
||||||
return transactions;
|
return transactions;
|
||||||
|
|
||||||
|
@ -146,6 +146,9 @@ public class Settings {
|
|||||||
/* How many blocks to cache locally. Defaulted to 10, which covers a typical Synchronizer request + a few spare */
|
/* How many blocks to cache locally. Defaulted to 10, which covers a typical Synchronizer request + a few spare */
|
||||||
private int blockCacheSize = 10;
|
private int blockCacheSize = 10;
|
||||||
|
|
||||||
|
/** Maximum number of transactions for the block minter to include in a block */
|
||||||
|
private int maxTransactionsPerBlock = 25;
|
||||||
|
|
||||||
/** How long to keep old, full, AT state data (ms). */
|
/** How long to keep old, full, AT state data (ms). */
|
||||||
private long atStatesMaxLifetime = 5 * 24 * 60 * 60 * 1000L; // milliseconds
|
private long atStatesMaxLifetime = 5 * 24 * 60 * 60 * 1000L; // milliseconds
|
||||||
/** How often to attempt AT state trimming (ms). */
|
/** How often to attempt AT state trimming (ms). */
|
||||||
@ -693,6 +696,10 @@ public class Settings {
|
|||||||
return this.blockCacheSize;
|
return this.blockCacheSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMaxTransactionsPerBlock() {
|
||||||
|
return this.maxTransactionsPerBlock;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isTestNet() {
|
public boolean isTestNet() {
|
||||||
return this.isTestNet;
|
return this.isTestNet;
|
||||||
}
|
}
|
||||||
|
@ -641,7 +641,8 @@ public abstract class Transaction {
|
|||||||
BlockData latestBlockData = repository.getBlockRepository().getLastBlock();
|
BlockData latestBlockData = repository.getBlockRepository().getLastBlock();
|
||||||
|
|
||||||
EnumSet<TransactionType> excludedTxTypes = EnumSet.of(TransactionType.CHAT, TransactionType.PRESENCE);
|
EnumSet<TransactionType> excludedTxTypes = EnumSet.of(TransactionType.CHAT, TransactionType.PRESENCE);
|
||||||
List<TransactionData> unconfirmedTransactions = repository.getTransactionRepository().getUnconfirmedTransactions(excludedTxTypes);
|
int limit = Settings.getInstance().getMaxTransactionsPerBlock();
|
||||||
|
List<TransactionData> unconfirmedTransactions = repository.getTransactionRepository().getUnconfirmedTransactions(excludedTxTypes, limit);
|
||||||
|
|
||||||
unconfirmedTransactions.sort(getDataComparator());
|
unconfirmedTransactions.sort(getDataComparator());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user