nostr_tools.check_writability

async nostr_tools.check_writability(client, sec, pub, target_difficulty=None, event_creation_timeout=None)[source]

Check if the relay allows writing events and measure write response time.

This function creates and publishes a test event (kind 30166) to the relay and measures the response time. The event uses the relay URL as identifier.

Parameters:
  • client (Client) – An instance of Client (must be connected)

  • sec (str) – Private key for signing the test event

  • pub (str) – Public key corresponding to the private key

  • target_difficulty (Optional[int]) – Proof-of-work difficulty for the event

  • event_creation_timeout (Optional[int]) – Timeout for event creation

Returns:

(rtt_write in ms or None, writable as bool)

Return type:

Tuple[Optional[int], bool]

Raises:

ClientConnectionError – If client is not connected