p2pfl.communication.protocols.protobuff.memory.server moduleΒΆ

In-memory server.

class p2pfl.communication.protocols.protobuff.memory.server.AddressCounter[source]ΒΆ

Bases: object

Singleton address counter with efficient address tracking.

get(base_name)[source]ΒΆ

Get a unique address based on the given base name.

Parameters:

base_name (str) – The base name for the address. If empty, β€œnode” will be used.

Return type:

str

Returns:

A unique address string

class p2pfl.communication.protocols.protobuff.memory.server.MemoryServer(gossiper, neighbors, commands=None)[source]ΒΆ

Bases: ProtobuffServer

Implementation of the server side logic of Memory communication protocol.

Parameters:
  • addr – Address of the server.

  • gossiper (Gossiper) – Gossiper instance.

  • neighbors (Neighbors) – Neighbors instance.

  • commands (list[Command] | None) – List of commands to be executed by the server.

is_running()[source]ΒΆ

Check if the server is running.

Return type:

bool

Returns:

True if the server is running, False otherwise.

set_addr(addr)[source]ΒΆ

Set the addr of the node.

Parameters:

addr (str)

Return type:

str

start(wait=False)[source]ΒΆ

Start the in-memory server.

Parameters:

wait (bool) – If True, wait for termination.

Return type:

None

stop()[source]ΒΆ

Stop the in-memory server.

Return type:

None

wait_for_termination()[source]ΒΆ

Wait for termination.

Return type:

None