Skip to content

Commit d54c9ca

Browse files
feat(wallet): initial transactions fetch window reduced to top 10 down from 1 month
1 parent fe629c7 commit d54c9ca

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

packages/wallet/src/services/TransactionsTracker.ts

+5-15
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ import { newAndStoredMulticast } from './util/newAndStoredMulticast';
4040
import chunk from 'lodash/chunk.js';
4141
import sortBy from 'lodash/sortBy.js';
4242

43-
const ONE_MONTH_BLOCK_TIME = 21_600 * 6;
44-
4543
export interface TransactionsTrackerProps {
4644
chainHistoryProvider: ChainHistoryProvider;
4745
addresses$: Observable<Cardano.PaymentAddress[]>;
@@ -218,26 +216,18 @@ const fetchInitialTransactions = async (
218216
addresses: Cardano.PaymentAddress[],
219217
historicalTransactionsFetchLimit: number
220218
): Promise<Cardano.HydratedTx[]> => {
221-
const firstPassTxs = await allTransactionsByAddresses(chainHistoryProvider, {
219+
const transactions = await allTransactionsByAddresses(chainHistoryProvider, {
222220
addresses,
223221
filterBy: { limit: historicalTransactionsFetchLimit, type: 'tip' }
224222
});
225223

226-
if (firstPassTxs.length === 0) {
224+
if (transactions.length === 0) {
227225
return [];
228226
}
229227

230-
if (addresses.length === 1) {
231-
return firstPassTxs;
232-
}
233-
234-
const highBlockNo = Cardano.BlockNo(Math.max(...firstPassTxs.map((tx) => tx.blockHeader.blockNo)));
235-
const onMonthBack = Cardano.BlockNo(Math.max(highBlockNo - ONE_MONTH_BLOCK_TIME, 0));
236-
237-
return await allTransactionsByAddresses(chainHistoryProvider, {
238-
addresses,
239-
filterBy: { blockRange: { lowerBound: onMonthBack }, type: 'blockRange' }
240-
});
228+
return transactions
229+
.sort((lhs, rhs) => rhs.blockHeader.slot - lhs.blockHeader.slot)
230+
.slice(0, historicalTransactionsFetchLimit);
241231
};
242232

243233
const findIntersectionAndUpdateTxStore = ({

0 commit comments

Comments
 (0)