github.com/status-im/status-go@v1.1.0/protocol/v1/clock.go (about) 1 package protocol 2 3 import "time" 4 5 const clockBumpInMs = uint64(time.Minute / time.Millisecond) 6 7 // CalcMessageClock calculates a new clock value for Message. 8 // It is used to properly sort messages and accommodate the fact 9 // that time might be different on each device. 10 func CalcMessageClock(lastObservedValue uint64, timeInMs uint64) uint64 { 11 clock := lastObservedValue 12 if clock < timeInMs { 13 // Added time should be larger than time skew tollerance for a message. 14 // Here, we use 1 minute which is larger than accepted message time skew by Whisper. 15 clock = timeInMs + clockBumpInMs 16 } else { 17 clock++ 18 } 19 return clock 20 }