1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-02-20 23:47:21 -05:00

simpilify updateUserHash method

This commit is contained in:
v2ray 2016-06-04 19:59:23 +02:00
parent 798c870069
commit ea8f7e7506

View File

@ -50,7 +50,7 @@ func NewTimedUserValidator(hasher IDHash) UserValidator {
hasher: hasher, hasher: hasher,
cancel: signal.NewCloseSignal(), cancel: signal.NewCloseSignal(),
} }
go tus.updateUserHash(updateIntervalSec*time.Second, tus.cancel) go tus.updateUserHash(updateIntervalSec * time.Second)
return tus return tus
} }
@ -88,7 +88,7 @@ func (this *TimedUserValidator) generateNewHashes(nowSec Timestamp, idx int, ent
} }
} }
func (this *TimedUserValidator) updateUserHash(interval time.Duration, cancel *signal.CancelSignal) { func (this *TimedUserValidator) updateUserHash(interval time.Duration) {
L: L:
for { for {
select { select {
@ -97,11 +97,11 @@ L:
for _, entry := range this.ids { for _, entry := range this.ids {
this.generateNewHashes(nowSec, entry.userIdx, entry) this.generateNewHashes(nowSec, entry.userIdx, entry)
} }
case <-cancel.WaitForCancel(): case <-this.cancel.WaitForCancel():
break L break L
} }
} }
cancel.Done() this.cancel.Done()
} }
func (this *TimedUserValidator) Add(user *User) error { func (this *TimedUserValidator) Add(user *User) error {