p2pfl.communication.protocols.heartbeater moduleΒΆ

Protocol agnostic heartbeater.

class p2pfl.communication.protocols.heartbeater.Heartbeater(self_addr, neighbors, client)[source]ΒΆ

Bases: Thread

Heartbeater for agnostic communication protocol. Send and update fresh heartbeats.

TODO: Merge heartbeats to increase efficiency.

Parameters:
  • self_addr (str) – Address of the node.

  • neighbors (Neighbors) – Neighbors to update.

  • client (Client) – Client to send messages.

beat(nei, time)[source]ΒΆ

Update the time of the last heartbeat of a neighbor. If the neighbor is not added, add it.

Parameters:
  • nei (str) – Address of the neighbor.

  • time (float) – Time of the heartbeat.

Return type:

None

run()[source]ΒΆ

Run the heartbeat thread.

Return type:

None

stop()[source]ΒΆ

Stop the heartbeat thread.

Return type:

None