Network

Network

class Network(**kwargs)

Implements the network api endpoints.

disconnect(peer_address: str, **kwargs) None

Disconnect from a node.

Parameters:
  • peer_address (str) – The peer endpoint.

  • **kwargs – Extra keyword arguments.

Returns:

None

Raises:

APIError – Error thrown by node API. See message for details.

set_ban(ban_command: str, ban_duration_seconds: int, peer_address: str, **kwargs) None

Set a banned node.

Parameters:
  • ban_command (str) – Allowed commands [add, remove].

  • ban_duration_seconds (int) – The ban duration in seconds.

  • peer_address (str) – The peer address to ban/unban.

  • **kwargs – Extra keyword arguments.

Returns:

None

Raises:

APIError – Error thrown by node API. See message for details.

get_bans(**kwargs) List[BannedPeerModel]

Get a list of banned peers.

Parameters:

**kwargs – Extra keyword arguments.

Returns:

A list of banned peers with information on duration and reason for ban.

Return type:

List[BannedPeerModel]

Raises:

APIError – Error thrown by node API. See message for details.

clear_banned(**kwargs) None

Clear banned node list.

Parameters:

**kwargs – Extra keyword arguments.

Returns:

None

Raises:

APIError – Error thrown by node API. See message for details.

BannedPeerModel

class BannedPeerModel(*, endPoint: str, banUntil: str, banReason: str)

A pydantic model describing a banned peer.

endpoint: str

The banned peer endpoint.

ban_until: str

The time when ban end.

ban_reason: str

The reason for the ban.