Fix local timediff

This commit is contained in:
Kusakabe Si 2021-12-09 21:29:05 +00:00
parent 17fe0cdae3
commit 7ef762b6b0

View File

@ -309,9 +309,12 @@ func (device *Device) server_process_Pong(peer *Peer, content mtypes.PongMsg) er
func (device *Device) process_ping(peer *Peer, content mtypes.PingMsg) error {
Timediff := device.graph.GetCurrentTime().Sub(content.Time).Seconds()
NewTimediff := peer.SingleWayLatency.Load().(float64)
DR := NewTimediff * device.EdgeConfig.DynamicRoute.P2P.GraphRecalculateSetting.DampingResistance
NewTimediff = NewTimediff*DR + Timediff*(1-DR)
OldTimediff := peer.SingleWayLatency.Load().(float64)
NewTimediff := Timediff
if OldTimediff <= mtypes.Infinity {
DR := device.EdgeConfig.DynamicRoute.P2P.GraphRecalculateSetting.DampingResistance
NewTimediff = OldTimediff*DR + Timediff*(1-DR)
}
peer.SingleWayLatency.Store(NewTimediff)
PongMSG := mtypes.PongMsg{