Skip to content

Commit 576d05b

Browse files
authored
feat: mark /mempool/dropped endpoint as legacy deprecated (#2255)
* feat: mark /mempool/dropped endpoint as legacy deprecated * test: enable legacy
1 parent 32868dd commit 576d05b

File tree

3 files changed

+42
-35
lines changed

3 files changed

+42
-35
lines changed

.env

+3
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ STACKS_NODE_TYPE=L1
158158
# Enable FT metadata processing for Rosetta operations display. Disabled by default.
159159
# STACKS_API_ENABLE_FT_METADATA=1
160160

161+
# Enable legacy API endpoints. Disabled by default.
162+
# STACKS_API_ENABLE_LEGACY_ENDPOINTS=1
163+
161164
# The Rosetta API endpoints require FT metadata to display operations with the proper `symbol` and
162165
# `decimals` values. If FT metadata is enabled, this variable controls the token metadata error
163166
# handling mode when metadata is not found.

src/api/routes/tx.ts

+38-35
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
handleTransactionCache,
1717
} from '../controllers/cache-controller';
1818
import { DbEventTypeId } from '../../datastore/common';
19-
import { has0xPrefix } from '@hirosystems/api-toolkit';
19+
import { has0xPrefix, parseBoolean } from '@hirosystems/api-toolkit';
2020

2121
import { FastifyPluginAsync } from 'fastify';
2222
import { Server } from 'node:http';
@@ -318,43 +318,46 @@ export const TxRoutes: FastifyPluginAsync<
318318
}
319319
);
320320

321-
fastify.get(
322-
'/mempool/dropped',
323-
{
324-
preHandler: handleMempoolCache,
325-
schema: {
326-
operationId: 'get_dropped_mempool_transaction_list',
327-
summary: 'Get dropped mempool transactions',
328-
description: `Retrieves all recently-broadcast transactions that have been dropped from the mempool.
329-
330-
Transactions are dropped from the mempool if:
331-
* they were stale and awaiting garbage collection or,
332-
* were expensive, or
333-
* were replaced with a new fee`,
334-
tags: ['Transactions'],
335-
querystring: Type.Object({
336-
offset: OffsetParam(),
337-
limit: LimitParam(ResourceType.Tx),
338-
}),
339-
response: {
340-
200: PaginatedResponse(MempoolTransactionSchema, {
341-
description: 'List of dropped mempool transactions',
321+
if (parseBoolean(process.env['STACKS_API_ENABLE_LEGACY_ENDPOINTS'])) {
322+
fastify.get(
323+
'/mempool/dropped',
324+
{
325+
preHandler: handleMempoolCache,
326+
schema: {
327+
deprecated: true,
328+
operationId: 'get_dropped_mempool_transaction_list',
329+
summary: 'Get dropped mempool transactions',
330+
description: `Retrieves all recently-broadcast transactions that have been dropped from the mempool.
331+
332+
Transactions are dropped from the mempool if:
333+
* they were stale and awaiting garbage collection or,
334+
* were expensive, or
335+
* were replaced with a new fee`,
336+
tags: ['Transactions'],
337+
querystring: Type.Object({
338+
offset: OffsetParam(),
339+
limit: LimitParam(ResourceType.Tx),
342340
}),
341+
response: {
342+
200: PaginatedResponse(MempoolTransactionSchema, {
343+
description: 'List of dropped mempool transactions',
344+
}),
345+
},
343346
},
344347
},
345-
},
346-
async (req, reply) => {
347-
const limit = getPagingQueryLimit(ResourceType.Tx, req.query.limit);
348-
const offset = parsePagingQueryInput(req.query.offset ?? 0);
349-
const { results: txResults, total } = await fastify.db.getDroppedTxs({
350-
offset,
351-
limit,
352-
});
353-
const results = txResults.map(tx => parseDbMempoolTx(tx));
354-
const response = { limit, offset, total, results };
355-
await reply.send(response);
356-
}
357-
);
348+
async (req, reply) => {
349+
const limit = getPagingQueryLimit(ResourceType.Tx, req.query.limit);
350+
const offset = parsePagingQueryInput(req.query.offset ?? 0);
351+
const { results: txResults, total } = await fastify.db.getDroppedTxs({
352+
offset,
353+
limit,
354+
});
355+
const results = txResults.map(tx => parseDbMempoolTx(tx));
356+
const response = { limit, offset, total, results };
357+
await reply.send(response);
358+
}
359+
);
360+
}
358361

359362
fastify.get(
360363
'/mempool/stats',

tests/api/setup.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ export default (): void => {
88
}
99
loadDotEnv();
1010
process.env.PG_DATABASE = 'postgres';
11+
process.env.STACKS_API_ENABLE_LEGACY_ENDPOINTS = '1';
1112
console.log('Jest - setup done');
1213
};

0 commit comments

Comments
 (0)