Skip to content

Commit 977dad2

Browse files
committed
fix timestamps overflow add bug in SanityCheckPeers
1 parent f615802 commit 977dad2

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

rpc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ func (s *SnowflakeRPC) DatacenterId(ignore int, dataCenterId *int64) error {
104104
return nil
105105
}
106106

107-
// Timestamp return the service current unixnano
107+
// Timestamp return the service current unix seconds.
108108
func (s *SnowflakeRPC) Timestamp(ignore int, timestamp *int64) error {
109-
*timestamp = time.Now().UnixNano()
109+
*timestamp = time.Now().Unix()
110110
return nil
111111
}
112112

zk.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func SanityCheckPeers() error {
214214
}
215215
// check 10s
216216
// calc avg timestamps
217-
now := time.Now().UnixNano()
217+
now := time.Now().Unix()
218218
avg := int64(timestamps / peerCount)
219219
log.Debug("timestamps: %d, peer: %d, avg: %d, now - avg: %d, maxdelay: %d", timestamps, peerCount, avg, now-avg, timestampMaxDelay)
220220
if now-avg > timestampMaxDelay {

0 commit comments

Comments
 (0)