Skip to content

Commit

Permalink
refactor: refactor code to remove unused total
Browse files Browse the repository at this point in the history
  • Loading branch information
asimm241 authored and zone117x committed Oct 6, 2020
1 parent 4bb146d commit 97d38fb
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
6 changes: 1 addition & 5 deletions src/api/routes/rosetta/mempool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ export function createRosettaMempoolRouter(db: DataStore): RouterWithAsync {
return;
}

// const limit = req.body.metadata
// ? parseMempoolTxQueryLimit(req.body.metadata.limit ?? 100)
// : 100;
// const offset = req.body.metadata ? parsePagingQueryInput(req.body.metadata.offset ?? 0) : 0;
const { results: txResults, total } = await db.getMempoolTxIdList();
const { results: txResults } = await db.getMempoolTxIdList();

const transaction_identifiers = txResults.map(tx => {
return { hash: tx.tx_id };
Expand Down
2 changes: 1 addition & 1 deletion src/datastore/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export interface DataStore extends DataStoreEventEmitter {
limit: number;
offset: number;
}): Promise<{ results: DbMempoolTx[]; total: number }>;
getMempoolTxIdList(): Promise<{ results: DbMempoolTxId[]; total: number }>;
getMempoolTxIdList(): Promise<{ results: DbMempoolTxId[] }>;
getTx(txId: string): Promise<FoundOrNot<DbTx>>;
getTxList(args: {
limit: number;
Expand Down
2 changes: 1 addition & 1 deletion src/datastore/memory-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class MemoryDataStore extends (EventEmitter as { new (): DataStoreEventEm
throw new Error('not yet implemented');
}

getMempoolTxIdList(): Promise<{ results: DbMempoolTx[]; total: number }> {
getMempoolTxIdList(): Promise<{ results: DbMempoolTx[] }> {
throw new Error('not yet implemented');
}

Expand Down
10 changes: 2 additions & 8 deletions src/datastore/postgres-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1152,13 +1152,7 @@ export class PgDataStore extends (EventEmitter as { new (): DataStoreEventEmitte
return { results: parsed, total: totalQuery.rows[0].count };
}

async getMempoolTxIdList(): Promise<{ results: DbMempoolTxId[]; total: number }> {
const totalQuery = await this.pool.query<{ count: number }>(
`
SELECT COUNT(*)::integer
FROM mempool_txs
`
);
async getMempoolTxIdList(): Promise<{ results: DbMempoolTxId[] }> {
const resultQuery = await this.pool.query<MempoolTxIdQueryResult>(
`
SELECT ${MEMPOOL_TX_ID_COLUMNS}
Expand All @@ -1172,7 +1166,7 @@ export class PgDataStore extends (EventEmitter as { new (): DataStoreEventEmitte
};
return tx;
});
return { results: parsed, total: totalQuery.rows[0].count };
return { results: parsed };
}

async getTx(txId: string) {
Expand Down

0 comments on commit 97d38fb

Please sign in to comment.