upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/nostr.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/nostr.h')
-rw-r--r--src/nostr.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/nostr.h b/src/nostr.h
index 63fc095..37b3b05 100644
--- a/src/nostr.h
+++ b/src/nostr.h
@@ -12,11 +12,17 @@
12 12
13#include <string> 13#include <string>
14#include <vector> 14#include <vector>
15#include <map>
15 16
16// Thread entry point (signature compatible with _beginthread) 17// Thread entry point (signature compatible with _beginthread)
17void ThreadNostrSeed(void* parg); 18void ThreadNostrSeed(void* parg);
18void ThreadBtfPoolAnnouncer(void* parg); 19void ThreadBtfPoolAnnouncer(void* parg);
19 20
21// Set to true to make ThreadBtfPoolAnnouncer publish immediately instead of
22// waiting for its ~60s sleep loop (e.g. right after the operator changes pool
23// name/fee/dashboard URL in Options). The announcer clears it after publishing.
24extern volatile bool gAnnounceNow;
25
20// Public relays used for discovery. Tunable. 26// Public relays used for discovery. Tunable.
21extern const char* pszNostrRelays[]; 27extern const char* pszNostrRelays[];
22extern const int nNostrRelays; 28extern const int nNostrRelays;
@@ -56,6 +62,9 @@ struct BtfPoolAnnouncement
56 } 62 }
57}; 63};
58 64
65// Number of .btf peers discovered from Nostr relays (includes not-yet-connected).
66int GetDiscoveredPeerCount();
67
59// Current live pool announcements discovered from Nostr relays. 68// Current live pool announcements discovered from Nostr relays.
60void BtfGetPoolAnnouncements(std::vector<BtfPoolAnnouncement>& out); 69void BtfGetPoolAnnouncements(std::vector<BtfPoolAnnouncement>& out);
61 70
@@ -78,4 +87,21 @@ std::string BtfLocalAddress();
78bool BtfResolve(const std::string& btfAddr, std::string& meetingHostPort, 87bool BtfResolve(const std::string& btfAddr, std::string& meetingHostPort,
79 unsigned char enc_pub[32]); 88 unsigned char enc_pub[32]);
80 89
90// Result of resolving one .btf address via BtfResolveMany.
91struct BtfResolvedPeer
92{
93 std::string meetingHostPort;
94 unsigned char enc_pub[32];
95};
96
97// Resolve many .btf addresses at once. Batches all still-unresolved addresses
98// into a single Nostr REQ per relay (multiple "authors"), instead of opening
99// one relay connection per address like BtfResolve does. Use this whenever
100// resolving more than a handful of addresses in the same pass -- e.g. before
101// dialing several discovered peers in parallel -- to avoid hammering the
102// same few public relays with a burst of simultaneous connections. Returns
103// true if at least one address resolved; check `out` for which ones.
104bool BtfResolveMany(const std::vector<std::string>& btfAddrs,
105 std::map<std::string, BtfResolvedPeer>& out);
106
81#endif 107#endif