diff --git a/swarmlab-app/src/run/app.js b/swarmlab-app/src/run/app.js index 81ffd38..7a578c9 100755 --- a/swarmlab-app/src/run/app.js +++ b/swarmlab-app/src/run/app.js @@ -430,6 +430,11 @@ cors(corsOptions), (req, res, next) => { //function getSHA256ofJSON(input){ // return require("crypto").createHash("sha256").update(JSON.stringify(input)).digest("hex"); //} + +function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} + function getSHA256ofJSON(data, inputEncoding, encoding){ if (!data) { return ''; @@ -444,6 +449,9 @@ function getSHA256ofJSON(data, inputEncoding, encoding){ async function getkey(key) { return new Promise((resolve) => { + const randomTimeInMs = Math.random() * (2000); + await sleep(randomTimeInMs); + pubClient.get(key, function (err, reply) { if(err){