mirror of https://github.com/dirtbags/moth.git
go fmt
This commit is contained in:
parent
ac242d0aa9
commit
5be46ca55a
|
@ -103,7 +103,7 @@ func (ctx *Instance) answerHandler(w http.ResponseWriter, req *http.Request) {
|
||||||
pointstr := req.FormValue("points")
|
pointstr := req.FormValue("points")
|
||||||
answer := req.FormValue("answer")
|
answer := req.FormValue("answer")
|
||||||
|
|
||||||
if ! ctx.ValidTeamId(teamId) {
|
if !ctx.ValidTeamId(teamId) {
|
||||||
respond(
|
respond(
|
||||||
w, req, JSendFail,
|
w, req, JSendFail,
|
||||||
"Invalid team ID",
|
"Invalid team ID",
|
||||||
|
|
|
@ -28,7 +28,7 @@ type Instance struct {
|
||||||
jPointsLog []byte
|
jPointsLog []byte
|
||||||
nextAttempt map[string]time.Time
|
nextAttempt map[string]time.Time
|
||||||
nextAttemptMutex *sync.RWMutex
|
nextAttemptMutex *sync.RWMutex
|
||||||
mux *http.ServeMux
|
mux *http.ServeMux
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *Instance) Initialize() error {
|
func (ctx *Instance) Initialize() error {
|
||||||
|
@ -132,15 +132,15 @@ func (ctx *Instance) ThemePath(parts ...string) string {
|
||||||
|
|
||||||
func (ctx *Instance) TooFast(teamId string) bool {
|
func (ctx *Instance) TooFast(teamId string) bool {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
ctx.nextAttemptMutex.RLock()
|
ctx.nextAttemptMutex.RLock()
|
||||||
next, _ := ctx.nextAttempt[teamId]
|
next, _ := ctx.nextAttempt[teamId]
|
||||||
ctx.nextAttemptMutex.RUnlock()
|
ctx.nextAttemptMutex.RUnlock()
|
||||||
|
|
||||||
ctx.nextAttemptMutex.Lock()
|
ctx.nextAttemptMutex.Lock()
|
||||||
ctx.nextAttempt[teamId] = now.Add(ctx.AttemptInterval)
|
ctx.nextAttempt[teamId] = now.Add(ctx.AttemptInterval)
|
||||||
ctx.nextAttemptMutex.Unlock()
|
ctx.nextAttemptMutex.Unlock()
|
||||||
|
|
||||||
return now.Before(next)
|
return now.Before(next)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue