Skip to content

Commit 4ecf282

Browse files
authored
Merge pull request #4 from persistenceOne/puneet/updatedeps
fix simultaneous threading of faucet loop
2 parents 20ff0de + 887d933 commit 4ecf282

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

.env.local

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ PREFIX="persistence"
99
GAS_PRICE="0.025uxprt"
1010
IP_WINDOW=86400000
1111
IP_DRIP_LIMIT=10
12-
FAUCET_SLEEP=10000
12+
FAUCET_SLEEP=2000
1313
HD_PATH="m/44'/118'/0'/0/0"

faucet.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,15 @@ async function MnemonicWalletWithPassphrase(mnemonic) {
4949

5050
}
5151

52-
function runner() {
52+
function delay(x) {
53+
return new Promise((done, fail) => setTimeout(done, x));
54+
}
55+
56+
async function runner() {
5357
console.log("started faucet loop")
54-
setInterval(async function () {
58+
59+
// noinspection InfiniteLoopJS
60+
while (true) {
5561
if (constants.FaucetList.length > 0) {
5662
try {
5763
let [wallet, addr] = await MnemonicWalletWithPassphrase(mnemonic);
@@ -81,7 +87,8 @@ function runner() {
8187
} else {
8288
console.log("No Accounts to faucet");
8389
}
84-
}, constants.FAUCET_SLEEP);
90+
await delay(constants.FAUCET_SLEEP) // this allows the function to be async
91+
}
8592
}
8693

8794
function handleFaucetRequest(userAddress) {

0 commit comments

Comments
 (0)