Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
chore: use Set for BLOCKLIST_CONTRACT_IDS
Browse files Browse the repository at this point in the history
  • Loading branch information
kunstmusik committed Jan 18, 2024
1 parent 63aba2a commit f46e1f6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import { EvaluationOptions } from 'warp-contracts';

export const PREFETCH_CONTRACTS = process.env.PREFETCH_CONTRACTS === 'true';
export const BOOTSTRAP_CACHE = process.env.BOOTSTRAP_CACHE === 'true';
export const BLOCKLISTED_CONTRACT_IDS = process.env.BLOCKLISTED_CONTRACT_IDS
export const BLOCKLISTED_CONTRACT_IDS = new Set(
process.env.BLOCKLISTED_CONTRACT_IDS
? process.env.BLOCKLISTED_CONTRACT_IDS.split(',')
: ['fbU8Y4NMKKzP4rmAYeYj6tDrVDo9XNbdyq5IZPA31WQ'];
: ['fbU8Y4NMKKzP4rmAYeYj6tDrVDo9XNbdyq5IZPA31WQ']);
export const ARWEAVE_TX_ID_REGEX = '([a-zA-Z0-9-_s+]{43})';
export const ARNS_NAME_REGEX = '([a-zA-Z0-9-s+]{1,51})';
export const SUB_CONTRACT_EVALUATION_TIMEOUT_MS = 10_000; // 10 sec state timeout - non configurable
Expand Down
2 changes: 1 addition & 1 deletion src/middleware/blocklist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { blockListedContractCount } from '../metrics';

export async function blocklistMiddleware(ctx: KoaContext, next: Next) {
const { contractTxId } = ctx.params;
if (BLOCKLISTED_CONTRACT_IDS.includes(contractTxId)) {
if (BLOCKLISTED_CONTRACT_IDS.has(contractTxId)) {
blockListedContractCount
.labels({
contractTxId,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export async function walletContractHandler(ctx: KoaContext) {
await Promise.allSettled(
[...deployedOrOwned].map(async (id: string) => {
// do not evaluate any blocklisted contracts
if (BLOCKLISTED_CONTRACT_IDS.includes(id)) {
if (BLOCKLISTED_CONTRACT_IDS.has(id)) {
logger.debug('Skipping blocklisted contract.', {
contractTxId: id,
});
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5752,7 +5752,7 @@ lines-and-columns@^1.1.6:
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632"
integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==

[email protected], lmdb@^2.9.0:
[email protected], lmdb@^2.9.2:
version "2.9.2"
resolved "https://registry.yarnpkg.com/lmdb/-/lmdb-2.9.2.tgz#a67ed24cad282ba7ad21daf2a8a13c08dcb33f56"
integrity sha512-Q5SQzu4u4sdz4U8QT1uCS04beS7hS/1YYb1suJwaijqVETGAkrPBKr0ERxTeza/u2F6ei5+8UTnzm4ae3PJG3w==
Expand Down

0 comments on commit f46e1f6

Please sign in to comment.