cmd/faucet: make grace period dynamic based on original wait time

This commit is contained in:
Péter Szilágyi 2019-07-23 12:35:44 +03:00
parent 35efe8d8f4
commit f60cbb7f0d
No known key found for this signature in database
GPG key ID: E9AE538CEDF8293D

View file

@ -506,7 +506,10 @@ func (f *faucet) apiHandler(conn *websocket.Conn) {
Time: time.Now(), Time: time.Now(),
Tx: signed, Tx: signed,
}) })
f.timeouts[username] = time.Now().Add(time.Duration(*minutesFlag*int(math.Pow(3, float64(msg.Tier)))-5) * time.Minute) timeout := time.Duration(*minutesFlag*int(math.Pow(3, float64(msg.Tier)))) * time.Minute
grace := timeout / 288 // 24h timeout => 5m grace
f.timeouts[username] = time.Now().Add(timeout - grace)
fund = true fund = true
} }
f.lock.Unlock() f.lock.Unlock()