|
30 | 30 |
|
31 | 31 | #define SINGLE_THREAD_MAX_TXES_SIZE 4000 |
32 | 32 |
|
| 33 | +// Maximum amount of loaded records in ram in the first load. |
| 34 | +// If the user has more and want to load them, could add a load on demand in pages. |
| 35 | +// but.. to be realistic, it's not useful anyway, why someone would ever want to have more than 20,000 txs loaded in the UI?? |
| 36 | +// The person would be essentially spamming himself.. |
| 37 | +#define MAX_AMOUNT_LOADED_RECORDS 20000 |
| 38 | + |
33 | 39 | // Amount column is right-aligned it contains numbers |
34 | 40 | static int column_alignments[] = { |
35 | 41 | Qt::AlignLeft | Qt::AlignVCenter, /* status */ |
@@ -88,6 +94,21 @@ class TransactionTablePriv |
88 | 94 | std::size_t txesSize = walletTxes.size(); |
89 | 95 | if (txesSize > SINGLE_THREAD_MAX_TXES_SIZE) { |
90 | 96 |
|
| 97 | + // First check if the amount of txs exceeds the UI limit |
| 98 | + if (txesSize > MAX_AMOUNT_LOADED_RECORDS) { |
| 99 | + // Sort the txs by date just to be really really sure that them are ordered. |
| 100 | + // (this extra calculation should be removed in the future if can ensure that |
| 101 | + // txs are stored in order in the db, which is what should be happening) |
| 102 | + sort(walletTxes.begin(), walletTxes.end(), |
| 103 | + [](const CWalletTx & a, const CWalletTx & b) -> bool { |
| 104 | + return a.GetComputedTxTime() < b.GetComputedTxTime(); |
| 105 | + }); |
| 106 | + |
| 107 | + // Only latest ones. |
| 108 | + walletTxes = std::vector<CWalletTx>(walletTxes.begin(), walletTxes.begin() + MAX_AMOUNT_LOADED_RECORDS); |
| 109 | + txesSize = walletTxes.size(); |
| 110 | + }; |
| 111 | + |
91 | 112 | // Simple way to get the processors count |
92 | 113 | std::size_t threadsCount = (QThreadPool::globalInstance()->maxThreadCount() / 2 ) + 1; |
93 | 114 |
|
|
0 commit comments