diff --git a/backend/src/event-handlers/rollup/index.js b/backend/src/event-handlers/rollup/index.js index 8bdcaaa..0dd031c 100644 --- a/backend/src/event-handlers/rollup/index.js +++ b/backend/src/event-handlers/rollup/index.js @@ -36,7 +36,7 @@ const start = async () => { expectedAuthors = await getBatchPostAuthorWeights(post.embeddedData.batchItems); } catch (e) { console.error('Error calculating batch post author weights', e); - return false; + return null; } const valid = authorsMatch(post.authors, expectedAuthors); console.log(`batch post ${pool.props.postId} is ${valid ? 'valid' : 'invalid'}`); @@ -45,11 +45,6 @@ const start = async () => { // Even if we're not the current batch worker, keep track of batch items initializeBatchItems(); - try { - batchItems = await applicationData.get('batchItems'); - } catch (e) { - batchItems = []; - } // Check for an assigned batch worker await initializeBatchWorker(); diff --git a/backend/src/event-handlers/validation-pools.js b/backend/src/event-handlers/validation-pools.js index 3a88b55..2d4ae35 100644 --- a/backend/src/event-handlers/validation-pools.js +++ b/backend/src/event-handlers/validation-pools.js @@ -40,8 +40,6 @@ const start = async () => { } console.log('postId:', pool.props.postId); console.log('post.content:', post.content); - const results = await Promise.mapSeries(deciders, (decider) => decider(pool, post)); - const inFavor = results.some((x) => x === true); // We have the opportunity to stake for/against this validation pool. // To implement the legislative process of upgrading this protocol, // the execution of this code can be protected by a given proposal. @@ -49,6 +47,15 @@ const start = async () => { if (!enableStaking) { return; } + const decisions = await Promise.mapSeries(deciders, (decider) => decider(pool, post)); + const inFavor = decisions.some((x) => x === true); + const nullResult = decisions.some((x) => x === null); + if (!inFavor && nullResult) { + console.log(`Obtained a NULL RESULT for pool ${poolIndex}. Abstaining from the vote.`); + // TODO: Retry? + // TODO: Notify + return; + } // Stake all available reputation const currentRep = await dao.balanceOf(await wallet.getAddress()); console.log(`STAKING ${currentRep} ${inFavor ? 'in favor of' : 'against'} pool ${poolIndex}`);