diff --git a/servers/mu/src/config.js b/servers/mu/src/config.js index 985bc829a..c9ead1431 100644 --- a/servers/mu/src/config.js +++ b/servers/mu/src/config.js @@ -57,7 +57,8 @@ export const domainConfigSchema = z.object({ TASK_QUEUE_MAX_RETRIES: positiveIntSchema, TASK_QUEUE_RETRY_DELAY: positiveIntSchema, DISABLE_TRACE: z.boolean(), - SPAWN_PUSH_ENABLED: z.boolean() + SPAWN_PUSH_ENABLED: z.boolean(), + ALLOW_PUSHES_AFTER: z.number() }) /** @@ -102,7 +103,8 @@ const CONFIG_ENVS = { TASK_QUEUE_MAX_RETRIES: process.env.TASK_QUEUE_MAX_RETRIES || 5, TASK_QUEUE_RETRY_DELAY: process.env.TASK_QUEUE_RETRY_DELAY || 1000, DISABLE_TRACE: process.env.DISABLE_TRACE !== 'false', - SPAWN_PUSH_ENABLED: process.env.SPAWN_PUSH_ENABLED === 'true' + SPAWN_PUSH_ENABLED: process.env.SPAWN_PUSH_ENABLED === 'true', + ALLOW_PUSHES_AFTER: process.env.ALLOW_PUSHES_AFTER || 1572103 }, production: { MODE, @@ -124,7 +126,8 @@ const CONFIG_ENVS = { TASK_QUEUE_MAX_RETRIES: process.env.TASK_QUEUE_MAX_RETRIES || 5, TASK_QUEUE_RETRY_DELAY: process.env.TASK_QUEUE_RETRY_DELAY || 1000, DISABLE_TRACE: process.env.DISABLE_TRACE !== 'false', - SPAWN_PUSH_ENABLED: process.env.SPAWN_PUSH_ENABLED === 'true' + SPAWN_PUSH_ENABLED: process.env.SPAWN_PUSH_ENABLED === 'true', + ALLOW_PUSHES_AFTER: process.env.ALLOW_PUSHES_AFTER || 1572103 } } diff --git a/servers/mu/src/domain/api/pushMsg.js b/servers/mu/src/domain/api/pushMsg.js index 63b8ca134..1f52d87e1 100644 --- a/servers/mu/src/domain/api/pushMsg.js +++ b/servers/mu/src/domain/api/pushMsg.js @@ -2,7 +2,6 @@ import { Rejected, Resolved, fromPromise, of } from 'hyper-async' import { getCuAddressWith } from '../lib/get-cu-address.js' import { pullResultWith } from '../lib/pull-result.js' -import { graphqlReturnSchema } from '../dal.js' export function pushMsgWith ({ selectNode, @@ -10,6 +9,7 @@ export function pushMsgWith ({ fetchTransactions, crank, logger, + ALLOW_PUSHES_AFTER }) { const getCuAddress = getCuAddressWith({ selectNode, logger }) const pullResult = pullResultWith({ fetchResult, logger }) @@ -22,9 +22,8 @@ export function pushMsgWith ({ }) .chain(res => { if(res?.data?.transactions?.edges?.length >= 1) { - if(res.data.transactions.edges[0].block?.timestamp) { - const oneDayAgo = Date.now() - 24 * 60 * 60 * 1000; - if (res.data.transactions.edges[0].block.timestamp >= oneDayAgo) { + if(res.data.transactions.edges[0].block?.height) { + if (res.data.transactions.edges[0].block.height >= ALLOW_PUSHES_AFTER) { return Resolved(ctx) } } diff --git a/servers/mu/src/domain/api/pushMsg.test.js b/servers/mu/src/domain/api/pushMsg.test.js index c610c45d1..d32759aff 100644 --- a/servers/mu/src/domain/api/pushMsg.test.js +++ b/servers/mu/src/domain/api/pushMsg.test.js @@ -30,7 +30,7 @@ describe('pushMsgWith', () => { transactions: { edges: [ { - block: { timestamp: Date.now() } + block: { height: 1572105 } } ] } @@ -42,6 +42,7 @@ describe('pushMsgWith', () => { return Resolved() }, logger, + ALLOW_PUSHES_AFTER: 1572103 }) const { crank } = await pushMsg({ diff --git a/servers/mu/src/domain/index.js b/servers/mu/src/domain/index.js index 8b7c3bf2a..260c33323 100644 --- a/servers/mu/src/domain/index.js +++ b/servers/mu/src/domain/index.js @@ -86,6 +86,7 @@ export const createApis = async (ctx) => { const PROC_FILE_PATH = ctx.PROC_FILE_PATH const CRON_CURSOR_DIR = ctx.CRON_CURSOR_DIR const SPAWN_PUSH_ENABLED = ctx.SPAWN_PUSH_ENABLED + const ALLOW_PUSHES_AFTER = ctx.ALLOW_PUSHES_AFTER const logger = ctx.logger const fetch = ctx.fetch @@ -300,7 +301,8 @@ export const createApis = async (ctx) => { fetchResult: cuClient.resultWith({ fetch: fetchWithCache, histogram, CU_URL, logger: sendDataItemLogger }), crank, logger: pushMsgItemLogger, - fetchTransactions: gatewayClient.fetchTransactionDetailsWith({ fetch, GRAPHQL_URL }) + fetchTransactions: gatewayClient.fetchTransactionDetailsWith({ fetch, GRAPHQL_URL }), + ALLOW_PUSHES_AFTER }) return {