Skip to content

Commit

Permalink
fix: mutex added to package.json & return mutex on checkLeaves
Browse files Browse the repository at this point in the history
  • Loading branch information
richimenendez committed May 3, 2024
1 parent d840832 commit ed2c517
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions merkle-tree/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"solc": "0.5.8",
"fs-extra": "^8.1.0",
"lodash": "^4.17.21",
"keccak": "^2.1.0"
"keccak": "^2.1.0",
"async-mutex": "^0.5.0"
},
"devDependencies": {
"@babel/cli": "^7.6.4",
Expand All @@ -39,4 +40,4 @@
"nodemon": "^3.0.1",
"mocha": "^10.2.0"
}
}
}
2 changes: 1 addition & 1 deletion merkle-tree/src/merkle-tree-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async function checkLeaves(db) {
// count all the leaves
// get the max leafIndex of all the leaves

await mutex.runExclusive(async () => {
return await mutex.runExclusive(async () => {
let { leafCount, maxLeafIndex } = await leafService.getCountAndMaxLeafIndex();
logger.debug(`leaf count: ${leafCount}, max leaf index: ${maxLeafIndex}`);
if (maxLeafIndex === undefined) maxLeafIndex = -1;
Expand Down

0 comments on commit ed2c517

Please # to comment.