|
Nostrduino
|
#include <NostrPool.h>
The main class for interacting with the Nostr network. Handles subscriptions, relays, and event publishing.
|
inline |
Create a new NostrPool
| transport | A transport object, you can get one for the esp32 platform using nostr::esp32::ESP32Platform::getTransport() , for other platforms you need to implement the Transport interface |
| eventStatusTimeoutSeconds | The number of seconds to wait for an event status before timing out (optional) |
| NostrPool::~NostrPool | ( | ) |
|
delete |
| void NostrPool::close | ( | ) |
Close the pool and disconnect from every relay
| void NostrPool::closeSubscription | ( | NostrString | subId | ) |
Close the subscription with the given ID
| subId | The subscription ID |
| void NostrPool::disconnectRelay | ( | NostrString | url | ) |
Disconnect from the specified relay
| url | The relay URL |
| NostrRelay * NostrPool::ensureRelay | ( | NostrString | url | ) |
Ensure the connection to the specified relay is open
| url | The relay URL |
| const std::vector< NostrRelay * > * NostrPool::getConnectedRelays | ( | ) | const |
Get all relays that the pool is connected to
| std::vector< NostrString > NostrPool::getRelays | ( | ) |
Get all relays that the pool is connected to
| const NostrSubscription * NostrPool::getSubscription | ( | const NostrString & | subId | ) | const |
Get a subscription by ID, or nullptr if it does not exist
|
inline |
Return whether incoming subscription events are verified.
| bool NostrPool::hasSubscription | ( | const NostrString & | subId | ) | const |
Check whether a subscription with the given ID exists
| bool NostrPool::publish | ( | const std::vector< NostrString > & | rs, |
| SignedNostrEvent * | event, | ||
| NostrEventStatusCallback | statusCallback = nullptr |
||
| ) |
| bool NostrPool::publish | ( | std::initializer_list< NostrString > | rs, |
| SignedNostrEvent * | event, | ||
| NostrEventStatusCallback | statusCallback = nullptr |
||
| ) |
Publish a signed event to one or more relays. The pool will automatically start listening to the specified relays after publishing.
| rs | The relays to publish to |
| event | The event to publish |
| statusCallback | A callback to be called when the event status is known (optional) |
| void NostrPool::setSeenTracker | ( | NostrSeenCallback | callback | ) |
Set the event tracking callback. Return true when an event has already been seen and should be discarded. A null callback restores the default behavior, which keeps no tracking state and returns false for every event.
Calls to the callback are serialized by the pool.
Enable or disable cryptographic verification of subscription events. Disabled by default for backwards compatibility.
| NostrString NostrPool::subscribeMany | ( | const std::vector< NostrString > & | urls, |
| JsonArray | filters, | ||
| NostrEventCallback | eventCallback = nullptr, |
||
| NostrCloseCallback | closeCallback = nullptr, |
||
| NostrEOSECallback | eoseCallback = nullptr |
||
| ) |
| NostrString NostrPool::subscribeMany | ( | const std::vector< NostrString > & | urls, |
| std::initializer_list< std::map< NostrString, std::initializer_list< NostrString > > > | filters, | ||
| NostrEventCallback | eventCallback = nullptr, |
||
| NostrCloseCallback | closeCallback = nullptr, |
||
| NostrEOSECallback | eoseCallback = nullptr |
||
| ) |
| NostrString NostrPool::subscribeMany | ( | std::initializer_list< NostrString > | urls, |
| JsonArray | filters, | ||
| NostrEventCallback | eventCallback = nullptr, |
||
| NostrCloseCallback | closeCallback = nullptr, |
||
| NostrEOSECallback | eoseCallback = nullptr |
||
| ) |
Subscribe to events from one or more relays
| urls | The relays to subscribe to |
| filters | A json array of filters for each relay |
| eventCallback | A callback to be called when an event is received (optional) |
| closeCallback | A callback to be called when the subscription is closed (optional) |
| eoseCallback | A callback to be called when the stored events are exhausted (optional) |
| NostrString NostrPool::subscribeMany | ( | std::initializer_list< NostrString > | urls, |
| std::initializer_list< std::map< NostrString, std::initializer_list< NostrString > > > | filters, | ||
| NostrEventCallback | eventCallback = nullptr, |
||
| NostrCloseCallback | closeCallback = nullptr, |
||
| NostrEOSECallback | eoseCallback = nullptr |
||
| ) |
Subscribe to events from one or more relays
| urls | The relays to subscribe to |
| filters | A list of filters for each relay |
| eventCallback | A callback to be called when an event is received (optional) |
| closeCallback | A callback to be called when the subscription is closed (optional) |
| eoseCallback | A callback to be called when the stored events are exhausted (optional) |