Skip to content

Commit

Permalink
Fix cooldown value
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Jul 12, 2022
1 parent 09f3e0a commit 86d9edb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to

## [Unreleased]

### Fixed

- @cosmjs/faucet: Fix cooldown value from 86 seconds to 24 hours.

## [0.28.10] - 2022-06-29

### Fixed
Expand Down
5 changes: 3 additions & 2 deletions packages/faucet/src/api/webserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ export class Webserver {

const entry = this.addressCounter.get(address);
if (entry !== undefined) {
if (entry.getTime() + 24 * 3600 > Date.now()) {
const cooldownMs = constants.cooldown * 3600 * 1000;
if (entry.getTime() + cooldownMs > Date.now()) {
throw new HttpError(
405,
"Too many request from the same address. Blocked to prevent draining. Please wait 24h and try it again!",
`Too many request for the same address. Blocked to prevent draining. Please wait ${constants.cooldown}h and try it again!`,
);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/faucet/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ export const pathPattern = process.env.FAUCET_PATH_PATTERN || "m/44'/118'/0'/0/a
export const tokenConfig: TokenConfiguration = {
bankTokens: parseBankTokens(process.env.FAUCET_TOKENS || "ucosm, ustake"),
};
export const cooldown = 24; // hours

0 comments on commit 86d9edb

Please sign in to comment.