Nostr.Connection (nostr_access v0.3.3)

View Source

WebSocket connection to a Nostr relay with subscription management.

Summary

Functions

Closes a subscription.

Checks if the connection has free slots.

Publishes a Nostr event to the relay. The caller will receive {:pub_ack, conn_pid, event_id, success?, message}.

Starts a new connection to a relay.

Functions

close_subscription(conn_pid, sub_id)

@spec close_subscription(pid(), String.t()) :: :ok

Closes a subscription.

has_free_slot?(conn_pid)

@spec has_free_slot?(pid()) :: boolean()

Checks if the connection has free slots.

publish_event(conn_pid, caller_pid, event)

@spec publish_event(pid(), pid(), map()) :: :ok

Publishes a Nostr event to the relay. The caller will receive {:pub_ack, conn_pid, event_id, success?, message}.

send_filter(conn_pid, caller_pid, sub_id, filter)

@spec send_filter(pid(), pid(), String.t(), map()) :: :ok | {:error, :no_slots}

Sends a filter to the relay.

start_link(uri, caller_pid)

@spec start_link(String.t(), pid()) :: {:ok, pid()} | {:error, term()}

Starts a new connection to a relay.