fix cached id generation after system sleep

pull/1024/head
Darien Raymond 2018-04-06 22:02:52 +02:00
parent 8f7bdede4e
commit ee5bc8133a
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
1 changed files with 5 additions and 1 deletions

View File

@ -64,7 +64,11 @@ func (v *TimedUserValidator) generateNewHashes(nowSec protocol.Timestamp, user *
var hashValue [16]byte
genHashForID := func(id *protocol.ID) {
idHash := v.hasher(id.Bytes())
for ts := user.lastSec; ts <= nowSec; ts++ {
lastSec := user.lastSec
if lastSec < nowSec-cacheDurationSec*2 {
lastSec = nowSec - cacheDurationSec*2
}
for ts := lastSec; ts <= nowSec; ts++ {
common.Must2(idHash.Write(ts.Bytes(nil)))
idHash.Sum(hashValue[:0])
idHash.Reset()