MCPcopy Index your code
hub / github.com/HelloZeroNet/ZeroNet / getTimecorrection

Method getTimecorrection

src/Connection/ConnectionServer.py:351–361  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

349 self.log.info("Internet offline")
350
351 def getTimecorrection(self):
352 corrections = sorted([
353 connection.handshake.get("time") - connection.handshake_time + connection.last_ping_delay
354 for connection in self.connections
355 if connection.handshake.get("time") and connection.last_ping_delay
356 ])
357 if len(corrections) < 6:
358 return 0.0
359 mid = int(len(corrections) / 2 - 1)
360 median = (corrections[mid - 1] + corrections[mid] + corrections[mid + 1]) / 3
361 return median

Callers 2

checkConnectionsMethod · 0.95
actionStatsMethod · 0.80

Calls 1

getMethod · 0.45

Tested by

no test coverage detected