Skip to content

Commit

Permalink
Merge pull request #1382 from multiversx/API-70-add-missing-filters-p…
Browse files Browse the repository at this point in the history
…ool-count

added missing filters to tx pool count endpoint
  • Loading branch information
bogdan-rosianu authored Nov 15, 2024
2 parents 3615ee8 + d1d63d1 commit 34f5ad1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
14 changes: 12 additions & 2 deletions src/endpoints/pool/pool.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,24 @@ export class PoolController {
@ApiOperation({ summary: 'Transactions pool count', description: 'Returns the number of transactions that are currently in the memory pool.' })
@ApiOkResponse({ type: Number })
@ApiQuery({ name: 'sender', description: 'Returns the number of transactions with a specific sender', required: false })
@ApiQuery({ name: 'receiver', description: 'Returns the number of transactions with a specific receiver', required: false })
@ApiQuery({ name: 'receiver', description: 'Search in transaction pool by a specific receiver', required: false })
@ApiQuery({ name: 'senderShard', description: 'The shard of the sender', required: false })
@ApiQuery({ name: 'receiverShard', description: 'The shard of the receiver', required: false })
@ApiQuery({ name: 'type', description: 'Returns the number of transactions with a specific type', required: false })
async getTransactionPoolCount(
@Query('sender', ParseAddressAndMetachainPipe) sender?: string,
@Query('receiver', ParseAddressPipe) receiver?: string,
@Query('senderShard', ParseIntPipe) senderShard?: number,
@Query('receiverShard', ParseIntPipe) receiverShard?: number,
@Query('type', new ParseEnumPipe(TransactionType)) type?: TransactionType,
): Promise<number> {
return await this.poolService.getPoolCount(new PoolFilter({ sender, receiver, type }));
return await this.poolService.getPoolCount(new PoolFilter({
sender: sender,
receiver: receiver,
senderShard: senderShard,
receiverShard: receiverShard,
type: type,
}));
}

@Get("/pool/c")
Expand Down
6 changes: 2 additions & 4 deletions src/endpoints/pool/pool.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ export class PoolService {

async getTransactionFromPool(txHash: string): Promise<TransactionInPool | undefined> {
const pool = await this.getEntirePool();
const transaction = pool.find(tx => tx.txHash === txHash);

return transaction;
return pool.find(tx => tx.txHash === txHash);
}

async getPoolCount(filter: PoolFilter): Promise<number> {
Expand All @@ -41,7 +39,7 @@ export class PoolService {
return [];
}

const {from, size} = queryPagination;
const { from, size } = queryPagination;
const entirePool = await this.getEntirePool();
const pool = this.applyFilters(entirePool, filter);
return pool.slice(from, from + size);
Expand Down

0 comments on commit 34f5ad1

Please sign in to comment.