revid: only set local clock if it hasn't already been set

This commit is contained in:
Trek H 2021-02-11 09:58:05 +10:30
parent 51c489946a
commit 0f9b06b266
1 changed files with 10 additions and 7 deletions

View File

@ -136,14 +136,17 @@ func extractMeta(r string, log func(lvl int8, msg string, args ...interface{}))
if err != nil {
return nil
}
// Extract time from reply
// Extract time from reply if mts.Realtime has not been set.
if !mts.RealTime.IsSet() {
t, err := dec.Int("ts")
if err != nil {
log(logger.Warning, "No timestamp in reply")
} else {
log(logger.Debug, fmt.Sprintf("got timestamp: %v", t))
fmt.Printf("got timestamp: %v, setting\n", t)
mts.RealTime.Set(time.Unix(int64(t), 0))
}
}
// Extract location from reply
g, err := dec.String("ll")