From 72e16651fba196dd8b40f581e3499c3ddd216056 Mon Sep 17 00:00:00 2001 From: Ladd Hoffman Date: Thu, 9 May 2024 12:06:09 -0500 Subject: [PATCH] minor refactor, add additional subdir for rollup --- .../event-handlers/rollup/{ => batch}/batch-items.js | 2 +- .../rollup/{ => batch}/batch-worker.js | 2 +- .../rollup/{ => batch}/compute-author-weights.js | 4 ++-- .../{ => batch}/compute-author-weights.test.js | 0 .../rollup/{ => batch}/fetch-batch-items-info.js | 2 +- .../rollup/{ => batch}/submit-rollup.js | 12 ++++++------ backend/src/event-handlers/rollup/index.js | 6 +++--- .../event-handlers/rollup/matrix-pools/evaluate.js | 6 +++--- .../rollup/matrix-pools/initiate-matrix-pools.js | 4 ++-- 9 files changed, 19 insertions(+), 19 deletions(-) rename backend/src/event-handlers/rollup/{ => batch}/batch-items.js (93%) rename backend/src/event-handlers/rollup/{ => batch}/batch-worker.js (92%) rename backend/src/event-handlers/rollup/{ => batch}/compute-author-weights.js (92%) rename backend/src/event-handlers/rollup/{ => batch}/compute-author-weights.test.js (100%) rename backend/src/event-handlers/rollup/{ => batch}/fetch-batch-items-info.js (84%) rename backend/src/event-handlers/rollup/{ => batch}/submit-rollup.js (87%) diff --git a/backend/src/event-handlers/rollup/batch-items.js b/backend/src/event-handlers/rollup/batch/batch-items.js similarity index 93% rename from backend/src/event-handlers/rollup/batch-items.js rename to backend/src/event-handlers/rollup/batch/batch-items.js index 71f1253..e753a88 100644 --- a/backend/src/event-handlers/rollup/batch-items.js +++ b/backend/src/event-handlers/rollup/batch/batch-items.js @@ -1,4 +1,4 @@ -const { applicationData } = require('../../util/db'); +const { applicationData } = require('../../../util/db'); let batchItems; diff --git a/backend/src/event-handlers/rollup/batch-worker.js b/backend/src/event-handlers/rollup/batch/batch-worker.js similarity index 92% rename from backend/src/event-handlers/rollup/batch-worker.js rename to backend/src/event-handlers/rollup/batch/batch-worker.js index ffa3607..e7e84f3 100644 --- a/backend/src/event-handlers/rollup/batch-worker.js +++ b/backend/src/event-handlers/rollup/batch/batch-worker.js @@ -1,4 +1,4 @@ -const { rollup, wallet } = require('../../util/contracts'); +const { rollup, wallet } = require('../../../util/contracts'); let batchWorker; let batchStart; diff --git a/backend/src/event-handlers/rollup/compute-author-weights.js b/backend/src/event-handlers/rollup/batch/compute-author-weights.js similarity index 92% rename from backend/src/event-handlers/rollup/compute-author-weights.js rename to backend/src/event-handlers/rollup/batch/compute-author-weights.js index c9d8b3c..bf39d06 100644 --- a/backend/src/event-handlers/rollup/compute-author-weights.js +++ b/backend/src/event-handlers/rollup/batch/compute-author-weights.js @@ -1,6 +1,6 @@ const Promise = require('bluebird'); -const read = require('../../util/forum/read'); -const { matrixPools } = require('../../util/db'); +const read = require('../../../util/forum/read'); +const { matrixPools } = require('../../../util/db'); const computeAuthorWeights = async (batchItems_) => { const weights = {}; diff --git a/backend/src/event-handlers/rollup/compute-author-weights.test.js b/backend/src/event-handlers/rollup/batch/compute-author-weights.test.js similarity index 100% rename from backend/src/event-handlers/rollup/compute-author-weights.test.js rename to backend/src/event-handlers/rollup/batch/compute-author-weights.test.js diff --git a/backend/src/event-handlers/rollup/fetch-batch-items-info.js b/backend/src/event-handlers/rollup/batch/fetch-batch-items-info.js similarity index 84% rename from backend/src/event-handlers/rollup/fetch-batch-items-info.js rename to backend/src/event-handlers/rollup/batch/fetch-batch-items-info.js index 352c304..fd73810 100644 --- a/backend/src/event-handlers/rollup/fetch-batch-items-info.js +++ b/backend/src/event-handlers/rollup/batch/fetch-batch-items-info.js @@ -1,4 +1,4 @@ -const { rollup } = require('../../util/contracts'); +const { rollup } = require('../../../util/contracts'); const fetchBatchItemsInfo = async () => { // Read from Rollup.items diff --git a/backend/src/event-handlers/rollup/submit-rollup.js b/backend/src/event-handlers/rollup/batch/submit-rollup.js similarity index 87% rename from backend/src/event-handlers/rollup/submit-rollup.js rename to backend/src/event-handlers/rollup/batch/submit-rollup.js index b73958f..cf60abd 100644 --- a/backend/src/event-handlers/rollup/submit-rollup.js +++ b/backend/src/event-handlers/rollup/batch/submit-rollup.js @@ -1,13 +1,13 @@ const { v4: uuidv4 } = require('uuid'); -const write = require('../../util/forum/write'); -const addPostWithRetry = require('../../util/add-post-with-retry'); -const callWithRetry = require('../../util/call-with-retry'); +const write = require('../../../util/forum/write'); +const addPostWithRetry = require('../../../util/add-post-with-retry'); +const callWithRetry = require('../../../util/call-with-retry'); const { getBatchItems, clearBatchItems } = require('./batch-items'); const computeAuthorWeights = require('./compute-author-weights'); -const { wallet, rollup } = require('../../util/contracts'); -const { sendMatrixEvent } = require('../../matrix-bot'); -const { stakeRollupAvailability } = require('./utils'); +const { wallet, rollup } = require('../../../util/contracts'); +const { sendMatrixEvent } = require('../../../matrix-bot'); +const { stakeRollupAvailability } = require('../utils'); const fetchBatchItemsInfo = require('./fetch-batch-items-info'); const submitRollup = async () => { diff --git a/backend/src/event-handlers/rollup/index.js b/backend/src/event-handlers/rollup/index.js index 74ec882..0c967ec 100644 --- a/backend/src/event-handlers/rollup/index.js +++ b/backend/src/event-handlers/rollup/index.js @@ -12,11 +12,11 @@ const { stakeRollupAvailability, authorsMatch, validatePost, } = require('./utils'); const computeMatrixPoolResult = require('./matrix-pools/compute-result'); -const { initializeBatchItems, addBatchItem, clearBatchItems } = require('./batch-items'); -const { getCurrentBatchWorker, initializeBatchWorker } = require('./batch-worker'); +const { initializeBatchItems, addBatchItem, clearBatchItems } = require('./batch/batch-items'); +const { getCurrentBatchWorker, initializeBatchWorker } = require('./batch/batch-worker'); const initiateMatrixPool = require('./matrix-pools/initiate'); const { initiateMatrixPools } = require('./matrix-pools/initiate-matrix-pools'); -const computeAuthorWeights = require('./compute-author-weights'); +const computeAuthorWeights = require('./batch/compute-author-weights'); const start = async () => { console.log('registering validation pool decider for rollup'); diff --git a/backend/src/event-handlers/rollup/matrix-pools/evaluate.js b/backend/src/event-handlers/rollup/matrix-pools/evaluate.js index 07317bc..a082f86 100644 --- a/backend/src/event-handlers/rollup/matrix-pools/evaluate.js +++ b/backend/src/event-handlers/rollup/matrix-pools/evaluate.js @@ -1,11 +1,11 @@ const { sendMatrixEvent } = require('../../../matrix-bot'); const { wallet } = require('../../../util/contracts'); const { matrixPools } = require('../../../util/db'); -const { addBatchItem, getBatchItems } = require('../batch-items'); -const { getCurrentBatchWorker, getBatchAge } = require('../batch-worker'); +const { addBatchItem, getBatchItems } = require('../batch/batch-items'); +const { getCurrentBatchWorker, getBatchAge } = require('../batch/batch-worker'); const computeMatrixPoolResult = require('./compute-result'); const { rollupInterval } = require('../config'); -const submitRollup = require('../submit-rollup'); +const submitRollup = require('../batch/submit-rollup'); const { stakeRollupAvailability } = require('../utils'); const evaluateMatrixPoolOutcome = async (postId) => { diff --git a/backend/src/event-handlers/rollup/matrix-pools/initiate-matrix-pools.js b/backend/src/event-handlers/rollup/matrix-pools/initiate-matrix-pools.js index 068e1ad..3ffef52 100644 --- a/backend/src/event-handlers/rollup/matrix-pools/initiate-matrix-pools.js +++ b/backend/src/event-handlers/rollup/matrix-pools/initiate-matrix-pools.js @@ -2,8 +2,8 @@ const Promise = require('bluebird'); const { matrixPools } = require('../../../util/db'); const read = require('../../../util/forum/read'); const initiateMatrixPool = require('./initiate'); -const { addBatchItem, getBatchItems } = require('../batch-items'); -const fetchBatchItemsInfo = require('../fetch-batch-items-info'); +const { addBatchItem, getBatchItems } = require('../batch/batch-items'); +const fetchBatchItemsInfo = require('../batch/fetch-batch-items-info'); const initiateMatrixPools = async () => { const batchItemsInfo = await fetchBatchItemsInfo();