p2pfl.communication.protocols.protobuff.heartbeater moduleΒΆ

Protocol agnostic heartbeater.

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

Bases: Thread, NodeComponent

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

TODO: Merge heartbeats to increase efficiency.

Parameters:
  • neighbors (Neighbors) – Neighbors to update.

  • build_msg (Callable[..., RootMessage])

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

set_addr(addr)[source]ΒΆ

Set the address.

Parameters:

addr (str)

Return type:

str

stop()[source]ΒΆ

Stop the heartbeat thread.

Return type:

None