From e02698ab9fa12b0bf5e424faffda1a7fc1e18603 Mon Sep 17 00:00:00 2001 From: zeus Date: Sun, 29 Nov 2020 20:27:48 +0200 Subject: [PATCH] prox --- swarmlab-app/src/run/app.js | 8 ++++++++ 1 file changed, 8 insertions(+) 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){