Skip to content

Commit d9bb6e7

Browse files
Merge pull request #1573 from input-output-hk/feat/reduce-initial-tx-discovery-to-10-tx-per-address
feat(wallet): initial transactions fetch window reduced to top 10 down from 1 month
2 parents fe629c7 + 765feb3 commit d9bb6e7

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

packages/wallet/src/services/TransactionsTracker.ts

+3-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,16 @@ 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.slice(0, historicalTransactionsFetchLimit);
241229
};
242230

243231
const findIntersectionAndUpdateTxStore = ({

packages/wallet/test/services/TransactionsTracker.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const updateTransactionIds = (transactions: Cardano.HydratedTx[]) =>
6464

6565
describe('TransactionsTracker', () => {
6666
const logger = dummyLogger;
67-
const historicalTransactionsFetchLimit = 2;
67+
const historicalTransactionsFetchLimit = 3;
6868

6969
describe('newTransactions$', () => {
7070
it('considers transactions from 1st emission as old and emits only new transactions', () => {

0 commit comments

Comments
 (0)