MCPcopy Index your code
hub / github.com/Bitmessage/PyBitmessage / antiIntersectionDelay

Method antiIntersectionDelay

src/network/tcp.py:78–92  ·  view source on GitHub ↗
(self, initial = False)

Source from the content-addressed store, hash-verified

76 self.set_state("bm_header", expectBytes=protocol.Header.size)
77
78 def antiIntersectionDelay(self, initial = False):
79 # estimated time for a small object to propagate across the whole network
80 delay = math.ceil(math.log(max(len(knownnodes.knownNodes[x]) for x in knownnodes.knownNodes) + 2, 20)) * (0.2 + invQueue.queueCount/2.0)
81 # take the stream with maximum amount of nodes
82 # +2 is to avoid problems with log(0) and log(1)
83 # 20 is avg connected nodes count
84 # 0.2 is avg message transmission time
85 if delay > 0:
86 if initial:
87 self.skipUntil = self.connectedAt + delay
88 if self.skipUntil > time.time():
89 logger.debug("Initial skipping processing getdata for %.2fs", self.skipUntil - time.time())
90 else:
91 logger.debug("Skipping processing getdata due to missing object for %.2fs", delay)
92 self.skipUntil = time.time() + delay
93
94 def state_connection_fully_established(self):
95 self.set_connection_fully_established()

Callers 2

bm_command_getdataMethod · 0.45

Calls 1

logMethod · 0.80

Tested by

no test coverage detected