Merge pull request #863 from filecoin-project/feat/faucet-limits

Increase faucet limits
This commit is contained in:
Jakub Sztandera 2019-12-11 16:30:36 +01:00 committed by GitHub
commit 1c7a9cb64d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -100,7 +100,7 @@ var runCmd = &cli.Command{
IPRate: time.Minute, IPRate: time.Minute,
IPBurst: 5, IPBurst: 5,
WalletRate: 15 * time.Minute, WalletRate: 15 * time.Minute,
WalletBurst: 1, WalletBurst: 2,
}), }),
minerLimiter: NewLimiter(LimiterConfig{ minerLimiter: NewLimiter(LimiterConfig{
TotalRate: time.Second, TotalRate: time.Second,
@ -108,7 +108,7 @@ var runCmd = &cli.Command{
IPRate: 10 * time.Minute, IPRate: 10 * time.Minute,
IPBurst: 2, IPBurst: 2,
WalletRate: 1 * time.Hour, WalletRate: 1 * time.Hour,
WalletBurst: 1, WalletBurst: 2,
}), }),
} }
@ -150,7 +150,7 @@ func (h *handler) send(w http.ResponseWriter, r *http.Request) {
// Limit based on wallet address // Limit based on wallet address
limiter := h.limiter.GetWalletLimiter(to.String()) limiter := h.limiter.GetWalletLimiter(to.String())
if !limiter.Allow() { if !limiter.Allow() {
http.Error(w, http.StatusText(http.StatusTooManyRequests), http.StatusTooManyRequests) http.Error(w, http.StatusText(http.StatusTooManyRequests)+": wallet limit", http.StatusTooManyRequests)
return return
} }
@ -170,13 +170,13 @@ func (h *handler) send(w http.ResponseWriter, r *http.Request) {
limiter = h.limiter.GetIPLimiter(reqIP) limiter = h.limiter.GetIPLimiter(reqIP)
if !limiter.Allow() { if !limiter.Allow() {
http.Error(w, http.StatusText(http.StatusTooManyRequests), http.StatusTooManyRequests) http.Error(w, http.StatusText(http.StatusTooManyRequests)+": IP limit", http.StatusTooManyRequests)
return return
} }
// General limiter to allow throttling all messages that can make it into the mpool // General limiter to allow throttling all messages that can make it into the mpool
if !h.limiter.Allow() { if !h.limiter.Allow() {
http.Error(w, http.StatusText(http.StatusTooManyRequests), http.StatusTooManyRequests) http.Error(w, http.StatusText(http.StatusTooManyRequests)+": global limit", http.StatusTooManyRequests)
return return
} }
@ -221,20 +221,20 @@ func (h *handler) mkminer(w http.ResponseWriter, r *http.Request) {
// Limit based on wallet address // Limit based on wallet address
limiter := h.minerLimiter.GetWalletLimiter(owner.String()) limiter := h.minerLimiter.GetWalletLimiter(owner.String())
if !limiter.Allow() { if !limiter.Allow() {
http.Error(w, http.StatusText(http.StatusTooManyRequests), http.StatusTooManyRequests) http.Error(w, http.StatusText(http.StatusTooManyRequests)+": wallet limit", http.StatusTooManyRequests)
return return
} }
// Limit based on IP // Limit based on IP
limiter = h.minerLimiter.GetIPLimiter(r.RemoteAddr) limiter = h.minerLimiter.GetIPLimiter(r.RemoteAddr)
if !limiter.Allow() { if !limiter.Allow() {
http.Error(w, http.StatusText(http.StatusTooManyRequests), http.StatusTooManyRequests) http.Error(w, http.StatusText(http.StatusTooManyRequests)+": IP limit", http.StatusTooManyRequests)
return return
} }
// General limiter owner allow throttling all messages that can make it into the mpool // General limiter owner allow throttling all messages that can make it into the mpool
if !h.minerLimiter.Allow() { if !h.minerLimiter.Allow() {
http.Error(w, http.StatusText(http.StatusTooManyRequests), http.StatusTooManyRequests) http.Error(w, http.StatusText(http.StatusTooManyRequests)+": global limit", http.StatusTooManyRequests)
return return
} }